Created
October 28, 2010 13:47
-
-
Save be5invis/651379 to your computer and use it in GitHub Desktop.
A Better <home> key for windows users
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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