mappings.vim 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. " Basic Key Mappings
  2. imap <C-h> <C-w>h
  3. imap <C-j> <C-w>j
  4. imap <C-k> <C-w>k
  5. imap <C-l> <C-w>l
  6. " g Leader key
  7. let mapleader=" "
  8. " let localleader=" "
  9. nnoremap <Space> <Nop>
  10. " Better indenting
  11. vnoremap < <gv
  12. vnoremap > >gv
  13. if exists('g:vscode')
  14. " Simulate same TAB behavior in VSCode
  15. nmap <Tab> :Tabnext<CR>
  16. nmap <S-Tab> :Tabprev<CR>
  17. else
  18. " Better nav for omnicomplete
  19. inoremap <expr> <c-j> ("\<C-n>")
  20. inoremap <expr> <c-k> ("\<C-p>")
  21. " I hate escape more than anything else
  22. inoremap jk <Esc>
  23. inoremap kj <Esc>
  24. " Easy CAPS
  25. " inoremap <c-u> <ESC>viwUi
  26. " nnoremap <c-u> viwU<Esc>
  27. " TAB in general mode will move to text buffer
  28. nnoremap <silent> <TAB> :bnext<CR>
  29. " SHIFT-TAB will go back
  30. nnoremap <silent> <S-TAB> :bprevious<CR>
  31. " Move selected line / block of text in visual mode
  32. " shift + k to move up
  33. " shift + j to move down
  34. xnoremap K :move '<-2<CR>gv-gv
  35. xnoremap J :move '>+1<CR>gv-gv
  36. " Alternate way to save
  37. nnoremap <silent> <C-s> :w<CR>
  38. " Alternate way to quit
  39. nnoremap <silent> <C-Q> :wq!<CR>
  40. " Use control-c instead of escape
  41. nnoremap <silent> <C-c> <Esc>
  42. " <TAB>: completion.
  43. inoremap <silent> <expr><TAB> pumvisible() ? "\<C-n>" : "\<TAB>"
  44. " Better window navigation
  45. nnoremap <C-h> <C-w>h
  46. nnoremap <C-j> <C-w>j
  47. nnoremap <C-k> <C-w>k
  48. nnoremap <C-l> <C-w>l
  49. " Terminal window navigation
  50. tnoremap <C-h> <C-\><C-N><C-w>h
  51. tnoremap <C-j> <C-\><C-N><C-w>j
  52. tnoremap <C-k> <C-\><C-N><C-w>k
  53. tnoremap <C-l> <C-\><C-N><C-w>l
  54. inoremap <C-h> <C-\><C-N><C-w>h
  55. inoremap <C-j> <C-\><C-N><C-w>j
  56. inoremap <C-k> <C-\><C-N><C-w>k
  57. inoremap <C-l> <C-\><C-N><C-w>l
  58. tnoremap <Esc> <C-\><C-n>
  59. " Use alt + hjkl to resize windows
  60. " nnoremap <silent> <M-j> :resize -2<CR>
  61. " nnoremap <silent> <M-k> :resize +2<CR>
  62. " nnoremap <silent> <M-h> :vertical resize -2<CR>
  63. " nnoremap <silent> <M-l> :vertical resize +2<CR>
  64. nnoremap <silent> <C-Up> :resize -2<CR>
  65. nnoremap <silent> <C-Down> :resize +2<CR>
  66. nnoremap <silent> <C-Left> :vertical resize -2<CR>
  67. nnoremap <silent> <C-Right> :vertical resize +2<CR>
  68. let g:elite_mode=0 " Disable arrows"
  69. " Disable arrow movement, resize splits instead.
  70. if get(g:, 'elite_mode')
  71. nnoremap <C-Up> :resize -2<CR>
  72. nnoremap <C-Down> :resize +2<CR>
  73. nnoremap <C-Left> :vertical resize -2<CR>
  74. nnoremap <C-Right> :vertical resize +2<CR>
  75. endif
  76. endif
  77. " Better nav for omnicomplete
  78. inoremap <expr> <c-j> ("\<C-n>")
  79. inoremap <expr> <c-k> ("\<C-p>")