Visual Studio代码与Android Studio功能搜索和源代码控制

Choosing the right tool for the job.

为工作选择合适的工具。

This article was originally published here on the Codemagic blog.

本文最初发布 Codemagic博客上。

Years ago, there weren’t many choices when it came to Integrated Development Environments (IDE). In the early days, there were languages like Visual Basic 6 which had to be written in Visual Studio and that was it.

多年前,在集成开发环境(IDE)方面没有太多选择。 在早期,必须使用Visual Studio编写类似Visual Basic 6的语言。

Nowadays, we have choices to make, not only related to what languages and frameworks we use to make our apps, but also the tooling that we use to accomplish this task. This topic is somewhat surprisingly hotly contested, with people avidly defending “their” IDE and plugins over another IDE.

如今,我们可以做出选择,不仅与我们用来制作应用程序的语言和框架有关,还与我们用于完成此任务的工具有关。 人们在热烈地争论着这个话题,人们在另一个IDE上为“他们的” IDE和插件辩护。

Comparing two different IDEs is a fairly big topic, so in this article, we’ll look at the differences between Visual Studio Code and Android Studio by focusing on three key aspects that I notice the most when comparing IDEs:

比较两个不同的IDE是一个相当大的话题,因此在本文中,我们将重点关注我在比较IDE时最注意到的三个关键方面,从而研究Visual Studio Code和Android Studio之间的区别:

  • Functionality: How easy is it is to get around my code? Can I tear tabs off and work on my code with more than one window open at a time?

    功能:遍历我的代码有多容易? 我可以一次打开多个窗口,然后撕下标签并处理代码吗?

  • 🔎Search: Is it straightforward to find where a certain widget has been used in my app? If I forget the implementation of something, can I easily search and find if it has been used somewhere else?

    🔎 搜索 :查找在我的应用程序中使用过某个小部件的位置是否简单明了? 如果我忘记了某些东西的实现,是否可以轻松地搜索并找到它是否已在其他地方使用?

  • 👩‍💻 Source control: Does the source control solution make it easy to see changes and differences?

    💻 源代码控制 :源代码管理解决方案是否易于查看更改和差异?

功能性 (Functionality)

Visual Studio程式码 (Visual Studio Code)

Visual Studio Code is an editor that favors simplicity over having an endless assortment of bells and whistles. Most of the functionality is exposed by typing in the thing you need into the top search bar.

Visual Studio Code是一种编辑器,它比简单多样的铃铛和哨子更偏向于简单。 大部分功能是通过在顶部搜索栏中键入所需的内容来显示的。

Image for post

Everything you would expect to be there is there: debugging, breakpoints, etc.

您所期望的一切都在那里:调试,断点等。

However, something that I have been doing for years in every IDE that I have used is to tearing off the tabs from the top. This is invaluable, as at various times I can effectively work on two parts of my app at the same time.

但是,在我使用的每个IDE中,多年来我一直在做的事情是撕掉顶部的选项卡 。 这是无价的,因为在任何时候我都可以同时有效地处理应用程序的两个部分。

Visual Studio Code can’t do this and it doesn’t seem like it’s getting this functionality any time soon. You can split your tabs so that one window is split down the middle or you can try to reopen the same project in another instance of Visual Studio Code. But you can’t just tear the tabs off.

Visual Studio Code无法做到这一点 ,而且似乎也不会很快获得此功能。 您可以拆分选项卡,以便将一个窗口拆分为中间的窗口,也可以尝试在另一个Visual Studio Code实例中重新打开同一项目。 但是您不能随便撕掉标签。

The practical effect of this is that if you are working between your services and your UI layer, you have to switch back and forth between both files until you eventually solve the issue.

这样做的实际效果是,如果在服务和UI层之间工作,则必须在两个文件之间来回切换,直到最终解决问题为止。

Android Studio (Android Studio)

Android Studio is more of a “kitchen sink” approach to an IDE. Google licensed IntelliJ IDEA and used it to make Android Studio. Software developers have been using it to make apps for Android for a very long time.

Android Studio更像是IDE的“厨房水槽”。 Google授予IntelliJ IDEA许可,并将其用于制作Android Studio。 长期以来,软件开发人员一直使用它来为Android开发应用程序。

In terms of tearing the tabs off: Well, you just do it. You just pick one up, drag it off, and you’re done. You can put these onto alternate screens — whatever you want. Any comparable solution to doing this in Visual Studio Code (that’s as easy as just grabbing the tab and moving it to where you want it) doesn’t seem to exist, at least not at the time of writing.

就撕下标签而言:好吧,您只需这样做。 您只需捡起一个,然后将其拖出即可完成。 您可以将它们放到备用屏幕上-随意设置。 在Visual Studio Code中执行此操作的任何可比的解决方案(就像只是抓住选项卡并将其移动到所需位置一样容易)似乎并不存在,至少在撰写本文时不存在。

