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绝对值得学习,以下是部分总结前面所述的主要原因:

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

其他回答

我和你的情况一样,作为Vim的初学者,我最初发现它有点令人生畏——学习曲线似乎很陡峭。 从我在短短几个小时里学到的东西来看,我已经觉得没有它我就活不下去了。

下面是我找到的一些有用的Vim截屏链接,可以向您展示它的功能。

Bram Moolenaar (Vim的仁慈独裁者)在最后一个链接中给出的一个很好的建议是,试图学习每一个命令和函数是没有效率的,只是弄清楚你正在做的事情不是很好,寻找一种方法使它更有效,然后使它成为一种习惯。

仅在Unix系统上,Vim的惊人的普遍性,以及vi克隆的更惊人的普遍性,就足以使它值得学习。

除此之外,我认为整个vi式的思维方式让我变得更有效率。对于一个不习惯命令模式和插入模式等模式的人来说,仅仅为了插入文本而进入一个模式似乎有点过分。但是,当一个人已经使用Vim几个月,并且已经学习了相当多的技巧和技巧时,Vim似乎是一项值得的资产。

当然,关于Emacs风格的思维,Emacs人群也说了同样的话,但我放弃了学习Emacs,因为Vim更简单,而且为我做了这项工作。

没有它我能活下去吗?很容易。

它有用吗?是的。

学习的理由

vi保证在所有Unix系统上存在,并且在大多数Linux系统上也存在。这种广泛的覆盖面让学习变得值得。 使用vi编辑sudo要快得多: $ sudo vi 此外,GMail使用vi-ish命令来选择和移动电子邮件!

你不需要成为大师。

只是学习

基础知识:

如何从命令模式切换到插入模式i 如何从插入模式切换到命令模式Esc 如何在命令模式k中浏览一行 如何在命令模式下导航一行j 如何导航左字符在命令模式h 如何正确导航字符l 如何保存文件:wEnter (write) 不保存退出(命令模式下):q!输入 如何撤销 如何重做Ctrl+r 您可以结合写入和退出(在命令模式下)::wqEnter

剩下的只会让你跑得更快。

我学过Vim。这并不费劲。现在我绝对喜欢ci”ci(cw V:s/from/to/g

我已经使用vi/vim超过25年了。如果你已经知道一些命令行编辑器,那么你可能不需要学习vi/vim。但是如果您不太了解其他命令行编辑器,那么学习它是值得的。在vi/vim中很容易轻松地提高效率。