Skip to content

Instantly share code, notes, and snippets.

@be5invis
Created October 28, 2010 13:47
Show Gist options
  • Save be5invis/651379 to your computer and use it in GitHub Desktop.
Save be5invis/651379 to your computer and use it in GitHub Desktop.
A Better <home> key for windows users
function HomeBind(offset)
let cursor=getpos('.')
let s0=getline(line('.'))
let s1=substitute(s0, "^\\s\\+", "", "")
let x=len(s0)-len(s1)+1
if col('.') == x-a:offset
let x=1
endif
call setpos('.', [cursor[0], cursor[1], x, cursor[3]])
endfunction
imap <silent> <Home> <Esc>:call HomeBind(1)<cr>i
nmap <silent> <Home> :call HomeBind(0)<cr>
vmap <silent> <Home> <Esc>:call HomeBind(1)<cr>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment