My Vim-fu improved a lot in the last couple of years.
Part of the reason is that working on dotvim forced me to dive deeper into it, but thats not the whole story.
I think a much bigger reason is that I decided to systematically work on improving it.
One of the tricks I use is to have a list of Vim tricks and shortcuts that I’m learning right now on my OSX dashboard.
Whenever I come by a new shortcut or trick I add it to the list. Once I feel like I learned it and added it to my regular tool-belt I remove it from the list.
The current list looks like this:
]p - paste with indent
n| - to n-th column
& - repeat subst
g& - global repeat subst
Regarding n|
I don’t know how I got this far w/o knowing it ;). n
means any
number, e.g. 5|
or 37|
, which would go to column 5 and 37 respectively.
I use nG
all the time to get to line number n
, so naturally it should have
been clear to me that there is a horizontal equivalent to it, but no, I just
stumbled on it by ‘mistake’ a couple of days ago.
Once I add something to the list I try to use it as much as possible in the next days, until I feel I know it well enough that I actually remember it exists and use it during regular text editing. Once it happens, I remove it and replace it with something else what I just found or things I know but feel that I don’t use enough.
In the coming weeks I’ll try to write a semi-regular short posts here about new nice Vim things that I find. I have enough content for a while just talking about all the great stuff in dotvim ;).
But first lets start with some basics.
If you don’t yet understand the DNA of Vim, how most its commands are verb
+
motion
, then go and read this first: “Your problem with Vim is that you don’t
grok vi”. Note that the guy eventually gets to pretty advanced Vim
that you don’t need at the beginning, but read it anyway, even if only to know
what is possible once you really master this great editor.
This is another introduction into the verb+motion nature of Vim: “Why, oh WHY, do those #?@! nutheads use vi?”.
It is a little more beginner friendly, but a little less coherent too.
“Everyone Who Tried to Convince Me to use Vim was Wrong” is another nice article from Yehuda Katz of Rails fame where he talks about how own road to Vim.
He describes a more incremental approach of staying mostly in the insert
mode
for a first couple of days until you learn native Vim ways to do things.
Especially, if you use MacVim, gVim or another Vim wrapper that provides you
with all the regular operating system keyboard shortcuts like ⌘S
for
save and ⌘W
for close etc. I didn’t do it this way myself, and I
remain slightly skeptical as to the premise, will be glad to hear some
success/failure stories in the comments.
I agree though that I would definitely not recommend disabling arrow-keys until you are already semi-pro.
Now once you’ve read all this and ready to dive in, I recommend you do go and install dotvim as it packages lost of very useful settings and plugins that will make the experience much better. Just follow the “Installation” section of the README.
If you want to read some more, here you go:
- Coming Home to Vim - another nice introduction into “physics” of Vim.
- VIM Recipes - free cookbook for Vim.
- Best VIM Tips.
Also you can browse and follow my Vim bookmarks here.
UPDATE 10-Dec-2012 This article was translated to Serbo-Croatian language by Jovana Milutinovich from Webhostinggeeks.com.