/vimrcs/extended.vim

https://gitlab.com/jeichert/vimrc · Vim Script · 147 lines · 78 code · 29 blank · 40 comment · 7 complexity · 8e213c655d03fd79053cc5e73e0d166c MD5 · raw file

  1. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  2. " Important:
  3. " This requries that you install https://github.com/amix/vimrc !
  4. "
  5. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  6. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  7. " => GUI related
  8. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  9. " Set font according to system
  10. if has("mac") || has("macunix")
  11. set gfn=Source\ Code\ Pro:h15,Menlo:h15
  12. elseif has("win16") || has("win32")
  13. set gfn=Source\ Code\ Pro:h12,Bitstream\ Vera\ Sans\ Mono:h11
  14. elseif has("linux")
  15. set gfn=Source\ Code\ Pro:h12,Bitstream\ Vera\ Sans\ Mono:h11
  16. elseif has("unix")
  17. set gfn=Monospace\ 11
  18. endif
  19. " Open MacVim in fullscreen mode
  20. if has("gui_macvim")
  21. set fuoptions=maxvert,maxhorz
  22. au GUIEnter * set fullscreen
  23. endif
  24. " Disable scrollbars (real hackers don't use scrollbars for navigation!)
  25. set guioptions-=r
  26. set guioptions-=R
  27. set guioptions-=l
  28. set guioptions-=L
  29. " Colorscheme
  30. if has("gui_running")
  31. set background=dark
  32. colorscheme peaksea
  33. else
  34. colorscheme desert
  35. let g:colors_name="desert"
  36. endif
  37. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  38. " => Fast editing and reloading of vimrc configs
  39. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  40. map <leader>e :e! ~/.vim_runtime/my_configs.vim<cr>
  41. autocmd! bufwritepost vimrc source ~/.vim_runtime/my_configs.vim
  42. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  43. " => Turn persistent undo on
  44. " means that you can undo even when you close a buffer/VIM
  45. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  46. try
  47. set undodir=~/.vim_runtime/temp_dirs/undodir
  48. set undofile
  49. catch
  50. endtry
  51. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  52. " => Command mode related
  53. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  54. " Smart mappings on the command line
  55. cno $h e ~/
  56. cno $d e ~/Desktop/
  57. cno $j e ./
  58. cno $c e <C-\>eCurrentFileDir("e")<cr>
  59. " $q is super useful when browsing on the command line
  60. " it deletes everything until the last slash
  61. cno $q <C-\>eDeleteTillSlash()<cr>
  62. " Bash like keys for the command line
  63. cnoremap <C-A> <Home>
  64. cnoremap <C-E> <End>
  65. cnoremap <C-K> <C-U>
  66. cnoremap <C-P> <Up>
  67. cnoremap <C-N> <Down>
  68. " Map ½ to something useful
  69. map ½ $
  70. cmap ½ $
  71. imap ½ $
  72. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  73. " => Parenthesis/bracket
  74. """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  75. vnoremap $1 <esc>`>a)<esc>`<i(<esc>
  76. vnoremap $2 <esc>`>a]<esc>`<i[<esc>
  77. vnoremap $3 <esc>`>a}<esc>`<i{<esc>
  78. vnoremap $$ <esc>`>a"<esc>`<i"<esc>
  79. vnoremap $q <esc>`>a'<esc>`<i'<esc>
  80. vnoremap $e <esc>`>a"<esc>`<i"<esc>
  81. " Map auto complete of (, ", ', [
  82. inoremap $1 ()<esc>i
  83. inoremap $2 []<esc>i
  84. inoremap $3 {}<esc>i
  85. inoremap $4 {<esc>o}<esc>O
  86. inoremap $q ''<esc>i
  87. inoremap $e ""<esc>i
  88. inoremap $t <><esc>i
  89. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  90. " => General abbreviations
  91. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  92. iab xdate <c-r>=strftime("%d/%m/%y %H:%M:%S")<cr>
  93. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  94. " => Omni complete functions
  95. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  96. autocmd FileType css set omnifunc=csscomplete#CompleteCSS
  97. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  98. " => Helper functions
  99. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  100. func! DeleteTillSlash()
  101. let g:cmd = getcmdline()
  102. if has("win16") || has("win32")
  103. let g:cmd_edited = substitute(g:cmd, "\\(.*\[\\\\]\\).*", "\\1", "")
  104. else
  105. let g:cmd_edited = substitute(g:cmd, "\\(.*\[/\]\\).*", "\\1", "")
  106. endif
  107. if g:cmd == g:cmd_edited
  108. if has("win16") || has("win32")
  109. let g:cmd_edited = substitute(g:cmd, "\\(.*\[\\\\\]\\).*\[\\\\\]", "\\1", "")
  110. else
  111. let g:cmd_edited = substitute(g:cmd, "\\(.*\[/\]\\).*/", "\\1", "")
  112. endif
  113. endif
  114. return g:cmd_edited
  115. endfunc
  116. func! CurrentFileDir(cmd)
  117. return a:cmd . " " . expand("%:p:h") . "/"
  118. endfunc