I’m still pretty new to Vim and keep practicing Vim everyday, and also started to learn some VimScript by myself, I found some nice learning resources and some easy but AWESOME key combinations.
Books and Articles
- A Byte of Vim, it has kinds of translations, including the traditional chinese version(not finish yet).
- Learn the Vi and Vim editors, published by Oreilly.
- Vi iMproved, you can buy a copy from Amazon, or download it for free, it’s available as a PDF!
- Learn Vimscript the Hard Way
- IBM DeveloperWorks VimScript Serial part 1, 2, 3, 4, 5
vimtutoris a great resource, you can type
vimtutorin terminal directly to launch it. there’s also some translated version, ex:
vimtutor zhwould be the tranditional chinese version.
- last but not the least, the best resource is the built-in HELP manual, just type
:h something, and you SHOULD read them through at least one time.
- dw : delete a word from current cursor position.
- diw : delete the whold word which the cursor is parking.
- dfSpace : delete everything until finding the next Space of the current line.
- di( : as above, but delete all words within the nearest parenthesis, di[, di", and di' also do pretty much the same thing.
- gv : re-select last visual select.
- ma to create a marker named
aat the current cursor, then by hitting 'a to jump to the
amarker. You can use
zas the name of the marker.
:.![command]will dump the output of the command to your current editing window.
%!xxdturn vim to a hex editor, and
%!xxd -rwill change it back.
- even you don’t manage your file within any version control system,
:earlier 10mcan help you to change the current file back to 10 minites ago, and
:later 10mwill jump back to 10 minites later.
:undo 5will go back by 5 changes, and
:undolistwill show you undo tree.
- you can grab web page source code into your editor directly, just like this
Some crazy/stupid things
I use Vim almost everyday now, but to be more sophisticated in it, I did some stupid or crazy things.
First, I removed my ESC key from my keyboard temporarily to force myself using Ctrl[, instead of hitting Esc to enter normal mode:
Why? actually there’s no good reason, just thought it might keep my fingers on main typing area in mode switching.
and second, I re-map the arrow keys to
<NOP> to disable them, both in normal mode and insert mode:
map <UP> <NOP> map <DOWN> <NOP> map <LEFT> <NOP> map <RIGHT> <NOP> inoremap <UP> <NOP> inoremap <DOWN> <NOP> inoremap <LEFT> <NOP> inoremap <RIGHt> <NOP>
You may think I’m crazy, but I think it’s a faster way to push those things into my muscle memory. I think there’s no shortcut to master Vim, just keep using it everyday.
At last, here is my yet another vimrc configuration. If you have any other tips which are also AWESOME, please let me know :)