For me personally, this is enough to make me want to use Android Studio by itself, but let’s press on.

就我个人而言,这足以使我想要自己使用Android Studio,但请继续。

搜索项目 (Searching in the project)

Visual Studio程式码 (Visual Studio Code)

Visual Studio Code has the ability to “search anywhere” in the project when the user presses CTRL+SHIFT+F.

当用户按下CTRL+SHIFT+F时,Visual Studio Code可以在项目中“搜索任何位置”。

Image for post

As we can see, I’ve searched for Sonder, and on the left-hand side of this window we have all the results. You can move backwards and forwards through them with F4 and SHIFT+F4. It's certainly functional.

如我们所见,我已经搜索了Sonder,并在该窗口的左侧获得了所有结果。 您可以使用F4SHIFT+F4在它们之间F4移动。 它肯定是功能正常的。

The only gripe I have with this search feature is that you tend to lose a lot of context when searching. We’re restricted to looking at each and every result of our search here, either by clicking on a specific result or using hotkeys to move through them. Afterwards, we can get back to where we were by clicking on the appropriate tab up at the top or hitting ALT+LEFT ARROW until we get back to where we were. Sometimes when I do that, I forget where I was up to and what I was doing initially.

我对这种搜索功能的唯一困扰是,搜索时往往会失去很多上下文 。 我们被限制在此处查看搜索的每个结果,方法是单击特定结果或使用热键在它们之间移动。 然后,我们可以通过单击顶部的适当选项卡或单击ALT+LEFT ARROW ,回到原来的位置,返回到原来的位置。 有时候,当我这样做时,我会忘记自己在做什么以及最初在做什么。

Android Studio (Android Studio)

Again, CTRL+SHIFT+F. But this time, we get a dedicated search dialog. It looks like this:

同样,按CTRL+SHIFT+F 但是这次,我们得到了专用的搜索对话框。 看起来像这样:

Image for post

If we search for something, like Sonder, we get the results in this dialog:

如果我们搜索诸如Sonder之类的东西,则会在此对话框中获得结果:

Image for post

Pressing the up or down cursors here will show us results from that particular file, as well as the 8–9 lines on either side of that search result.

在此处按下向上或向下光标将向我们显示该特定文件的结果,以及该搜索结果两侧的8–9行。

Image for post

SSometimes, I’m searching for an implementation of a certain widget or function, and then I just quickly hit CTRL+SHIFT+F to bring up this dialog. Doing so, I can quickly move through the list by using the up and down arrows, and when I have found what I'm looking for, I can just hit escape to go back to the file I was working on initially. In terms of productivity, I find this is more powerful and faster.

有时,我正在搜索某个小部件或函数的实现,然后我快速按下CTRL+SHIFT+F弹出此对话框。 这样做,我可以使用上下箭头快速浏览列表,当我找到要查找的内容时,只需按Escape键即可返回到最初正在处理的文件。 在生产率方面,我发现它更强大,更快。

源代码控制 (Source Control)

For more advanced source control operations I normally stick to using a dedicated tool like Fork, because it’s a lot easier to understand what is happening.

对于更高级的源代码控制操作,我通常会坚持使用专用工具(如Fork) ,因为它更容易理解正在发生的事情。

Still, you may find yourself in a situation where you have to use the tools of the IDE you are using, and that’s where the quality of the integrated source control solution does count.

尽管如此,您可能仍处在必须使用所使用的IDE工具的情况下,这才是集成源代码管理解决方案质量的关键。

Visual Studio程式码 (Visual Studio Code)

Visual Studio Code has an extremely wide array of source control utilities made available to it through extensions. But we’ll take a look at the built-in functionality that’s available.

Visual Studio Code通过扩展提供了种类繁多的源代码控制实用程序。 但是,我们将看一下可用的内置功能。

When writing this article, I noticed that I had changes to my pubspec.lock file, despite not recalling making any changes. The change window in Visual Studio Code looked like this:

在撰写本文时,我注意到我对pubspec.lock文件进行了更改,尽管没有记得进行任何更改。 Visual Studio Code中的更改窗口如下所示:

Image for post

Visual Studio Code knew that something had changed but couldn’t specifically call out what was different. If nothing has changed, then committing or resetting should logically have no impact, right? But it’s weird (and probably concerning) that Git is tracking a changed file but yet Visual Studio Code can’t show us what is different.

Visual Studio Code知道发生了某些变化,但无法明确指出有什么不同。 如果什么都没有改变,那么提交或重置在逻辑上应该没有影响,对吗? 但是Git跟踪一个更改的文件很奇怪(并且可能与此有关),但是Visual Studio Code不能告诉我们有什么不同。

Now, if we actually change a file, then we can see the change in the source control area of Visual Studio Code.

现在,如果我们实际上更改了文件 ,那么我们可以在Visual Studio Code的源代码控制区域中看到更改。

Image for post

This is functional. Deletions are shown in much the same way.

这是功能。 删除的显示方式几乎相同。

Android Studio (Android Studio)

Remember that pubspec.lock file for which Visual Studio Code couldn't tell us what the changes were? In Android Studio, it looks like this:

还记得Visual Studio Code不能告诉我们所做的更改的pubspec.lock文件吗? 在Android Studio中,它看起来像这样:

Image for post

So, there are still no actual changes shown, which is accurate. But up at the top of the “Diff” section, we see this text:

因此,仍然没有显示任何实际更改,这是准确的。 但是在“差异”部分的顶部,我们看到以下文本:

“Contents have differences only in line separators”

“内容仅在行分隔符中有所不同”

And then, on the left, we can see that the file used to have CRLF line endings but now has LF line endings. This is because of a change I made with my Git client for how it handles line endings, which happened after my initial checkout. That’s pretty cool — we can now decide on whether that’s something we want to commit or not.

然后,在左侧,我们可以看到该文件以前具有CRLF行尾,但现在具有LF行尾。 这是因为我与Git客户端进行了有关如何处理行尾的更改,该更改是在我最初结帐后发生的。 太酷了–我们现在可以决定是否要提交。

Checking actual file changes shows up like this as well:

检查实际文件更改也显示如下:

Image for post

Changes to the file and the comparisons between the version that is already in the repository and our local version are very clear. We can see the green highlighting showing us precise changes that are happening to the file. We can also untick or tick, on a line-by-line basis, what we want to commit before doing so.

对文件的更改以及存储库中已有的版本与我们的本地版本之间的比较非常清楚。 我们可以看到绿色的突出显示,向我们显示了文件中正在发生的精确更改。 我们还可以逐行取消或删除我们想要提交的内容。

In fact, Android Studio has quite a bit of flexibility when it comes to using Git as your source control system. These are the options from the Git menu:

实际上,在使用Git作为源代码控制系统时,Android Studio具有相当大的灵活性。 这些是Git菜单中的选项:

Image for post

我不能将插件添加到Visual Studio Code中以获得更好的功能吗? (Can’t I add plugins to Visual Studio Code for better functionality?)

You absolutely can, but I find that adding too many plugins to Visual Studio Code can bog it down considerably and make it slow to use. By the time you install all the stuff you need to do things like enhance the source control, you may be better off just choosing a more fully-featured IDE from the get-go.

您绝对可以,但是我发现向Visual Studio Code中添加太多插件会使它陷入困境,并使其使用缓慢。 当您安装完成诸如增强源代码控制之类的事情所需的所有东西时,您最好从一开始就选择功能更全的IDE。

Android Studio有一些您应该了解的奇怪的按键绑定: (Android Studio has some weird key bindings that you should know about:)

The one that got me is CTRL+Y. In Visual Studio Code, this will redo something you have undone. In Android Studio, it will delete the current line. The default key binding for redo is CTRL+SHIFT+Z. This one got me a few times😅.

而其中,让我为 CTRL+Y 在Visual Studio Code中,这将 重做 您已撤消的操作。 在Android Studio中,它将 删除当前行 默认键重做绑定是 CTRL+SHIFT+Z 这个让我好几次了。

那我该怎么用呢? (So what should I use?)

There are a variety of functionality differences between these two tools. Visual Studio Code is lighter than Android Studio, so if you are genuinely limited by your hardware, you may be better off on Visual Studio Code. Also, some plugins and enhancements are only available for one or the other, so that will impact your decision as well. I personally prefer Android Studio, but you should use both and make your own decision.

这两个工具之间存在多种功能差异。 Visual Studio Code比Android Studio轻巧,因此,如果您确实受到硬件的限制,那么使用Visual Studio Code可能会更好。 另外,某些插件和增强功能仅适用于彼此之一,因此也会影响您的决定。 我个人更喜欢Android Studio,但您应该同时使用两者并自行决定。

In the early days I went between both tools before finally settling on Android Studio. There’s no reason why you can’t do the same😊.

最初,我在最终使用Android Studio之前先使用这两种工具。 没有理由不能做同样的事情😊。

And of course, you should use what works best for you. For every article recommending Android Studio, I’m sure there’s an article recommending Visual Studio Code.

当然,您应该使用最适合自己的东西。 对于每篇推荐Android Studio的文章,我都肯定有一篇文章推荐Visual Studio Code。

Thanks for reading!

谢谢阅读!

翻译自: https://medium.com/swlh/visual-studio-code-vs-android-studio-functionality-search-and-source-control-6eadd16a9856

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值