start | find | index | login or register | edit
Sonntag, 30. Juli 2006 link

viktor wanted a better behaviour for the home key in VIM. pressing home once should take you to the outermost indent level (i.e. right where the actual line content starts). pressing home once more shall take you to the absolute home (column 0). subsequently pressing home again should switch between those two positions.

viktor likes it, i like it, loads of other editors do it that way by default. so i figured others might find it useful as well:

map <silent> <HOME> :call <SID>SwitchingHomeKey()<CR>
imap <silent> <HOME> <C-O>:call <SID>SwitchingHomeKey()<CR>

function! s:SwitchingHomeKey()
let l:c = col(".")
" move to outermost indent level
normal ^
if (col(".") == l:c)
" we did not move, so we are at outermost indent.
" move to col 0

normal 0
endif
endfunction

just drop it into your vimrc. i can't be bothered to mess with vim's plugin system or vim.org's script repository at the moment :)


no comments

Please log in (you may want to register first) to post comments!

powered by vanilla
echo earlZstrainYat|tr ZY @.
earl.strain.at • esa3 • online for 8452 days • c'est un vanilla site