当前位置: 首页 > 工具软件 > Vim.js > 使用案例 >

vim a.vim如何使用_vim开发人员第0部分为何使用vim

牛嘉谊
2023-12-01

vim a.vim如何使用

**Note: I will be using NeoVim for this series. I address why below. But 99.99% of everything I cover will work exactly the same in Vim8. So, if you’d prefer to use Vim8 you can still learn a lot! From here on out I will use Vim and NeoVim interchangeably, unless noting differences.

**注意:我将在本系列中使用NeoVim。 我在下面说明原因。 但是我介绍的所有内容的99.99%将在Vim8中完全相同 。 因此,如果您更喜欢使用Vim8,仍然可以学到很多东西! 从现在开始,除非有区别,否则我将交替使用Vim和NeoVim。

什么是Vim? (What is Vim?)

Once I, a dog-lover, was talking to my friend, a cat-lover, about cats and their general disdain for humanity. That’s when he said something I’ll never forget. “The thing you don’t understand about cats is they’re not dogs”. Woah. Profound. What he meant was if you approach a cat the same way you would a dog, it’s just not going to work. With that in mind:

我曾经是爱犬的人,和我的爱猫犬友谈论猫及其对人类的普遍鄙视。 那是他说我永远不会忘记的话。 “关于猫,您不了解的是它们不是狗”。 哇。 深刻。 他的意思是,如果您以与养狗相同的方式对待猫,那是行不通的。 考虑到这一点:

The thing about Vim is it’s not an IDE

关于Vim的事情是它不是一个IDE

Vim isn’t an IDE, it’s a text editor. It’s a lightning-fast, feature-packed text-editor with more secrets than Hogwarts, and I’d argue that with a little tweaking it has the potential to be as good, if not better, than your current IDE.

Vim不是IDE,而是文本编辑器。 这是一个闪电般的,功能丰富的文本编辑器,比霍格沃茨拥有更多的秘密,我认为只要稍加调整,它就有可能比当前的IDE更好甚至更好。

I’ve been working as a software developer for circa ~2.5 years now, and for the last ~1 year I’ve been using Vim as my “daily driver”. About 80% of my time is spent with Javascript, and the other 20% in Python. Prior to using Vim I used VS Code and the IntelliJ IDEs (WebStorm and PyCharm in my case). All great tools, but all had their weaknesses and left me wondering “is there something better?”.

我从事软件开发工作大约有2.5年,而在过去的1年中,我一直将Vim用作“日常驱动程序”。 我约有80%的时间用于Javascript,另外20%的时间用于Python。 在使用Vim之前,我使用了VS Code和IntelliJ IDE(在我的情况下为WebStorm和PyCharm)。 所有很棒的工具,但都有缺点,让我想知道“还有什么更好的吗?”。

I started noticing some of the coding superheroes (you know the type) at my company were using Vim. At first I assumed it was something they used because they superheroes. But, soon I started to wonder if they were superheroes because they used Vim. Well the truth is Vim won’t make you a 10x developer by itself, but if you commit some time to learning its ways, it certainly can help (or can’t hurt). If you’re willing to take the plunge read on.

我开始注意到我公司的某些编码超级英雄(您知道类型)正在使用Vim。 起初,我认为这是他们使用的东西,因为它们是超级英雄。 但是,很快我就开始怀疑它们是否是超级英雄,因为它们使用了Vim。 好吧,事实是Vim本身不会使您成为10倍的开发人员,但是如果您花一些时间来学习它的方式,那么它肯定会有所帮助(或不会造成伤害)。 如果您愿意尝试,请继续阅读。

我在IDE中寻找什么? (What I Look For in an IDE?)

There are some key features of IDEs that boost productivity so much that they’re non-negotiable for me in a dev environment.

IDE的一些关键功能极大地提高了生产率,以至于在开发环境中,这对我来说是不可商议的。

  • Code completion/Intellisense

    代码完成/智能感知
  • Go to definition of functions/variables/etc.

    转到功能/变量/等的定义。
  • Directory navigation and searching

    目录导航和搜索

By the end of this series we will use the power of Vim plugins to expand the functionality to encompass all these features.

在本系列文章的最后,我们将使用Vim插件的功能来扩展功能,使其包含所有这些功能。

为什么要使用Vim? (Why Use Vim?)

There’s many reasons to use Vim as we’ll see in this series. It enhances productivity, it’s super cool (okay maybe only devs might think that), but I think most importantly it’s goddam ubiquitous. Seriously. Vim is everywhere. It’s shipped preloaded on almost every computer (for sure Mac and Linux and I’d be shocked if not Windows too). It’s on Linux servers that you’ll SSH into. It’s on the ancient, brick of a computer you may be asked by a random company to do some in-person coding on for an interview. If you have Vim at your deposal you’re efficient no matter your hardware setup.

在本系列文章中将会看到使用Vim的原因很多。 它提高了生产率,超酷(好吧,也许只有开发人员可能会这么认为),但我认为最重要的是它无处不在。 说真的 Vim无处不在。 它已经预装在几乎每台计算机上(肯定是Mac和Linux,如果不是Windows,我也会感到震惊)。 您将在SSH服务器上使用Linux服务器。 它是在古老的计算机积木上,随机公司可能会要求您进行面试编码以进行采访。 如果您要使用Vim,则无论硬件设置如何,都是高效的。

This last point might seem like a stretch. I mean, hopefully you’re not SSH-ing into production servers and writing code directly on them very often (this does happen though and in those moments, trust me, you want to be fast). But it’s much more than that. To really be a super-powered-developer, you need to be a super-user of your dev environment. Sure the company you work at now provides the IntelliJ suite of products, and you know every nook and cranny of WebStorm. But your next company might not pay for IntelliJ, and then what? Or sure you’re a wizard at VS Code, and it’s free and open-source, so there’s no reason you can’t have it anywhere? Maybe your next role is for the Government, or some other large enterprise, you’d be surprised what it’s like to get the permission to download software at some of these places. Even if it’s free.

最后一点似乎有些困难。 我的意思是,希望您不要通过SSH进入生产服务器并经常直接在其上编写代码(这种情况确实发生了,但是在那一刻,请相信我,您想要更快)。 但是,不仅如此。 要真正成为超级开发人员,您需要成为开发环境的超级用户。 确保您现在工作的公司提供IntelliJ产品套件,并且您知道WebStorm的每个细节。 但是您的下一家公司可能不会为IntelliJ付费,然后呢? 还是确定您是VS Code的向导,并且它是免费的开放源代码,所以没有理由在任何地方都无法使用它? 也许您的下一个角色是为政府或其他大型企业服务,您会惊讶于在其中一些地方获得下载软件许可的感觉。 即使是免费的。

This is really the amazing thing about Vim’s reach. You can be certain anywhere you go, you can hit-the-ground-running right from the get-go.

这真的是Vim触手可及的惊人之处。 您可以肯定自己去的任何地方,都可以从一开始就动身运行。

Vim与NeoVim (Vim vs. NeoVim)

I know I just preached my heart out about Vim’s ubiquity being it’s secret weapon. But, I have a confession. I actually use NeoVim.

我知道我只是对Vim的普遍存在感到鼓舞,因为它是秘密武器。 但是,我有一个表白。 我实际上使用NeoVim。

But why? NeoVim isn’t everywhere? What gives!?

但为什么? NeoVim是否无处不在? 是什么赋予了!?

It’s true NeoVim isn’t everywhere. And to be honest at this point in time. There really isn’t a difference between Vim8 and NeoVim. The reason I use NeoVim is more of a long-term and principled philosophy and also long-term mindset. NeoVim is maintained by a large community of developers and because of this is very community-driven. Vim on the other hand is maintained by a small core of developers (bus factor, jk). And seriously, at this moment they’re almost indistinguishable. In fact, I’ll be using NeoVim for this series but 99.99% of the tips and tricks I share will work exactly the same on Vim8.

是的,NeoVim并不处处都是。 老实说,在这一点上。 Vim8和NeoVim确实没有区别。 我使用NeoVim的原因更多是长期的,有原则的哲学以及长期的心态。 NeoVim由大型开发人员社区维护,因此这是非常由社区驱动的。 另一方面,Vim由一小部分开发人员维护(总线系数,jk)。 严重的是,此刻它们几乎是无法区分的。 实际上,我将在本系列中使用NeoVim,但是我分享的99.99%的技巧将在Vim8上完全相同

The reason I choose NeoVim is because sure today they’re basically identical, but one day they may not be. I plan on being a dev for many years to come and I’d rather put my eggs in the community-driven wagon (not sure I nailed that metaphor).

我选择NeoVim的原因是因为可以肯定的是, 今天它们基本上是相同的,但是有一天它们可能不相同。 我计划在未来很多年成为一名开发人员,而我更愿意将自己的工作投入社区驱动的旅行车中(不确定我是否牢牢抓住了这个隐喻)。

我为什么写这个? 我们需要另一个Vim教程吗? (Why Did I Write This? Do We Need Another Vim Tutorial?)

I’ve read every Vim blog post. I’ve watched every configuration video on YouTube. I’m in all the subreddits. Although there’s tons of great content out there, I’ve often found there’s a key detail glossed over, or a concept not fully explained. My goal is to teach you everything from scratch. Every command will be explained fully. Every line of the init.vim/.vimrc will be explained. You will know your Vim setup inside and out.

我已经阅读了所有Vim博客文章。 我已经看过YouTube上的所有配置视频。 我参与所有的讨论。 尽管那里有很多精彩的内容,但我经常发现其中的关键细节被掩盖了,或者一个概念没有得到充分解释。 我的目标是从头开始教您一切。 每个命令将被完整解释。 将解释init.vim / .vimrc的每一行。 您将内外了解Vim的设置。

您可以从本系列中学到什么? (What Can You Expect to Learn From This Series?)

You can away with to come away from this series with:

您可以通过以下方法远离本系列:

  • A working knowledge of vanilla Vim (commands, mnemonics, buffers, modes, and macros)

    普通Vim的工作知识(命令,助记符,缓冲区,模式和宏)
  • Ability to customize your Vim using the config file (.vimrc/init.vim)

    可以使用配置文件(.vimrc / init.vim)自定义Vim
  • Knowledge to enhance your Vim setup using the power of plugins.

    利用插件的功能来增强Vim设置的知识。
  • The confidence to begin using Vim in your day-to-day work.

    有信心在日常工作中开始使用Vim。

潜水 (Take The Dive)

  1. Vim for Developers: Part 1 — The Basics

    Vim for Developers:第1部分-基础

  2. Vim for Developers: Part 2 — Advanced Basics

    Vim for Developers:第2部分-高级基础

翻译自: https://medium.com/@dbo1093/vim-for-developers-part-0-why-vim-95e68dc5d3a1

vim a.vim如何使用

 类似资料: