Advertisement
Guest User

Untitled

a guest
Jan 13th, 2017
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.02 KB | None | 0 0
  1. " Leader
  2. let mapleader = " "
  3.  
  4. set nocompatible
  5. set nocp
  6.  
  7. execute pathogen#infect()
  8.  
  9. set backspace=2 " Backspace deletes like most programs in insert mode
  10. set nobackup
  11. set nowritebackup
  12. set noswapfile " http://robots.thoughtbot.com/post/18739402579/global-gitignore#comment-458413287
  13. set history=50
  14. set ruler " show the cursor position all the time
  15. set showcmd " display incomplete commands
  16. set incsearch " do incremental searching
  17. set laststatus=2 " Always display the status line
  18. set autowrite " Automatically :write before running commands
  19.  
  20. syntax enable
  21. syntax on
  22.  
  23. let g:neocomplete#enable_at_startup = 1
  24.  
  25. " fzf
  26. " see: https://github.com/junegunn/fzf.vim
  27. set rtp+=/usr/local/opt/fzf
  28. set rtp+=~/.fzf
  29.  
  30. " Disable Arrow keys in Normal mode
  31. noremap <up> <nop>
  32. noremap <down> <nop>
  33. noremap <left> <nop>
  34. noremap <right> <nop>
  35.  
  36. nnoremap <Left> :echoe "Use h"<nop>
  37. nnoremap <Right> :echoe "Use l"<nop>
  38. nnoremap <Up> :echoe "Use k"<nop>
  39. nnoremap <Down> :echoe "Use j"<nop>
  40.  
  41. " Quicker window movement
  42. nnoremap <C-j> <C-w>j
  43. nnoremap <C-k> <C-w>k
  44. nnoremap <C-h> <C-w>h
  45. nnoremap <C-l> <C-w>l
  46.  
  47. " shift-h = beginning of line
  48. noremap H ^
  49. " shift-l = end of line
  50. noremap L g_
  51. " shift-j = down 5 lines
  52. noremap J 5j
  53. " shift-k = up 5 lines
  54. noremap K 5k
  55. " this is the best, let me tell you why
  56. " how annoying is that everytime you want to do something in vim
  57. " you have to do shift-; to get :, can't we just do ;?
  58. " Plus what does ; do anyways??
  59. " if you do have a plugin that needs ;, you can just wap the mapping
  60. " nnoremap : ;
  61. " give it a try and you will like it
  62. nnoremap ; :
  63. " file-path completion
  64. inoremap <c-f> <c-x><c-f>
  65. "Copy to OSX clipboard
  66. vnoremap <C-c> "*y<CR>
  67. " Align blocks of text and keep them selected
  68. vmap < <gv
  69. vmap > >gv
  70. " Toggle tcomment
  71. vnoremap <c-/> :TComment<cr>
  72. " Clears search history in buffer
  73. map <esc> :noh<cr>
  74. " Toggle NERDTree
  75. map <C-t> :NERDTreeToggle<CR>
  76. let NERDTreeShowHidden=1
  77. " no need to fold things in markdown all the time
  78. let g:vim_markdown_folding_disabled = 1
  79. " turn on spelling for markdown files
  80. autocmd BufRead,BufNewFile *.md setlocal spell complete+=kspell
  81.  
  82. " Multi-Cursors keybindings
  83. " see: https://github.com/terryma/vim-multiple-cursors
  84. let g:multi_cursor_next_key='<C-n>'
  85. let g:multi_cursor_prev_key='<C-p>'
  86. let g:multi_cursor_skip_key='<C-x>'
  87. let g:multi_cursor_quit_key='<Esc>'
  88.  
  89. " Set background and color scheme
  90. " See https://github.com/chrishunt/color-schemes
  91. set background=dark
  92. colorscheme base16-railscasts
  93. let base16colorspace=256 " Access colors present in 256 colorspace
  94.  
  95. highlight clear SignColumn
  96. highlight VertSplit ctermbg=236
  97. highlight ColorColumn ctermbg=237
  98. highlight LineNr ctermbg=236 ctermfg=240
  99. highlight CursorLineNr ctermbg=236 ctermfg=240
  100. highlight CursorLine ctermbg=236
  101. highlight StatusLineNC ctermbg=238 ctermfg=0
  102. highlight StatusLine ctermbg=240 ctermfg=12
  103. highlight IncSearch ctermbg=3 ctermfg=1
  104. highlight Search ctermbg=1 ctermfg=3
  105. highlight Visual ctermbg=3 ctermfg=0
  106. highlight Pmenu ctermbg=240 ctermfg=12
  107. highlight PmenuSel ctermbg=3 ctermfg=1
  108. highlight SpellBad ctermbg=0 ctermfg=1
  109.  
  110. " Switch syntax highlighting on, when the terminal has colors
  111. " Also switch on highlighting the last used search pattern.
  112. if (&t_Co > 2 || has("gui_running")) && !exists("syntax_on")
  113. syntax on
  114. endif
  115.  
  116. if filereadable(expand("~/.vimrc.bundles"))
  117. source ~/.vimrc.bundles
  118. endif
  119.  
  120. " Load matchit.vim, but only if the user hasn't installed a newer version.
  121. if !exists('g:loaded_matchit') && findfile('plugin/matchit.vim', &rtp) ==# ''
  122. runtime! macros/matchit.vim
  123. endif
  124.  
  125. filetype plugin indent on
  126.  
  127. augroup vimrcEx
  128. autocmd!
  129.  
  130. " When editing a file, always jump to the last known cursor position.
  131. " Don't do it for commit messages, when the position is invalid, or when
  132. " inside an event handler (happens when dropping a file on gvim).
  133. autocmd BufReadPost *
  134. \ if &ft != 'gitcommit' && line("'\"") > 0 && line("'\"") <= line("$") |
  135. \ exe "normal g`\"" |
  136. \ endif
  137.  
  138. " Set syntax highlighting for specific file types
  139. autocmd BufRead,BufNewFile Appraisals set filetype=ruby
  140. autocmd BufRead,BufNewFile *.md set filetype=markdown
  141. autocmd BufRead,BufNewFile .{jscs,jshint,eslint}rc set filetype=json
  142. augroup END
  143.  
  144. " When the type of shell script is /bin/sh, assume a POSIX-compatible
  145. " shell for syntax highlighting purposes.
  146. let g:is_posix = 1
  147.  
  148. " Softtabs, 2 spaces
  149. set tabstop=2
  150. set shiftwidth=2
  151. set shiftround
  152. set expandtab
  153.  
  154. " Display extra whitespace
  155. set list listchars=tab:»·,trail:·,nbsp:·
  156.  
  157. " Use one space, not two, after punctuation.
  158. set nojoinspaces
  159.  
  160. " Use The Silver Searcher https://github.com/ggreer/the_silver_searcher
  161. if executable('ag')
  162. " Use Ag over Grep
  163. set grepprg=ag\ --nogroup\ --nocolor
  164.  
  165. " Use ag in CtrlP for listing files. Lightning fast and respects .gitignore
  166. let g:ctrlp_user_command = 'ag -Q -l --nocolor --hidden -g "" %s'
  167.  
  168. " ag is fast enough that CtrlP doesn't need to cache
  169. let g:ctrlp_use_caching = 0
  170.  
  171. if !exists(":Ag")
  172. command -nargs=+ -complete=file -bar Ag silent! grep! <args>|cwindow|redraw!
  173. nnoremap \ :Ag<SPACE>
  174. endif
  175. endif
  176.  
  177. " Make it obvious where 80 characters is
  178. set textwidth=80
  179. set colorcolumn=+1
  180.  
  181. " Numbers
  182. set number
  183.  
  184. set numberwidth=5
  185.  
  186. " Tab completion
  187. " will insert tab at beginning of line,
  188. " will use completion if not at beginning
  189. set wildmode=list:longest,list:full
  190. function! InsertTabWrapper()
  191. let col = col('.') - 1
  192. if !col || getline('.')[col - 1] !~ '\k'
  193. return "\<tab>"
  194. else
  195. return "\<c-p>"
  196. endif
  197. endfunction
  198. inoremap <Tab> <c-r>=InsertTabWrapper()<cr>
  199. inoremap <S-Tab> <c-n>
  200.  
  201. " Switch between the last two files
  202. nnoremap <leader><leader> <c-^>
  203.  
  204. " vim-test mappings
  205. nnoremap <silent> <Leader>t :TestFile<CR>
  206. nnoremap <silent> <Leader>s :TestNearest<CR>
  207. nnoremap <silent> <Leader>l :TestLast<CR>
  208. nnoremap <silent> <Leader>a :TestSuite<CR>
  209. nnoremap <silent> <leader>gt :TestVisit<CR>
  210.  
  211. " Run commands that require an interactive shell
  212. nnoremap <Leader>r :RunInInteractiveShell<space>
  213.  
  214. " Treat <li> and <p> tags like the block tags they are
  215. let g:html_indent_tags = 'li\|p'
  216.  
  217. " Open new split panes to right and bottom, which feels more natural
  218. set splitbelow
  219. set splitright
  220.  
  221. " configure syntastic syntax checking to check on open as well as save
  222. let g:syntastic_check_on_open=1
  223. let g:syntastic_html_tidy_ignore_errors=[" proprietary attribute \"ng-"]
  224. let g:syntastic_eruby_ruby_quiet_messages =
  225. \ {"regex": "possibly useless use of a variable in void context"}
  226.  
  227. " Set spellfile to location that is guaranteed to exist, can be symlinked to
  228. " Dropbox or kept in Git and managed outside of thoughtbot/dotfiles using rcm.
  229. set spellfile=$HOME/.vim-spell-en.utf-8.add
  230.  
  231. " Autocomplete with dictionary words when spell check is on
  232. set complete+=kspell
  233.  
  234. " Always use vertical diffs
  235. set diffopt+=vertical
  236.  
  237. " Local config
  238. if filereadable($HOME . "/.vimrc.local")
  239. source ~/.vimrc.local
  240. endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement