Advertisement
Guest User

vimrc

a guest
Oct 26th, 2015
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VIM 6.60 KB | None | 0 0
  1. set nocompatible
  2. set ttyfast
  3.  
  4. let mapleader = " "
  5. noremap ; :
  6.  
  7. if (&t_Co > 2 || has("gui_running")) && !exists("syntax_on")
  8.   syntax on
  9.   set hlsearch
  10. endif
  11.  
  12. call plug#begin('~/.vim/bundle')
  13. " Statusline and colors
  14. Plug 'nanotech/jellybeans.vim'
  15. " Ruby && RoR
  16. Plug 'tpope/vim-rails'
  17. Plug 'tpope/vim-bundler'
  18. Plug 'tpope/vim-endwise'
  19. Plug 'vim-ruby/vim-ruby'
  20. Plug 'skalnik/vim-vroom'
  21. Plug 'thoughtbot/vim-rspec'
  22. " Elixir
  23. Plug 'elixir-lang/vim-elixir'
  24. Plug 'mattreduce/vim-mix'
  25. " JS
  26. Plug 'kchmck/vim-coffee-script'
  27. Plug 'pangloss/vim-javascript'
  28. Plug 'mxw/vim-jsx'
  29. " Editing utils
  30. Plug 'skwp/greplace.vim'
  31. Plug 'pbrisbin/vim-mkdir'
  32. Plug 'tpope/vim-surround'
  33. Plug 'tpope/vim-commentary'
  34. Plug 'junegunn/vim-easy-align'
  35. Plug 'scrooloose/syntastic'
  36. Plug 'tpope/vim-fugitive'
  37. " Fuzzy finder
  38. Plug 'ctrlpvim/ctrlp.vim'
  39. " Shell interaction
  40. Plug 'christoomey/vim-tmux-navigator'
  41. Plug 'tpope/vim-dispatch'
  42. Plug 'tpope/vim-eunuch'
  43. call plug#end()
  44.  
  45. runtime! macros/matchit.vim
  46.  
  47. filetype plugin indent on
  48.  
  49. " use the silver searcher https://github.com/ggreer/the_silver_searcher
  50. if executable('ag')
  51.   set grepprg=ag\ --nogroup\ --nocolor
  52.  
  53.   let g:ctrlp_user_command = 'ag %s -l --nocolor -U -g ""'
  54.   let g:ctrlp_match_window = 'bottom,order:ttb'
  55.   let g:ctrlp_use_caching = 0
  56. endif
  57.  
  58.  
  59. set nobackup
  60. set nowritebackup
  61. set noswapfile
  62. set backspace=2
  63. set history=50
  64. set ruler
  65. set ttimeout
  66. set ttimeoutlen=100
  67. :let @/ = ""
  68. set ignorecase
  69. set gdefault
  70. set smartcase
  71. set incsearch
  72. set laststatus=2
  73. set hidden
  74. set lazyredraw
  75. set clipboard=unnamed
  76. set autoread
  77. :set mouse=a
  78. set tabstop=2
  79. set shiftwidth=2
  80. set shiftround
  81. set expandtab
  82. set nofoldenable
  83. set fdm=marker
  84. set textwidth=80
  85. set colorcolumn=+1
  86. set number numberwidth=5
  87. set linespace=2
  88. set display+=lastline
  89. set list
  90. set listchars=tab:»·,trail:·,nbsp:·
  91. set splitbelow splitright
  92. set winheight=10
  93. set winminheight=10
  94. set winwidth=90
  95. set winheight=999
  96. set diffopt+=vertical
  97. set nocursorcolumn
  98. set nocursorline
  99. set formatoptions-=or
  100. set wildmenu
  101. set wildmode=list:longest,list:full
  102. set wildignore=*.swp,*.bak,*.pyc,*.class,*.jar,*.gif,*.png,*.jpg,
  103.       \**/.git/*,**/.bundle/*,**/bin/*,**/.svn/*,**/tmp/*
  104. set pastetoggle=<F9>
  105.  
  106. set t_Co=256
  107. set background=dark
  108. colorscheme jellybeans
  109.  
  110. let g:javascript_enable_domhtmlcss = 1
  111.  
  112. let g:jsx_ext_required = 0
  113.  
  114. let g:mta_filetypes = {
  115.     \ 'html' : 1,
  116.     \ 'xhtml' : 1,
  117.     \ 'xml' : 1,
  118.     \ 'jinja' : 1,
  119.     \ 'jsx' : 1,
  120.     \ 'javascript' : 1,
  121.     \ 'javascript.jsx' : 1,
  122.     \ 'eruby' : 1,
  123.     \}
  124.  
  125. let g:vroom_use_colors = 1
  126. let g:vroom_map_keys = 0
  127. let g:vroom_clear_screen = 1
  128. let g:vroom_write_all = 1
  129.  
  130. " Switch between the last two files
  131. nnoremap <leader><leader> <c-^>
  132. " Normal moving through long wrapped lines
  133. nnoremap <nowait> j gj
  134. nnoremap <nowait> k gk
  135. " Quicker window movement (exclude 'w' from mappings)
  136. nnoremap <C-j> <C-w>j
  137. nnoremap <C-k> <C-w>k
  138. nnoremap <C-h> <C-w>h
  139. nnoremap <C-l> <C-w>l
  140. " Get off my lawn
  141. nnoremap <Left> :echoe "Use h"<CR>
  142. nnoremap <Right> :echoe "Use l"<CR>
  143. nnoremap <Up> :echoe "Use k"<CR>
  144. nnoremap <Down> :echoe "Use j"<CR>
  145. " Don't need to escape chars when searching
  146. nnoremap / /\v
  147. vnoremap / /\v
  148. " Start interactive EasyAlign in visual mode (e.g. vip<Enter>)
  149. vmap <Enter> <Plug>(EasyAlign)
  150. " Start interactive EasyAlign for a motion/text object (e.g. gaip)
  151. nmap ga <Plug>(EasyAlign)
  152. " Toggle NERDTree
  153. noremap <Leader>m :Lexplore<CR>
  154. " Rspec-vim mappings
  155. map <Leader>rc :call RunCurrentSpecFile()<CR>
  156. map <Leader>rs :call RunNearestSpec()<CR>
  157. map <Leader>rl :call RunLastSpec()<CR>
  158. " Vroom (minitest) mappings
  159. " map <Leader>mc :VroomRunTestFile<CR>
  160. " map <Leader>ms :VroomRunNearestTest<CR>
  161. " map <Leader>ml :VroomRunLastTest<CR>
  162. " Use leader + T for ctrlp
  163. nnoremap <Leader>t :CtrlP<CR>
  164. " remap vim conf file sourcing to <leader>so
  165. nnoremap <Leader>so :source ~/.vimrc<CR> :echom ".vimrc reloaded."<CR>
  166. " Clear last search highlights
  167. nnoremap <Leader><CR> :nohlsearch<CR>
  168. " Bind Q to q
  169. command! Q q
  170. " Move to beginning/end of the line
  171. nnoremap <Leader>B ^
  172. nnoremap <Leader>E $
  173. " Select all
  174. map <Leader>sa ggVG
  175. " Duplicate selected content - thanks to Joe Ferris
  176. vmap D y'>p
  177. " Autocomplete on <TAB>
  178. imap <Tab> <C-P>
  179. " automatically rebalance windows on vim resize
  180. autocmd VimResized * wincmd =
  181. " zoom a vim pane, <C-w>= to re-balance
  182. nnoremap <leader>- :wincmd _<cr>:wincmd \|<cr>
  183. nnoremap <leader>= :wincmd =<cr>
  184.  
  185. " will insert tab at beginning of line and use completion if not at beginning
  186. function! InsertTabWrapper()
  187.    let col = col('.') - 1
  188.    if !col || getline('.')[col - 1] !~ '\k'
  189.        return "\<tab>"
  190.    else
  191.        return "\<c-p>"
  192.    endif
  193. endfunction
  194. inoremap <Tab> <c-r>=InsertTabWrapper()<cr>
  195. inoremap <S-Tab> <c-n>
  196.  
  197. " Some Ruby settings - thanks to r00k
  198. augroup myfiletypes
  199.  autocmd!
  200.  " autoindent with two spaces and always expand tabs
  201.  autocmd FileType ruby,eruby,yaml setlocal ai sw=2 sts=2 et
  202.  autocmd FileType ruby,eruby,yaml setlocal path+=lib
  203.  " make question marks part of words
  204.  autocmd FileType ruby,eruby,yaml setlocal iskeyword+=?
  205. augroup END
  206.  
  207. augroup vimrcEx
  208.  autocmd!
  209.  " When editing a file, always jump to the last known cursor position.
  210.  " Don't do it for commit messages, when the position is invalid, or when
  211.   " inside an event handler (happens when dropping a file on gvim).
  212.   autocmd BufReadPost *
  213.         \ if &ft != 'gitcommit' && line("'\"") > 0 && line("'\"") <= line("$") |
  214.         \   exe "normal g`\"" |
  215.         \ endif
  216.  
  217.   " Set syntax highlighting for specific file types
  218.   autocmd BufRead,BufNewFile Appraisals set filetype=ruby
  219.   autocmd BufRead,BufNewFile *.md set filetype=markdown
  220.  
  221.   " Enable spellchecking for Markdown
  222.   autocmd FileType markdown setlocal spell
  223.  
  224.   " Automatically wrap at 80 characters for Markdown
  225.   autocmd BufRead,BufNewFile *.md setlocal textwidth=80
  226.  
  227.   " Automatically wrap at 72 characters and spell check git commit messages
  228.   autocmd FileType gitcommit setlocal textwidth=72
  229.   autocmd FileType gitcommit setlocal spell
  230.  
  231.   " Allow stylesheets to autocomplete hyphenated words
  232.   autocmd FileType css,scss,sass setlocal iskeyword+=-
  233.  
  234.   " Save all buffs on focus lost
  235.   autocmd BufLeave,FocusLost * silent! wall
  236.   " strip whitespace on save
  237.   autocmd BufWritePre * :%s/\s\+$//e
  238. augroup END
  239.  
  240. function! RenameFile()
  241.     let old_name = expand('%')
  242.     let new_name = input('New file name: ', expand('%'), 'file')
  243.     if new_name != '' && new_name != old_name
  244.         exec ':saveas ' . new_name
  245.         exec ':silent !rm ' . old_name
  246.         redraw!
  247.     endif
  248. endfunction
  249. map <Leader>rn :call RenameFile()<cr>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement