Advertisement
Guest User

vim-config

a guest
Aug 22nd, 2017
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VIM 9.07 KB | None | 0 0
  1. " Use space as leader key
  2. map <space> <leader>
  3. let mapleader = "\<space>"
  4. "
  5.  
  6. " Source the vimrc file after saving it
  7. augroup myvimrchooks
  8.     au!
  9.     autocmd bufwritepost .vimrc source ~/.vimrc
  10. augroup END
  11.  
  12. call plug#begin('~/.vim/plugged')
  13.  
  14. Plug 'bling/vim-airline'  " Command line at the bottom
  15. Plug 'chrisbra/colorizer' "h:Colorizer
  16. Plug 'christoomey/vim-sort-motion' "Sort paragraphs etc gs
  17. Plug 'christoomey/vim-system-copy' "Use cp to copy and cv to paste to the clipboard
  18. Plug 'christoomey/vim-titlecase' "Titlecase words with gt
  19. Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' } "FAST Fuzzy search
  20. Plug 'junegunn/fzf.vim'
  21. Plug 'junegunn/vim-easy-align' "Use ga to allign
  22. Plug 'lervag/vimtex'
  23. Plug 'tibabit/vim-templates' "Add templates in ~/templates
  24. Plug 'tpope/vim-commentary' " Comment out stuff with gc
  25. Plug 'tpope/vim-fugitive' " Git wrapper
  26. Plug 'tpope/vim-sensible' " backslash to delete, etc
  27. Plug 'tpope/vim-surround' " change surrounding parenthesis cs' or ys' for adding
  28. Plug 'vim-scripts/ReplaceWithRegister' "gr[motion]
  29.  
  30. " Colorscheme plugins
  31.  
  32. Plug 'vim-airline/vim-airline-themes' "Themes for airline
  33. Plug 'altercation/vim-colors-solarized'
  34. Plug 'tomasr/molokai'
  35.  
  36. call plug#end()
  37.  
  38. " Attempt to determine the type of a file based on its name and possibly its
  39. " contents. Use this to allow intelligent auto-indenting for each filetype,
  40. " and for plugins that are filetype specific.
  41. filetype indent plugin on
  42.  
  43. " Enable syntax highlighting
  44. syntax on
  45.  
  46. if &term == "screen"
  47.   set t_Co=256
  48. endif
  49.  
  50. set background=dark
  51. " let g:solarized_termcolors=256 "this is what fixed it for me
  52. " let g:solarized_termtrans = 1 "fixed the black bakground
  53. let g:airline_solarized_bg='dark'
  54. " let g:airline_left_sep='>'
  55. " let g:airline_right_sep='<'
  56. let g:airline_powerline_fonts = 1
  57. let g:Powerline_symbols='unicode'
  58. colorscheme solarized
  59.  
  60. " Plugin specific features
  61. augroup latexSurround
  62.     autocmd!
  63.     autocmd FileType tex call s:latexSurround()
  64. augroup END
  65.  
  66. function! s:latexSurround()
  67.     let b:surround_{char2nr("e")}
  68.            \ = "\\begin{\1environment: \1}\n\t\r\n\\end{\1\1}"
  69.     let b:surround_{char2nr("c")} = "\\\1command: \1{\r}"
  70. endfunction
  71.  
  72. command! -complete=custom,ListE -nargs=1 Ei execute "normal \<Esc>i\\begin{<args>}\<CR>\\end{<args>}<Esc>O<Space>" | startinsert
  73. function! ListE(A,L,P)
  74.   return "align*\nenumerate\nitemize\nfigure\ntabular\nbmatrix\npmatrix\ncases\n\ndocument\narray\nproof"
  75. endfunction
  76.  
  77. set wildcharm=<C-z> "Enables <C-z> to use autocomplete in commands
  78.  
  79. inoremap EE <Esc>diw:Ei <C-R>"<C-z><CR>
  80.  
  81. "------------------------------------------------------------
  82. " Features {{{1
  83. "
  84. " These options and commands enable some very useful features in Vim, that
  85. " no user should have to live without.
  86.  
  87. " Set 'nocompatible' to ward off unexpected things that your distro might
  88. " have made, as well as sanely reset options when re-sourcing .vimrc
  89. set nocompatible
  90.  
  91. " Attempt to determine the type of a file based on its name and possibly its
  92. " contents. Use this to allow intelligent auto-indenting for each filetype,
  93. " and for plugins that are filetype specific.
  94. filetype indent plugin on
  95.  
  96. " Enable syntax highlighting
  97. syntax on
  98.  
  99.  
  100. "------------------------------------------------------------
  101. " Must have options {{{1
  102. "
  103. " These are highly recommended options.
  104.  
  105. " Vim with default settings does not allow easy switching between multiple files
  106. " in the same editor window. Users can use multiple split windows or multiple
  107. " tab pages to edit multiple files, but it is still best to enable an option to
  108. " allow easier switching between files.
  109. "
  110. " One such option is the 'hidden' option, which allows you to re-use the same
  111. " window and switch from an unsaved buffer without saving it first. Also allows
  112. " you to keep an undo history for multiple files when re-using the same window
  113. " in this way. Note that using persistent undo also lets you undo in multiple
  114. " files even in the same window, but is less efficient and is actually designed
  115. " for keeping undo history after closing Vim entirely. Vim will complain if you
  116. " try to quit without saving, and swap files will keep you safe if your computer
  117. " crashes.
  118. set hidden
  119.  
  120. " Note that not everyone likes working this way (with the hidden option).
  121. " Alternatives include using tabs or split windows instead of re-using the same
  122. " window as mentioned above, and/or either of the following options:
  123. " set confirm
  124. " set autowriteall
  125.  
  126. " Better command-line completion
  127. set wildmenu
  128.  
  129. " Show partial commands in the last line of the screen
  130. set showcmd
  131.  
  132. " Highlight searches (use <C-L> to temporarily turn off highlighting; see the
  133. " mapping of <C-L> below)
  134. set hlsearch
  135.  
  136. " Modelines have historically been a source of security vulnerabilities. As
  137. " such, it may be a good idea to disable them and use the securemodelines
  138. " script, <http://www.vim.org/scripts/script.php?script_id=1876>.
  139. " set nomodeline
  140.  
  141.  
  142. "------------------------------------------------------------
  143. " Usability options {{{1
  144. "
  145. " These are options that users frequently set in their .vimrc. Some of them
  146. " change Vim's behaviour in ways which deviate from the true Vi way, but
  147. " which are considered to add usability. Which, if any, of these options to
  148. " use is very much a personal preference, but they are harmless.
  149.  
  150. " Use case insensitive search, except when using capital letters
  151. set ignorecase
  152. set smartcase
  153.  
  154. " Allow backspacing over autoindent, line breaks and start of insert action
  155. set backspace=indent,eol,start
  156.  
  157. " When opening a new line and no filetype-specific indenting is enabled, keep
  158. " the same indent as the line you're currently on. Useful for READMEs, etc.
  159. set autoindent
  160.  
  161. " Stop certain movements from always going to the first character of a line.
  162. " While this behaviour deviates from that of Vi, it does what most users
  163. " coming from other editors would expect.
  164. set nostartofline
  165.  
  166. " Display the cursor position on the last line of the screen or in the status
  167. " line of a window
  168. set ruler
  169.  
  170. " Always display the status line, even if only one window is displayed
  171. set laststatus=2
  172.  
  173. " Instead of failing a command because of unsaved changes, instead raise a
  174. " dialogue asking if you wish to save changed files.
  175. set confirm
  176.  
  177. " Use visual bell instead of beeping when doing something wrong
  178. set visualbell
  179.  
  180. " And reset the terminal code for the visual bell. If visualbell is set, and
  181. " this line is also included, vim will neither flash nor beep. If visualbell
  182. " is unset, this does nothing.
  183. set t_vb=
  184.  
  185. " Enable use of the mouse for all modes
  186. set mouse=r
  187.  
  188. " Set the command window height to 2 lines, to avoid many cases of having to
  189. " "press <Enter> to continue"
  190. set cmdheight=2
  191.  
  192. " Display line numbers on the left
  193. set relativenumber
  194. set number
  195.  
  196. " Quickly time out on keycodes, but never time out on mappings
  197. set notimeout ttimeout ttimeoutlen=200
  198.  
  199. " Use <F11> to toggle between 'paste' and 'nopaste'
  200. set pastetoggle=<F11>
  201.  
  202.  
  203. "------------------------------------------------------------
  204. " Indentation options {{{1
  205. "
  206. " Indentation settings according to personal preference.
  207.  
  208. " Indentation settings for using 4 spaces instead of tabs.
  209. " Do not change 'tabstop' from its default value of 8 with this setup.
  210. set shiftwidth=4
  211. set softtabstop=4
  212. set expandtab
  213.  
  214. " Indentation settings for using hard tabs for indent. Display tabs as
  215. " four characters wide.
  216. "set shiftwidth=4
  217. "set tabstop=4
  218.  
  219.  
  220. "------------------------------------------------------------
  221. " Mappings {{{1
  222.  
  223.  
  224.  
  225. " Disable some mappings
  226. noremap  <f1>   <nop>
  227. inoremap <f1>   <nop>
  228. nnoremap Q      <nop>
  229.  
  230. " Some general/standard remappings
  231. nnoremap Y      y$
  232. nnoremap <expr> j v:count ? 'j' : 'gj'
  233. nnoremap <expr> k v:count ? 'k' : 'gk'
  234. nnoremap <leader>w :update<cr>
  235. inoremap jk <esc>
  236. inoremap AA <C-o>A
  237. inoremap II <C-o>I
  238. inoremap CL <C-o>c$
  239. inoremap CC <C-o>cc
  240. set wildcharm=<C-z> "Enables <C-z> to use autocomplete in commands
  241.  
  242. "This unsets the "last search pattern" register by hitting return
  243. nnoremap <CR> :noh<CR>
  244.  
  245. " ==========================================
  246. "      Plugins keybindings
  247. " ==========================================
  248.  
  249. " Start interactive EasyAlign in visual mode (e.g. vipga)
  250. xmap ga <Plug>(EasyAlign)
  251. xmap gA <Plug>(EasyAlign)
  252.  
  253. " Start interactive EasyAlign for a motion/text object (e.g. gaip)
  254. nmap ga <Plug>(EasyAlign)
  255. nmap gA <Plug>(EasyAlign)
  256.  
  257. nnoremap cV mq"+p`qJ
  258.  
  259. nmap <C-b> :w<CR>:args /home/oistes/maal.md *.md \| argdo tabe <CR>:tabclose<CR>:tabp<CR>/OPPGAVENAVN.html<CR>:noh<CR>:put=expand('%:p:h')<CR>$T/hd00y$i..<Esc>$pA.html<Esc>ddk0f/gri(2gg<leader>f
  260.  
  261. nmap <leader>v :tabedit $MYVIMRC<CR> "Opens .vimrc
  262.  
  263. nmap <leader>m :tabedit /home/oistes/maal.md<CR>
  264.  
  265. " Gets the current file directory and capitalizes it
  266. nmap <leader>f ititle<C-x><C-l><Esc>T:i Lærerveiledning -<Esc>0olevel<C-x><C-l><Esc>0olang<C-x><C-l><Esc>
  267.  
  268. " Inserts kompetansemål by tag
  269. inoremap <C-f> <C-x><C-l><Esc> k0diw
  270.  
  271. " Pastes the path of the file twice
  272. nnoremap <leader>n :let @" = expand('%:p:h:t')<CR>:%s/OPPGAVENAVN/\=@"/g<CR>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement