Skip to content

Commit

Permalink
finetune according to c9s's suggestion.
Browse files Browse the repository at this point in the history
  • Loading branch information
chenkaie committed Nov 14, 2009
1 parent f3e834d commit d9cb7ba
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions .vim/plugin/crazyhomekey.vim
Expand Up @@ -3,7 +3,7 @@
" Description: Finetune Home key operation for Programmer
" Maintainer: Kent Chen <chenkaie at gmail dot com>
" Version: 1.0
" Last Modified: Sun Oct 04, 2009 02:45AM
" Last Modified: Thu Oct 22, 2009 12:11AM
" License: This program is free software. It comes without any warranty,
" to the extent permitted by applicable law. You can redistribute
" it and/or modify it under the terms of the Do What The Fuck You
Expand Down Expand Up @@ -50,24 +50,30 @@ endfunction

function! ToggleHomeActionN()
if (GetPrevChar() == " " || GetPrevChar() == "\t")
call feedkeys("0", 'n')
"call feedkeys("0", 'n')
normal 0
" This works too!
" call setpos('.', [0, line('.'), 1])
else
call feedkeys("^", 'n')
"call feedkeys("^", 'n')
normal ^
endif
return ""
endfunction

function! ToggleHomeActionI()
if (GetPrevChar() == " " || GetPrevChar() == "\t")
" call setpos('.', [0, line('.'), 1])
call feedkeys("\<Home>i")
" call feedkeys("\<Home>i")
normal 0
else
call feedkeys("\<Esc>^i")
"call feedkeys("\<Esc>^i")
normal ^
endif
return ""
endfunction

nmap <silent> [1~ :call ToggleHomeActionN()<CR>
imap <silent> [1~ <ESC>:call ToggleHomeActionI()<CR>
nmap <silent> [1~ :call ToggleHomeActionN()<CR>
imap <silent> [1~ <C-r>=ToggleHomeActionI()<CR>
" vim:set ft=vim et sw=4 sts=4:

0 comments on commit d9cb7ba

Please sign in to comment.