start | find | index | login or register | edit
2006-07-30
by earl, 4857 days ago
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 :)
powered by vanilla
echo earlZstrainYat|tr ZY @.
earl.strain.at • esa3 • online for 6831 days • c'est un vanilla site