Helpful .vimrc Additions
Like all of you, I love vim, but occasionally want more out of it, or for it not to do something. Sometimes these are features that exist on one linux machine I use and I immediately know I must have it on mine. Sometimes something just gets too annoying. Here are useful things I've found:
That you want some sort of syntax highlighting and auto-indenting is almost a given. You may want to do more, such as auto-expanding tabs, setting tab width, changing syntax highlighting, changing tabbing behavior, and so on. I keep it simple:
I like to see code below the line at which my cursor is currently pointing. Sometimes the cursor is at the bottom of the screen, though, and by default, you don't see the next lines. Similarly, if the cursor is at the top of the screen, you don't see the previous lines. Here's a nifty way to make sure the cursor is never at the top or bottom unless it's the beginning or the end of the file:
How many times have you typed :W or :Q or :Wq or :WQ? Your finger is already pressing shift, so not lifting the shift button quickly enough happens often.
1234 | command -bang W w<bang>
command -bang Q q<bang>
command -bang WQ wq<bang>
command -bang Wq wq<bang>
|
You edit a file, close it, open it back up... wouldn't it be nice if the cursor was where you left it? You can change parameters here to your liking.
12345678910111213141516171819 |
set viminfo='10,\
function! ResCur()
if line("'\"") <= line("$")
normal! g`
return 1
endif
endfunction
augroup resCur
autocmd!
autocmd BufWinEnter * call ResCur()
augroup END
|
Ches Koblents
July 30, 2012