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#,它们一起使编辑代码比以前更快更容易,但即使如此,我认为我可以享受根本不需要使用鼠标。

甚至连方向键都没有。


当前回答

是的,一定要花时间学习至少一点'vi'和'vim'。它旅行很好。

当你面对一个你没有安装能力的Unix/Linux/Mac系统时,你永远不会被困住。即使在Windows上(如果你有安装功能)“Vim”是免费且易于安装的。(而不是把你的学习曲线完全投入到像UltraEdit这样的东西上,尽管一个优秀的编辑器可能并不总是适合你……)

学习vi可以帮助你学习其他工具,比如sed和regex:一般来说是可迁移的东西。

另外,如果你想成为一个真正的极客,你只需要知道'vi/m',否则你看起来就像一个骗子;-)

其他回答

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

我在远程计算机上维护一个非常大的linux项目。不能选择使用Eclipse或类似的基于GTK的IDE。我在那里工作三年了。 我为这个项目设置了vim。还在调整。

现在我可以在Vim中做任何事情:源代码控制、sql、调试、编译、浏览——非常快速地浏览超过1Gb的源代码。

Visual Studio或Eclipse无法处理所有这些。如果我有选择,我不会把Vim换成其他编辑器或IDE。

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书籍也很好,但口袋参考给你所有的基础知识,快速高效。

我的工作迫使我学习vim,这很快就成为了我的第二天性。现在我抱怨的是没有vim仿真或插件的IDE。我注意到esc键已经成为我在vim之外的敌人。

我确实在Visual Studio中找到了几个vi模拟器:

http://code.google.com/p/vim-visual-studio/

无论是vim还是emacs,都绝对值得学习。触摸打字也是值得学习的。在这两种情况下,原因是相同的:你的思考不再被把代码显示在屏幕上的机械过程所打断。

至于如何开始,只需开始使用vim进行所有操作。

附:关于emacs和vi的争论是无休止的。我已经使用emacs 26年了。如果我今天重新开始,我会学习vim,因为(a)它变得更好了,(b)修改键更少了(ctrl - alt - v,任何人),vim用户似乎打字受伤少了很多。