mappings.vim 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. endif
  65. " Better nav for omnicomplete
  66. inoremap <expr> <c-j> ("\<C-n>")
  67. inoremap <expr> <c-k> ("\<C-p>")