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…)

其他回答

vi/vim的两个优点:

它很轻 它几乎安装在每个*NIX系统上

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

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

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

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

恕我直言,学习新东西总是值得努力的。我建议你打印一张小抄单,强迫自己日复一日地使用它。

Vim绝对值得学习,以下是部分总结前面所述的主要原因:

Vi/Vim can be found on most unix systems. Vim allows you to easily code without taking your hands off the keyboard. If you plan you configure anything in a unix based system likelihood is you going to be editing a fair few config files, therefore you'll want to learn a terminal based editor, of which vim is one of the best (sorry emacs). Vim compiles/has precompiled binaries for almost every OS out there. No need to post "I need a textmate alternative for [insert OS]", you'll have Vim instead! There are a lot of good plugins out there to add alot of functionality, such as in-editor cvs diffs, although some of these require a fair amount of tinkering.

另外,如果您喜欢Vim键绑定,也有一些ide在它们的编辑器中包含了Vim绑定,用于简单的命令,例如Komodo Edit。

要获得学习Vim的帮助,请尝试在终端中输入'vimtutor'并按照说明进行操作。还有一本书是特别好的Hacking Vim