Simple image host.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

emacs-bindings.vim 1.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. " Basic cursor movement and deletion keybindings from emacs, for vim.
  2. " insert mode
  3. imap <C-g> <ESC>
  4. imap <C-b> <Left>
  5. imap <C-f> <Right>
  6. imap <C-p> <Up>
  7. imap <C-n> <Down>
  8. imap <C-a> <C-o>:call <SID>home()<CR>
  9. imap <C-e> <End>
  10. imap <C-d> <Del>
  11. imap <C-h> <BS>
  12. imap <C-k> <C-r>=<SID>kill_line()<CR>
  13. " command line mode
  14. cmap <C-p> <Up>
  15. cmap <C-n> <Down>
  16. cmap <C-b> <Left>
  17. cmap <C-f> <Right>
  18. cmap <C-a> <Home>
  19. cmap <C-e> <End>
  20. cnoremap <C-d> <Del>
  21. cnoremap <C-h> <BS>
  22. cnoremap <C-k> <C-f>D<C-c><C-c>:<Up>
  23. " command-T window
  24. let g:CommandTCursorLeftMap = ['<Left>', '<C-b>']
  25. let g:CommandTCursorRightMap = ['<Right>', '<C-f>']
  26. let g:CommandTBackspaceMap = ['<BS>', '<C-h>']
  27. let g:CommandTDeleteMap = ['<Del>', '<C-d>']
  28. function! s:home()
  29. let start_col = col('.')
  30. normal! ^
  31. if col('.') == start_col
  32. normal! 0
  33. endif
  34. return ''
  35. endfunction
  36. function! s:kill_line()
  37. let [text_before_cursor, text_after_cursor] = s:split_line_text_at_cursor()
  38. if len(text_after_cursor) == 0
  39. normal! J
  40. else
  41. call setline(line('.'), text_before_cursor)
  42. endif
  43. return ''
  44. endfunction
  45. function! s:split_line_text_at_cursor()
  46. let line_text = getline(line('.'))
  47. let text_after_cursor = line_text[col('.')-1 :]
  48. let text_before_cursor = (col('.') > 1) ? line_text[: col('.')-2] : ''
  49. return [text_before_cursor, text_after_cursor]
  50. endfunction