vim

More VIM tips

More vim things I really should have known before today:

http://www.moolenaar.net/habits.html

The bits I really liked from those tips are:

Pressing the * command to find the next occurence of the word and then using cw to change that word. Then pressing n to find the next word and . to repeat the cw command!

Typing the beginning of a function/variable and then pressing CTRL+N to get an autocomplete menu.

Typing qa to record a macro to register "a" and then q to stop. Press @a to repeat the macro.

Some VIM tips

I've been writing quite abit of javascript recently. Unfortunately by formatting is abit hit and miss. Thankfully sites like http://jsbeautifier.org/ exist to tidy up.

There is also a vim plugin: http://www.vim.org/scripts/script.php?script_id=2727

Drop it into your .vim/plugins folder and then "use: leader ff or bind the g:Jsbeautify() function to any short key you like."

If those instructions look like gobbledegook to you (it did to me) then know that leader defaults to "\" (so you would type \ff) and you can bind it to F5 (for example) by putting this into your .vimrc file:

map <F5> :call g:Jsbeautify()<CR>

Vim Replace All Reminder

I keep forgetting this so here it is for me to remember

Replace all occurences of foo with bar in the file:

%s/foo/bar/g
Syndicate content