├── .gitignore ├── .gitmodules ├── README.md └── vimrc /.gitignore: -------------------------------------------------------------------------------- 1 | bundle/* 2 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "bundle/vundle"] 2 | path = bundle/vundle 3 | url = https://github.com/gmarik/vundle.git 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # [gmarik](http://github.com/gmarik)'s [Vim configuration](http://github.com/gmarik/vimfiles) 2 | 3 | to try it out: 4 | 5 | $ mkdir -p /tmp/vimtest && cd /tmp/vimtest # create and cd to test folder 6 | $ git clone --recursive https://github.com/gmarik/vimfiles.git ./.vim # clone recursively with vundle 7 | $ HOME=`pwd` vim -u .vim/vimrc +BundleInstall +qall # run installation in relative to current folder 8 | # and using downloaded `vimrc` 9 | $ HOME=`pwd` vim -u .vim/vimrc # Start using Vim 10 | 11 | *NOTE*: add `-g` argument to the `vim` command to use graphical UI if you like 12 | -------------------------------------------------------------------------------- /vimrc: -------------------------------------------------------------------------------- 1 | " General "{{{ 2 | set nocompatible " be iMproved 3 | 4 | scriptencoding utf-8 " utf-8 all the way 5 | set encoding=utf-8 6 | 7 | set history=256 " Number of things to remember in history. 8 | set timeoutlen=250 " Time to wait after ESC (default causes an annoying delay) 9 | set clipboard+=unnamed " Yanks go on clipboard instead. 10 | set pastetoggle= " toggle between paste and normal: for 'safer' pasting from keyboard 11 | set shiftround " round indent to multiple of 'shiftwidth' 12 | set tags=.git/tags;$HOME " consider the repo tags first, then 13 | " walk directory tree upto $HOME looking for tags 14 | " note `;` sets the stop folder. :h file-search 15 | 16 | set modeline 17 | set modelines=5 " default numbers of lines to read for modeline instructions 18 | 19 | set autowrite " Writes on make/shell commands 20 | set autoread 21 | 22 | set nobackup 23 | set nowritebackup 24 | set directory=/tmp// " prepend(^=) $HOME/.tmp/ to default path; use full path as backup filename(//) 25 | set noswapfile " 26 | 27 | set hidden " The current buffer can be put to the background without writing to disk 28 | 29 | set hlsearch " highlight search 30 | set ignorecase " be case insensitive when searching 31 | set smartcase " be case sensitive when input has a capital letter 32 | set incsearch " show matches while typing 33 | 34 | let g:is_posix = 1 " vim's default is archaic bourne shell, bring it up to the 90s 35 | let mapleader = ',' 36 | let maplocalleader = ' ' " Tab as a local leader 37 | let g:netrw_banner = 0 " do not show Netrw help banner 38 | " "}}} 39 | 40 | " Formatting "{{{ 41 | set fo+=o " Automatically insert the current comment leader after hitting 'o' or 'O' in Normal mode. 42 | set fo-=r " Do not automatically insert a comment leader after an enter 43 | set fo-=t " Do no auto-wrap text using textwidth (does not apply to comments) 44 | 45 | set nowrap 46 | set textwidth=0 " Don't wrap lines by default 47 | 48 | set tabstop=2 " tab size eql 2 spaces 49 | set softtabstop=2 50 | set shiftwidth=2 " default shift width for indents 51 | set expandtab " replace tabs with ${tabstop} spaces 52 | set smarttab " 53 | 54 | set backspace=indent 55 | set backspace+=eol 56 | set backspace+=start 57 | 58 | set autoindent 59 | set cindent 60 | set indentkeys-=0# " do not break indent on # 61 | set cinkeys-=0# 62 | set cinoptions=:s,ps,ts,cs 63 | set cinwords=if,else,while,do 64 | set cinwords+=for,switch,case 65 | " "}}} 66 | 67 | " Visual "{{{ 68 | syntax on " enable syntax 69 | 70 | " set synmaxcol=250 " limit syntax highlighting to 128 columns 71 | 72 | set mouse=a "enable mouse in GUI mode 73 | set mousehide " Hide mouse after chars typed 74 | 75 | set nonumber " line numbers Off 76 | set showmatch " Show matching brackets. 77 | set matchtime=2 " Bracket blinking. 78 | 79 | set wildmode=longest,list " At command line, complete longest common string, then list alternatives. 80 | 81 | set completeopt-=preview " disable auto opening preview window 82 | 83 | set novisualbell " No blinking 84 | set noerrorbells " No noise. 85 | set vb t_vb= " disable any beeps or flashes on error 86 | 87 | set laststatus=2 " always show status line. 88 | set shortmess=atI " shortens messages 89 | set showcmd " display an incomplete command in statusline 90 | 91 | set statusline=%<%f\ " custom statusline 92 | set stl+=[%{&ff}] " show fileformat 93 | set stl+=%y%m%r%= 94 | set stl+=%-14.(%l,%c%V%)\ %P 95 | 96 | 97 | set foldenable " Turn on folding 98 | set foldmethod=marker " Fold on the marker 99 | set foldlevel=100 " Don't autofold anything (but I can still fold manually) 100 | 101 | set foldopen=block,hor,tag " what movements open folds 102 | set foldopen+=percent,mark 103 | set foldopen+=quickfix 104 | 105 | set virtualedit=block 106 | 107 | set splitbelow 108 | set splitright 109 | 110 | set list " display unprintable characters f12 - switches 111 | set listchars=tab:\ ·,eol:¬ 112 | set listchars+=trail:· 113 | set listchars+=extends:»,precedes:« 114 | map :set invlist 115 | 116 | if has('gui_running') 117 | set guioptions=cMg " console dialogs, do not show menu and toolbar 118 | 119 | " Fonts 120 | " :set guifont=* " to launch a GUI dialog 121 | if has('mac') 122 | if has('macligatures') 123 | set antialias macligatures guifont=Fira\ Code\ Light:h13 " -> <= 124 | else 125 | set noantialias guifont=Andale\ Mono:h14 126 | end 127 | set fuoptions=maxvert,maxhorz ",background:#00AAaaaa 128 | else 129 | set guifont=Terminus:h16 130 | end 131 | endif 132 | " "}}} 133 | 134 | " Key mappings " {{{ 135 | " Duplication 136 | nnoremap c mz"dyy"dp`z 137 | vnoremap c "dymz"dP`z 138 | 139 | nnoremap rs :source ~/.vimrc 140 | nnoremap rt :tabnew ~/.vim/vimrc 141 | nnoremap re :e ~/.vim/vimrc 142 | nnoremap rd :e ~/.vim/ 143 | nnoremap rc :silent ! cd ~/.vim/ && git commit ~/.vim/vimrc -v 144 | 145 | " Tabs 146 | nnoremap :tabprev 147 | nnoremap :tabnext 148 | 149 | " Buffers 150 | nnoremap - :bd 151 | nnoremap -- :bd! 152 | " Split line(opposite to S-J joining line) 153 | nnoremap gEaew 154 | 155 | " map v :vnew 156 | " map s :snew 157 | 158 | " copy filename 159 | map . :let @+=expand('%:p').':'.line('.') 160 | map / :let @+=expand('%:p:h') 161 | " copy path 162 | 163 | 164 | map A 165 | 166 | map E :Explore 167 | map EE :Vexplore!= 168 | 169 | " toggle search highlighting 170 | nnoremap :let &hls=1-&hls 171 | 172 | " Make Control-direction switch between windows (like C-W h, etc) 173 | nmap 174 | nmap 175 | nmap 176 | nmap 177 | 178 | " vertical paragraph-movement 179 | nmap { 180 | nmap } 181 | 182 | " vertical split with fuzzy-searcher 183 | nnoremap v :exec ':vnew \| CtrlP' 184 | " and without 185 | nnoremap V :vnew 186 | 187 | " when pasting copy pasted text back to 188 | " buffer instead replacing with owerride 189 | xnoremap p pgvy 190 | 191 | if has('mac') 192 | 193 | if has('gui_running') 194 | set macmeta 195 | end 196 | 197 | " map(range(1,9), 'exec "imap ".v:val."gt"') 198 | " map(range(1,9), 'exec " map ".v:val."gt"') 199 | 200 | " Copy whole line 201 | nnoremap yy 202 | 203 | " close/delete buffer when closing window 204 | map :bdelete 205 | endif 206 | 207 | " Control+S and Control+Q are flow-control characters: disable them in your terminal settings. 208 | " $ stty -ixon -ixoff 209 | noremap :update 210 | vnoremap :update 211 | inoremap :update 212 | " 213 | " generate HTML version current buffer using current color scheme 214 | map 2h :runtime! syntax/2html.vim 215 | 216 | " " }}} 217 | 218 | " AutoCommands " {{{ 219 | au BufRead,BufNewFile {*.go} setl ft=go tabstop=2 softtabstop=2 noexpandtab smarttab 220 | au BufRead,BufNewFile {*.coffee} setl ft=coffee tabstop=2 softtabstop=2 expandtab smarttab 221 | au BufRead,BufNewFile {Gemfile,Rakefile,*.rake,config.ru,*.rabl} setl ft=ruby tabstop=2 softtabstop=2 shiftwidth=2 expandtab smarttab 222 | au BufRead,BufNewFile {*.local} setl ft=sh 223 | au BufRead,BufNewFile {*.md,*.mkd,*.markdown} setl ft=markdown 224 | au BufRead,BufNewFile {*.scala} setl ft=scala 225 | au! BufReadPost {COMMIT_EDITMSG,*/COMMIT_EDITMSG} exec 'setl ft=gitcommit noml list spell' | norm 1G 226 | au! BufWritePost {*.snippet,*.snippets} call ReloadAllSnippets() 227 | 228 | " open help in vertical split 229 | " au BufWinEnter {*.txt} if 'help' == &ft | wincmd H | nmap q :q | endif 230 | " " }}} 231 | 232 | " Scripts and Plugins " {{{ 233 | filetype off 234 | runtime macros/matchit.vim 235 | set rtp+=~/.vim/bundle/vundle/ 236 | call vundle#rc() 237 | 238 | Plugin 'gmarik/vundle' " let Vundle manage Vundle 239 | 240 | " Colorscheme 241 | Plugin 'gmarik/ingretu' 242 | 243 | if has("gui_running") 244 | colorscheme ingretu 245 | endif 246 | 247 | " Programming 248 | " Python 249 | Plugin 'davidhalter/jedi-vim' 250 | Plugin 'klen/python-mode' 251 | let g:pymode_lint = 0 252 | 253 | " Golang 254 | Plugin 'fatih/vim-go' 255 | " unlike gofmt also adds/removes imports 256 | let g:go_fmt_command = 'gofmt' 257 | let g:go_highlight_functions = 1 258 | let g:go_highlight_methods = 1 259 | let g:go_highlight_structs = 1 260 | let g:go_highlight_build_constraints = 1 261 | 262 | 263 | nnoremap gt :GoTest 264 | nnoremap gv :GoVet 265 | nnoremap gl :GoLint 266 | 267 | " goes to the definition under cursor in a new split 268 | " TODO: doesn't work 269 | nnoremap gd ^zz 270 | 271 | 272 | " Scala 273 | Plugin 'derekwyatt/vim-scala' 274 | 275 | " Ruby/Rails 276 | Plugin 'tpope/vim-rails' 277 | 278 | " Js 279 | Plugin 'pangloss/vim-javascript' 280 | Plugin 'mxw/vim-jsx' 281 | 282 | " Snippets 283 | Plugin 'gmarik/snipmate.vim' 284 | Plugin 'gmarik/snipmate.snippets' 285 | nnoremap so :Explore ~/.vim/bundle/snipmate.snippets/snippets/ 286 | 287 | 288 | 289 | " Syntax highlight 290 | Plugin 'gmarik/vim-markdown' 291 | Plugin 'timcharper/textile.vim' 292 | 293 | " Git integration 294 | Plugin 'tpope/vim-git' 295 | Plugin 'tpope/vim-fugitive' 296 | Plugin 'junegunn/gv.vim' 297 | 298 | nnoremap W :Gwrite 299 | nnoremap C :Gcommit -v 300 | nnoremap S :Gstatus \| 7 301 | inoremap W W 302 | inoremap C C 303 | inoremap S S 304 | 305 | Plugin 'tpope/vim-repeat' 306 | Plugin 'tpope/vim-surround' 307 | Plugin 'tpope/vim-unimpaired' 308 | 309 | " bubble current line 310 | nmap ]e 311 | nmap [e 312 | " bubble visual selection lines 313 | vmap ]egv 314 | vmap [egv 315 | 316 | " Utility 317 | Plugin 'AndrewRadev/splitjoin.vim' 318 | nmap sj :SplitjoinJoin 319 | nmap sk :SplitjoinSplit 320 | 321 | Plugin 'gmarik/github-search.vim' 322 | 323 | Plugin 'gmarik/ide-popup.vim' 324 | Plugin 'gmarik/sudo-gui.vim' 325 | 326 | Plugin 'sjl/gundo.vim' 327 | 328 | Plugin 'mkitt/browser-refresh.vim' 329 | com! ONRRB :au! BufWritePost :RRB 330 | com! NORRB :au! BufWritePost 331 | 332 | 333 | " Plugin 'SuperTab' 334 | Plugin 'bogado/file-line' 335 | Plugin 'junegunn/vim-easy-align' 336 | Plugin 'vim-scripts/lastpos.vim' 337 | 338 | Plugin 'Lokaltog/vim-easymotion' 339 | let g:EasyMotion_leader_key='' 340 | 341 | Plugin 'ZoomWin' 342 | noremap o :ZoomWin 343 | vnoremap o :ZoomWin 344 | inoremap o :ZoomWin 345 | 346 | Plugin 'tomtom/tlib_vim' 347 | Plugin 'tomtom/tcomment_vim' 348 | nnoremap // :TComment 349 | vnoremap // :TComment 350 | 351 | Plugin 'gmarik/hlmatch.vim' 352 | nnoremap # :HlmCword 353 | nnoremap # :HlmGrepCword 354 | vnoremap # :HlmVSel 355 | vnoremap # :HlmGrepVSel 356 | 357 | nnoremap ## :HlmPartCword 358 | nnoremap ## :HlmPartGrepCword 359 | vnoremap ## :HlmPartVSel 360 | vnoremap ## :HlmPartGrepVSel 361 | 362 | Plugin 'ctrlpvim/ctrlp.vim' 363 | let g:ctrlp_map = 't' 364 | let g:ctrlp_match_window = 'bottom,order:btt,min:1,max:10,results:10' 365 | let g:ctrlp_extensions = ['tag', 'buffertag', 'dir', 'rtscript', 366 | \ 'undo', 'line', 'changes', 'mixed', 'bookmarkdir'] 367 | 368 | nnoremap 0 :CtrlPClearAllCaches 369 | nnoremap ` :CtrlPUndo 370 | nnoremap 1 :CtrlPTag expand("") 371 | nnoremap 11 :CtrlPTag 372 | nnoremap 2 :CtrlP expand("%:h:p") 373 | nnoremap 22 :CtrlP 374 | nnoremap 3 :CtrlPBuffer 375 | nnoremap 4 :CtrlPDir expand("%:h:p") 376 | nnoremap 44 :CtrlPDir 377 | nnoremap 6 :CtrlPMRU 378 | nnoremap 7 :CtrlPLine 379 | nnoremap 8 :CtrlPChange 380 | nnoremap 9 :CtrlPChange 381 | nnoremap h :CtrlPRTS 382 | 383 | 384 | Plugin 'rstacruz/sparkup.git', {'rtp': 'vim/'} 385 | let g:sparkupExecuteMapping = '' 386 | let g:sparkupNextMapping = '' 387 | 388 | filetype plugin indent on " Automatically detect file types. 389 | 390 | " " }}} 391 | --------------------------------------------------------------------------------