Advertisement
Guest User

VIMRC

a guest
Nov 3rd, 2018
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VIM 7.88 KB | None | 0 0
  1. let mapleader = " "
  2. set nocompatible
  3.  
  4. " allow backspacing over everything in insert mode
  5. set backspace=indent,eol,start
  6.  
  7. "Set smartcase
  8. set smartcase
  9.  
  10. "Don't redraw while executing macros
  11. set lazyredraw
  12.  
  13. "Add a bit extra margin to the left
  14. set foldcolumn=1
  15.  
  16. "Use spaces instead of tabs
  17. set expandtab
  18.  
  19. "Use smart tabs
  20. set smarttab
  21.  
  22. "Use tabstop to specify width of tab in columns
  23. set tabstop=4
  24.  
  25. "These two need linking for BS to work
  26.  
  27. "Use shiftwidth to make backspace delete a tab
  28. set shiftwidth=4
  29.  
  30. "Use softtabstop to specify whitespace of a tab
  31. set softtabstop=4
  32.  
  33. " do not keep a backup file, use versions instead
  34. set nobackup       
  35.  
  36. " keep a backup file (restore to previous version)
  37. set backup     
  38.  
  39. " keep an undo file (undo changes after closing)
  40. set undofile       
  41.  
  42. " keep 50 lines of command line history
  43. set history=700    
  44.  
  45. " show the cursor position all the time
  46. set ruler      
  47.  
  48. " do incremental searching
  49. set incsearch      
  50.  
  51. " Don't use Ex mode, use Q for formatting
  52. map Q gq
  53.  
  54. " CTRL-U in insert mode deletes a lot.  Use CTRL-G u to first break undo,
  55. " so that you can undo CTRL-U after inserting a line break.
  56. inoremap <C-U> <C-G>u<C-U>
  57.  
  58. " In many terminal emulators the mouse works just fine, thus enable it.
  59. if has('mouse')
  60.   set mouse=a
  61. endif"
  62.  
  63. " Switch syntax highlighting on, when the terminal has olors
  64. " Also switch on highlighting the last used search pattern.
  65. if &t_Co > 2 || has("gui_running")
  66.   syntax on
  67.   set hlsearch
  68. endif
  69.  
  70. " Only do this part when compiled with support for autocommands.
  71. if has("autocmd")
  72.  
  73.   " Enable file type detection.
  74.   " Use the default filetype settings, so that mail gets 'tw' set to 72,
  75.   " 'cindent' is on in C files, etc.
  76.   " Also load indent files, to automatically do language-dependent indenting.
  77.   filetype plugin indent on
  78.  
  79.   " Put these in an autocmd group, so that we can delete them easily.
  80.   augroup vimrcEx
  81.   au!
  82.  
  83.   " For all text files set 'textwidth' to 78 characters.
  84.   autocmd FileType text setlocal textwidth=78
  85.  
  86.   " When editing a file, always jump to the last known cursor position.
  87.   " Don't do it when the position is invalid or when inside an event handler
  88.   " (happens when dropping a file on gvim).
  89.   autocmd BufReadPost *
  90.     \ if line("'\"") >= 1 && line("'\"") <= line("$") |
  91.     \   exe "normal! g`\"" |
  92.     \ endif
  93.  
  94.   augroup END
  95.  
  96. else
  97.  
  98.   set autoindent        " always set autoindenting on
  99.  
  100. endif " has("autocmd")
  101.  
  102. " Convenient command to see the difference between the current buffer and the
  103. " file it was loaded from, thus the changes you made.
  104. " Only define it when not defined already.
  105. if !exists(":DiffOrig")
  106.   command DiffOrig vert new | set bt=nofile | r ++edit # | 0d_ | diffthis
  107.           \ | wincmd p | diffthis
  108. endif
  109.  
  110. if has('langmap') && exists('+langnoremap')
  111.   " Prevent that the langmap option applies to characters that result from a
  112.   " mapping.  If unset (default), this may break plugins (but it's backward
  113.   " compatible).
  114.   set langnoremap
  115. endif
  116.  
  117.  
  118. " The matchit plugin makes the % command work better, but it is not backwards
  119. " compatible.
  120. packadd matchit
  121.  
  122. "intgration with vundle"
  123. filetype off
  124.  
  125. set rtp+=~/.vim/bundle/Vundle.vim
  126.  
  127. call vundle#begin()
  128.  
  129. Plugin 'VundleVim/Vundle.vim'
  130.  
  131. Plugin 'Valloric/YouCompleteMe'
  132.  
  133. Plugin 'L9'
  134.  
  135. Plugin 'terryma/vim-multiple-cursors'
  136.  
  137. Plugin 'tpope/vim-surround'
  138.  
  139. Plugin 'vim-syntastic/syntastic'
  140.  
  141. Plugin 'francoiscabrol/ranger.vim'
  142.  
  143. Plugin 'mbbill/undotree'
  144.  
  145. Plugin 'tpope/vim-commentary'
  146.  
  147. Plugin 'easymotion/vim-easymotion'
  148.  
  149. Plugin 'Yggdroot/indentLine'
  150.  
  151. "Colorschemes and appearance
  152.  
  153. "Colorschemes and appearance
  154.  
  155. Plugin 'dracula/vim'
  156.  
  157. Plugin 'itchyny/lightline.vim'
  158.  
  159. Plugin 'rudrab/vim-coogle'
  160.  
  161. Plugin 'junegunn/limelight.vim'
  162.  
  163. Plugin 'junegunn/goyo.vim'
  164.  
  165. Plugin 'crusoexia/vim-monokai'
  166.  
  167. Plugin 'sfi0zy/atlantic-dark.vim'
  168.  
  169. Plugin 'szorfein/fromthehell.vim'
  170.  
  171. Plugin 'vim-scripts/inkpot'
  172.  
  173. "Plugin 'chriskempson/base16-vim'
  174.  
  175. call vundle#end()
  176.  
  177. filetype plugin indent on
  178.  
  179. set number
  180. set relativenumber
  181.  
  182. let g:lightline = {
  183.   \     'active': {
  184.   \         'left': [['mode', 'paste' ], ['readonly', 'filename', 'modified']],
  185.   \         'right': [['lineinfo'], ['percent'], ['fileformat', 'fileencoding']]
  186.   \     }
  187.   \ }
  188. set laststatus=2
  189. if !has('gui_running')
  190.       set t_Co=256
  191.   end
  192.  
  193. if has("patch-7.4.354")
  194.     " Indents word-wrapped lines as much as the 'parent' line
  195.     set breakindent
  196.         " Ensures word-wrap does not split words
  197.     set formatoptions=l
  198.     set lbr
  199. endif
  200.  
  201. "Turn on syntax and use x  as colorscheme for Vim
  202. syntax on
  203. colorscheme peachpuff
  204. set noshowmode
  205.  
  206. "Map <j> and <k> to their better alternatives <gj> and <gk>
  207. map j gj
  208. map k gk
  209.  
  210. "Map F7 to spellchecker
  211. map <F7> :setlocal spell! spelllang=en_us<CR>
  212.  
  213. "Ranger.vim mappings
  214. map <leader>f :Ranger<CR>
  215. let g:ranger_open_new_tab = 1
  216.  
  217. "show commands while you type
  218. set showcmd
  219.  
  220. "set f5 to look at undo tree.
  221. nnoremap <F5> :UndotreeToggle<cr>
  222.  
  223. "remap :W to avoid opening WordProcessor mode
  224. :command! W w
  225.  
  226. "remap :Q to quit
  227. :command! Q q
  228.  
  229. "Set nospell to leader key
  230. noremap <leader>n :noh<CR>
  231.  
  232. "Map jj in insert mode to Esc
  233. imap jj 
  234.  
  235. "Disable escape to learn habit
  236. imap <Esc> :echo "There's no Escape!"<CR>
  237. imap OD h
  238. imap OB j
  239. imap OA k
  240. imap OC l
  241.  
  242. "Map <C-H> and <C-L> to Home and End        
  243. let g:BASH_Ctrl_j = 'off'
  244. map!  0
  245. map! $
  246.  
  247. "Map <leader>j  to find the next placeholder and replace
  248. noremap <leader><leader> <Esc>/<++><CR>c4l
  249.  
  250. "Map <leader>s to reload $MYVIMRC
  251. nnoremap <leader>s :so $MYVIMRC <CR>
  252.  
  253. "Map <leader>w to write
  254. nnoremap <leader>w :w <CR>
  255.  
  256. "Map <leader>e to edit $MYVIMRC
  257. nnoremap <leader>e :tabedit $MYVIMRC <CR>
  258.  
  259. "Map <leader>p to run with python3
  260. nnoremap <leader>p :below term python3 %<CR>
  261.  
  262. "Map <leader>v to register paste
  263. nnoremap <leader>v "+p
  264.  
  265. "Allow saving of files as sudo
  266. cmap w!! w !sudo tee > /dev/null %
  267.  
  268. "Map leader enter to insert whitespace after cursor
  269. nnoremap <leader><CR> A<CR>
  270.  
  271. "Map leader backspace to insert whitespace before cursor
  272. nnoremap <leader><BS> I<CR>
  273.  
  274. "Map leader j to compile with javac
  275. nnoremap <leader>j :below term javac %<CR>
  276.  
  277. "Map leader qq to quit
  278. nnoremap <leader>qq :q!<CR>
  279.  
  280. "Map <F8> to show revision marks
  281. nmap <F8> :set list!<CR>
  282. set listchars=tab:⇒\ ,eol:¶,space:·
  283.  
  284. "Map <leader>t to prepend :tabdo
  285. nnoremap <leader>t :tabdo
  286.  
  287. " Motion for "next object". For example, "din(" would go to the next "()" pair
  288. " and delete its contents.
  289.  
  290. onoremap an :<c-u>call <SID>NextTextObject('a')<cr>
  291. xnoremap an :<c-u>call <SID>NextTextObject('a')<cr>
  292. onoremap in :<c-u>call <SID>NextTextObject('i')<cr>
  293. xnoremap in :<c-u>call <SID>NextTextObject('i')<cr>
  294.  
  295. function! s:NextTextObject(motion)
  296.   echo
  297.   let c = nr2char(getchar())
  298.   exe "normal! f".c."v".a:motion.c
  299. endfunction
  300.  
  301. " Automatically change cwd to the one that the current file is on
  302. autocmd BufEnter * silent! lcd %:p:h
  303.  
  304. " Open terminal
  305. nnoremap <leader>r :below terminal<CR>
  306.  
  307. "Map <leader>m to easymotion
  308. map <Leader>m <Plug>(easymotion-prefix)
  309.  
  310. " Bubble single lines
  311. nmap <C-K> ddkP
  312. nmap <C-J> ddp
  313.  
  314. " Bubble multiple lines
  315. vmap <C-K> xkP`[V`]
  316. vmap <C-J> xp`[V`]
  317.  
  318. "Auto-style for filetypes using astyle
  319. "autocmd BufNewFile,BufRead *.java set formatprg=/.vim/astyle/as-gcc-exe/astyle -A14 -T4pb
  320.  
  321. "let g:syntastic_java_checkers = ['syntastic-java-checkstyle']
  322. "let g:syntastic_aggregate_errors = 1
  323.  
  324.  
  325. "Change character for indent lines
  326. let g:indentLine_char = '▏'
  327. let g:indentLine_color_term = 239
  328.  
  329. "Use different cursor for each mode. Not available in  
  330. if empty($TMUX)
  331.   let &t_SI = "\<Esc>]50;CursorShape=1\x7"
  332.   let &t_EI = "\<Esc>]50;CursorShape=0\x7"
  333.   let &t_SR = "\<Esc>]50;CursorShape=2\x7"
  334. else
  335.   let &t_SI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=1\x7\<Esc>\\"
  336.   let &t_EI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=0\x7\<Esc>\\"
  337.   let &t_SR = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=2\x7\<Esc>\\"
  338. endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement