Last active
October 7, 2016 06:59
-
-
Save kentarosasaki/73ed0f17ed118916be5c895e2b8a50d5 to your computer and use it in GitHub Desktop.
VimをちょっとだけEmacsキーバインドに近づけるための.vimrc ref: http://qiita.com/kentarosasaki/items/785d8c1e1c4433df6ac9
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
" insert mode | |
imap <C-p> <Up> | |
imap <C-n> <Down> | |
imap <C-b> <Left> | |
imap <C-f> <Right> | |
imap <C-a> <C-o>:call <SID>home()<CR> | |
imap <C-e> <End> | |
imap <C-d> <Del> | |
imap <C-h> <BS> | |
imap <C-k> <C-r>=<SID>kill()<CR> | |
function! s:home() | |
let start_column = col('.') | |
normal! ^ | |
if col('.') == start_column | |
¦ normal! 0 | |
endif | |
return '' | |
endfunction | |
function! s:kill() | |
let [text_before, text_after] = s:split_line() | |
if len(text_after) == 0 | |
¦ normal! J | |
else | |
¦ call setline(line('.'), text_before) | |
endif | |
return '' | |
endfunction | |
function! s:split_line() | |
let line_text = getline(line('.')) | |
let text_after = line_text[col('.')-1 :] | |
let text_before = (col('.') > 1) ? line_text[: col('.')-2] : '' | |
return [text_before, text_after] | |
endfunction |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment