Advertisement
Guest User

Untitled

a guest
Jun 28th, 2018
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VIM 7.68 KB | None | 0 0
  1.  
  2. """""""""""""""""""""""""""""""""""""""""
  3. " - Functional
  4. """"""""""""""""""""""""""""""""""""""""""
  5.  
  6. set nocompatible             " leave the 1980s
  7. syntax enable                " syntax highlighting
  8. set path+=**                 " recursively search sub-dirs
  9. set expandtab                " tabs to spaces
  10. set shiftwidth=4             " 4 spaces per tab
  11. set tabstop=4                " tabs in file use 4 spaces
  12. set mouse=a                  " mouse usable in all modes
  13. set autoread                 " auto read file when changed while open
  14. set history=1000             " command history
  15. set hidden                   " allows switching between unsaved buffers
  16. set scrolloff=10             " set 10 lines to the edge of screen
  17. set sidescrolloff=5
  18. set visualbell               " visual cue instead of audio on error
  19. set report=0                 " show all substitutions
  20.  
  21.  
  22.  
  23. """""""""""""""""""""""""""""""""""""""""
  24. " - Swaps, Backups, Undo
  25. """"""""""""""""""""""""""""""""""""""""""
  26.  
  27. " no backups
  28. set nobackup
  29.  
  30. " setup swap
  31. if !isdirectory($HOME."/.vim/swap")
  32.     call mkdir($HOME."/.vim/swap", "p")
  33. endif
  34.  
  35. " // after each means files will have full paths (seperator subbed for %)
  36. set directory=~/.vim/swap//
  37.  
  38.  
  39. " setup persistent undos
  40. if has("persistent_undo")
  41.     if !isdirectory($HOME."/.vim/undo")
  42.         call mkdir($HOME."/.vim/undo", "p")
  43.     endif
  44.     set undodir=~/.vim/undodir//
  45.     set undofile
  46. endif
  47.  
  48.  
  49.  
  50. """""""""""""""""""""""""""""""""""""""""
  51. " - Visual
  52. """"""""""""""""""""""""""""""""""""""""""
  53.  
  54. set showmatch                       " show matching brackets
  55. set mat=2                           " tenths of a second to blink on bracket
  56. set cursorline                      " highlight current line
  57. set showcmd                         " show incomplete commands
  58. set number                          " show line numbers
  59. set relativenumber                  " show relative to current line
  60. set numberwidth=5                   " wider number column (to cater for gitgutter)
  61. set showbreak="+++"                 " long line wrap delimiter
  62. set autoindent                      " match indentation of prev line
  63. set smartindent                     " dependent on filetype
  64. set ruler                           " show (line, col) at bottom
  65.  
  66. " visual menu for auto-complete
  67. set wildmenu
  68. set wildignore=*.o,*.obj,*.bak,*.sw*,*.pyc,*.class
  69.  
  70. " better splits
  71. set splitbelow
  72. set splitright
  73. set equalalways
  74.  
  75. set lazyredraw                       " only redraw window after macro is finished (performance)
  76.  
  77. " line break next word after 150 chars
  78. set linebreak
  79. set textwidth=150
  80.  
  81. " Colours
  82. set t_CO=256
  83.  
  84. if !isdirectory($HOME."/.vim/colors")
  85.     call mkdir($HOME."/.vim/colors", "p")
  86. endif
  87.  
  88. try
  89.     colorscheme atom-dark-256
  90. catch
  91.     colorscheme desert
  92. endtry
  93.  
  94.  
  95.  
  96. """""""""""""""""""""""""""""""""""""""""
  97. " - Search
  98. """"""""""""""""""""""""""""""""""""""""""
  99.  
  100. set incsearch                       " incremental search
  101. set hlsearch                        " highlight all matches
  102. set ignorecase                      " ignore case on search..
  103. set smartcase                       " ..but case sensitive if one letter is upper case
  104. set laststatus=2                    " always status bar
  105. set backspace=indent,eol,start      " make backspace behave normally
  106.  
  107. let g:netrw_list_hide =  '^\.[^\.],'
  108. let g:netrw_list_hide .= '\.pyc$,'
  109. let g:netrw_list_hide .= '\.class$,'
  110.  
  111.  
  112.  
  113. """""""""""""""""""""""""""""""""""""""""
  114. " - Status Line
  115. """"""""""""""""""""""""""""""""""""""""""
  116.  
  117. " Override default to blank
  118. set statusline=
  119.  
  120. set statusline+=%2*\ %f\ %m\ %r%*                   " Show filename/path
  121. set statusline+=%3*%=%*                             " Set right-side status info after this line
  122. set statusline+=%4*%l/%L:%v%*                       " Set <line number>/<total
  123. set statusline+=%5*\ %*                             " Set ending space
  124.  
  125. set shm=atI                                         " Cut long messages
  126.  
  127.  
  128.  
  129. """""""""""""""""""""""""""""""""""""""""
  130. " - Key Mappings
  131. """"""""""""""""""""""""""""""""""""""""""
  132.  
  133. " easier exit from insert
  134. imap jk <Esc>
  135.  
  136. " yank to end of line
  137. nnoremap Y y$
  138.  
  139. " too common a mistake [:W == :w]
  140. command! W w
  141.  
  142. " fix page up and down
  143. map <PageUp> <C-U>
  144. map <PageDown> <C-D>
  145.  
  146. " for navigating wrapped lines
  147. nmap j gj
  148. nmap k gk
  149.  
  150. " easier start/end of line
  151. nnoremap H ^
  152. nnoremap L $
  153.  
  154. " autocomplete menu navigation
  155. imap <C-J> <C-N>
  156. imap <C-K> <C-P>
  157.  
  158. " netrw
  159. nmap - :Explore<CR>
  160.  
  161. " Default leader is \, but space is better
  162. nnoremap <SPACE> <Nop>
  163. let mapleader=' '
  164.  
  165. " un-highlight searches
  166. nmap <Leader><Leader> :nohlsearch<cr>
  167.  
  168. " paste from system clipboard
  169. nmap <Leader>p "+p
  170.  
  171. " quick edit config files
  172. nmap <Leader>ev :e $MYVIMRC<cr>
  173. nmap <Leader>ep :e $HOME/.vim/plugins.vim<cr>
  174.  
  175. " save as sudo if read-only
  176. noremap <leader>w  :w !sudo tee % > /dev/null
  177.  
  178. " buffers
  179. nnoremap <silent> <Leader>h :bp<CR>
  180. nnoremap <Leader>l :bn<CR>
  181. " close current buffer
  182. nmap <Leader>q :bp <BAR> bd #<CR>
  183. " list all open buffers, waiting for input to change
  184. nnoremap <leader>b :ls<CR> :b<space>
  185.  
  186. " tabs
  187. nmap <Leader>t :tab new<CR>
  188. nmap <Leader>c :tab close<CR>
  189.  
  190. " create splits
  191. nmap <Leader>s :split<cr>
  192. nmap <Leader>v :vsplit<cr>
  193.  
  194. " easier split navigation
  195. nmap <C-H> <C-W>h
  196. nmap <C-L> <C-W>l
  197. nmap <C-J> <C-W>j
  198. nmap <C-K> <C-W>k
  199.  
  200. " resize splits with Alt+<ARROW>
  201. nmap <silent> <A-Up> <C-W>+
  202. nmap <silent> <A-Down> <C-w>-
  203. nmap <silent> <A-Left> <C-w><
  204. nmap <silent> <A-Right> <C-w>>
  205.  
  206. " indenting in visual mode, go back to visual mode on same selection
  207. vnoremap > >gv
  208.  
  209. " easy visual mode macros
  210. vmap @ :normal @
  211.  
  212.  
  213. """""""""""""""""""""""""""""""""""""""""
  214. " - Auto-Commands
  215. """"""""""""""""""""""""""""""""""""""""""
  216.  
  217. " auto source Vimrc and reload airline on save
  218. augroup autosourcing
  219.     autocmd!
  220.     autocmd BufWritePost $MYVIMRC source $MYVIMRC
  221. augroup END
  222.  
  223.  
  224. " Return to last edit position when opening files
  225. autocmd BufReadPost *
  226.     \ if line("'\"") > 0 && line("'\"") <= line("$") |
  227.     \   exe "normal! g`\"" |
  228.     \ endif
  229. "Remember info about open buffers on close
  230. set viminfo^=%
  231.  
  232. " Remove trailing whitespace on save
  233. autocmd BufWritePre * :%s/\s\+$//e
  234. " Extension of basic.vim
  235.  
  236.  
  237. " indent overrides for certain filetypes
  238. " [ts: file tab size, sts: edit tab size, sw: >> indent size]
  239.  
  240. au BufNewFile,BufRead *.js,*.html,*.css :
  241.     \ set tabstop=2 |
  242.     \ set softtabstop=2 |
  243.     \ set shiftwidth=2 |
  244.  
  245. au BufNewFile,BufRead *.py :
  246.     \ set tabstop=4 |
  247.     \ set softtabstop=4 |
  248.     \ set shiftwidth=4 |
  249.     \ set textwidth=79 |
  250.     \ set expandtab |
  251.     \ set autoindent |
  252.     \ set fileformat=unix |
  253.  
  254. "------PLUGINS------"
  255. filetype off                " required
  256.  
  257. set rtp+=~/.vim/bundle/Vundle.vim
  258. call vundle#begin()
  259.  
  260. Plugin 'VundleVim/Vundle.vim'
  261.  
  262. Plugin 'tpope/vim-vinegar'
  263. Plugin 'tpope/vim-surround'
  264. Plugin 'tpope/vim-commentary'
  265. Plugin 'vim-syntastic/syntastic'
  266. Plugin 'airblade/vim-gitgutter'
  267. Plugin 'sheerun/vim-polyglot'
  268. Plugin 'vimwiki/vimwiki'
  269. Plugin 'simnalamburt/vim-mundo'
  270. Plugin 'jiangmiao/auto-pairs'
  271. Plugin 'vim-airline/vim-airline'
  272. Plugin 'vim-airline/vim-airline-themes'
  273.  
  274. call vundle#end()            " required
  275. filetype plugin indent on    " required
  276.  
  277.  
  278. "------PLUGIN-OPTIONS------
  279.  
  280. let NERDTreeHijackNetrw=0
  281.  
  282. " work up to .git for working directory
  283. let g:ctrlp_working_path_mode = 'ra'
  284. let g:ctrlp_custom_ignore = '\/(node_modules)'
  285.  
  286. let g:syntastic_python_checkers = ["flake8", "python"]
  287.  
  288. " powerline on airline
  289. let g:airline_powerline_fonts = 1
  290. " enable buffer list top
  291. let g:airline#extensions#tabline#enabled = 1
  292. " show only filename
  293. let g:airline#extensions#tabline#fnamemod = ':t'
  294.  
  295.  
  296. "------KEY-MAPPINGS-------
  297. nnoremap <C-U> :MundoToggle<CR>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement