Simple image host.
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

emacs-bindings.vim 1.3KB

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