As a programmer I spend a lot of hours at the keyboard and I've been doing it for the last 12 years, more or less. If there's something I've never gotten used to during all this time, it's these annoying and almost unconscious constant micro-interruptions I experience while coding, due to some of the most common code editing tasks. Things like a simple copy & paste from a different line (or even the same line), or moving 1 or 2 lines up or down from the current position require too much typing or involve the use of the arrow keys ...and it gets worse when I want to move further - I end up using the mouse. Now imagine this same scenario but on a laptop.

我一直在考虑学习VIM,但掌握它所需的时间总是让我想后退一步。

我想听听那些学会了它的人的意见,如果它最终成为你生活中不可或缺的东西之一。

在工作中,我使用VS2008, c#和r#,它们一起使编辑代码比以前更快更容易,但即使如此,我认为我可以享受根本不需要使用鼠标。

甚至连方向键都没有。


当前回答

我认为花时间和精力去学习vim绝对是值得的。对我来说,它使得在文本中输入和导航变得如此高效,很难想象回到emacs或ctrl/shift/alt/meta组合键。

不要被vim所有花哨的特性吓倒。一旦你用得够多了,你就会知道哪些命令用得最多,哪些事情可以忘记。

其他回答

我使用vi和vim也有20年了,我还在学习新的东西。

David Rayner的Best of Vim Tips网站是一个很好的列表,不过如果您对Vim比较熟悉,它可能会更有用。

我还想提一下ViEmu网站,那里有一些关于vi/vim技巧的很棒的信息,特别是文章Why, oh, Why, do those nuhead with vi?(存档版本)

I'd say vim is definitely worth learning. I picked it up last summer, and it is now my editor of choice for just about everything (java is a stretch, but doable when I don't need extensive analysis support). As everyone has already affirmed, it is a wonderfully efficient tool. For what it's worth, I only learned a fairly small subset of vim's features (which took a day or two) from a graphical tutorial, and a few odds and ends from here (long read), and the search and replace functionality, and I was hooked. I've learned things since then, but at my leisure. I'd say the learning curve flattens out at this point, but then, I was using it pretty heavily and was surrounded by others who were, too.

只需学习16个键的含义,就可以从vim中获得良好的功能:ijkdbw9:q!%s/nNEsc。只需要i:wqEsc就可以完成基本的构造。

你需要知道的前两个键是:Esc将你带入命令模式(你开始的模式),i将你带入插入模式(正常输入)。


为了拯救你需要

退出打字模式(Esc) 键入冒号: 输入小写字母w然后回车

要保存并退出,你需要这样做

退出打字模式(Esc) 键入冒号: 键入小写wq然后回车

不保存并强制退出,你需要

退出打字模式(Esc) 键入冒号: 小写的q!然后输入


要了解更多信息,可以在命令行上运行vimtutor。这是一节中等长度、结构合理的课。

除了i和Esc:你可以复制或超越一些MS Word功能,只需要jkwbd3:%s/nN。

b带你回到一个单词(Ctrl+←) w带你前进一个单词(Ctrl+→) 9w带你前进9个单词 db删除前面的单词(Ctrl+Backspace) D3b删除前面三个单词 9j向下移动9行 输入将带你到单词“ornithopter”的下一个实例,然后n和n分别到“ornithopter”的下一个和前一个出现。 :%s/ confaded /dangfangled/输入每一个“confaded”替换为“dangfangled”(就像在Word中查找和替换all一样)

这些都应该在“命令”模式(Esc)下运行,而不是在插入模式(i)下运行。

浏览vimtutor只花了我30分钟,这足以让我熟悉vim。每一秒都是值得的。

I too put off learning vi or vim for many years. Matter of fact, I use to make fun of the "vi guys" who always seemed to be doing finger aerobics. Then, as I moved away from Windows and over to Linux as my primary OS, I had to become more familiar with vim. It was a learning curve and it still is. After 9 years of using vim on a daily basis I still find myself learning new and faster ways of doing things. What I use to think of as "finger aerobics" actually turned out to be an extremely efficient way of being productive. I can now do a whole lot more code development in a whole lot less time and effort than I ever did prior to vim. And as I'm sure you know vim runs on about every platform out there so you always have it when you need it. Also, if you like GUI's they have GUI versions for most platforms. Personally, just like the mouse, I don't want to see a menu bar, scroll bars, etc. cluttering up my editing window(s).

如果你决定尝试一下vim,我强烈推荐O'Reilly的《vi Editor Pocket Reference》一书。它很便宜,如果你只是学习vi (vim),它是很棒的。完整的vim书籍也很好,但口袋参考给你所有的基础知识,快速高效。