VIM

I used VIM as my primary text editor for a very long time. These are some of the most useful tricks I picked up.

DVORAK mappings

Using VIM with a DVORAK keyboard is not hard. I learned nearly everything I know about VIM using a QWERTY keyboard, but I did not find the transition particularly difficult. Most of the hotkeys can keep the same location on the keyboard with some clever mappings.

""""""""" DVORAK FTW LOLZ! "
noremap d h
noremap h j
noremap t k
noremap n l
noremap k d
noremap l n
noremap j t
noremap ^Wd ^Wh
noremap ^Wh ^Wj
noremap ^Wt ^Wk
noremap ^Wn ^Wl

I added the above code to my .vimrc file. Here is a summary of what happens:

Helpful Hotkeys

After doing a text search with a string which matches many times in a file, having every instance highlighted can be distracting. Instead of doing a new search to clear the results, try the :noh command. I map this to the comma key.

map , :noh<CR>

I sometimes line up code by adding spaces. Moving in and out of insert mode to do this is tedious, so I map <space> in normal mode like this:

map <space> i<space><esc><right>

Saving and typing :make repeatedly is no fun. I map <C-c><C-c> to save the file and run :make. I also map <C-c><C-v> to run the output of the project.

map <C-c><C-c> :w<CR>:make<CR> " add to .vimrc
map <C-c><C-v> :!./program<CR> " do this by hand every time

This is how I quit REALLY FAST.

map q :q<CR> " quit one buffer fast
map Q :qa<CR> " GET ME OUT OF EVERY BUFFER NOW (unless some are unsaved)

Comments

Click here to view the comments on this post.