123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853 |
- #/root/.vimrc
- "
- " Personal preference .vimrc file
- "
- "
- " Use vim settings, rather then vi settings (much better!)
- " This must be first, because it changes other options as a side effect.
- set nocompatible
- syntax on
- " Change shell
- set shell=bash " Vim expects a POSIX-compliant shell
- " Change the mapleader from \ to ,
- let mapleader=","
- let maplocalleader="\\"
- " Editing behaviour {{{
- filetype indent on " load indent.vim needed for flake8 and other plugins
- set showmode " always show what mode we're currently editing in
- set nowrap " don't wrap lines
- set tabstop=4 " a tab is four spaces
- set softtabstop=4 " when hitting <BS>, pretend like a tab is removed, even if spaces
- set expandtab " expand tabs by default (overloadable per file type later)
- set shiftwidth=4 " number of spaces to use for autoindenting
- set shiftround " use multiple of shiftwidth when indenting with '<' and '>'
- set backspace=indent,eol,start " allow backspacing over everything in insert mode
- set autoindent " always set autoindenting on
- set copyindent " copy the previous indentation on autoindenting
- set number " always show line numbers
- set showmatch " set show matching parenthesis
- set ignorecase " ignore case when searching
- set smartcase " ignore case if search pattern is all lowercase,
- " case-sensitive otherwise
- set smarttab " insert tabs on the start of a line according to
- " shiftwidth, not tabstop
- set scrolloff=4 " keep 4 lines off the edges of the screen when scrolling
- set virtualedit=all " allow the cursor to go in to "invalid" places
- set hlsearch " highlight search terms
- set incsearch " show search matches as you type
- set gdefault " search/replace "globally" (on a line) by default
- set listchars=trail:·,precedes:«,extends:»,eol:↲,tab:▸\
- " set listchars=trail:\uB7,precedes:«,extends:»,eol:↲,tab:\uBB\uBB
- set nolist " don't show invisible characters by default,
- " but it is enabled for some file types (see later)
- set pastetoggle=<F2> " when in insert mode, press <F2> to go to
- " paste mode, where you can paste mass data
- " that won't be autoindented
- set mouse=a " enable using the mouse if terminal emulator
- " supports it (xterm does)
- set fileformats="unix,dos,mac"
- set formatoptions+=1 " When wrapping paragraphs, don't end lines
- " with 1-letter words (looks stupid)
- set nrformats= " make <C-a> and <C-x> play well with
- " zero-padded numbers (i.e. don't consider
- " them octal or hex)
- set shortmess+=I " hide the launch screen
- set clipboard=unnamed " normal OS clipboard interaction
- set autoread " automatically reload files changed outside of Vim
- " Toggle show/hide invisible chars
- nnoremap <leader>i :set list!<cr>
- " Toggle line numbers
- nnoremap <leader>N :setlocal number!<cr>
- " Thanks to Steve Losh for this liberating tip
- " See http://stevelosh.com/blog/2010/09/coming-home-to-vim
- nnoremap / /\v
- vnoremap / /\v
- " Speed up scrolling of the viewport slightly
- nnoremap <C-e> 2<C-e>
- nnoremap <C-y> 2<C-y>
- " }}}
- " Folding rules {{{
- set foldenable " enable folding
- set foldcolumn=2 " add a fold column
- set foldmethod=marker " detect triple-{ style fold markers
- set foldlevelstart=99 " start out with everything unfolded
- set foldopen=block,hor,insert,jump,mark,percent,quickfix,search,tag,undo
- " which commands trigger auto-unfold
- function! MyFoldText()
- let line = getline(v:foldstart)
- let nucolwidth = &fdc + &number * &numberwidth
- let windowwidth = winwidth(0) - nucolwidth - 3
- let foldedlinecount = v:foldend - v:foldstart
- " expand tabs into spaces
- let onetab = strpart(' ', 0, &tabstop)
- let line = substitute(line, '\t', onetab, 'g')
- let line = strpart(line, 0, windowwidth - 2 -len(foldedlinecount))
- let fillcharcount = windowwidth - len(line) - len(foldedlinecount) - 4
- return line . ' …' . repeat(" ",fillcharcount) . foldedlinecount . ' '
- endfunction
- set foldtext=MyFoldText()
- " Mappings to easily toggle fold levels
- nnoremap z0 :set foldlevel=0<cr>
- nnoremap z1 :set foldlevel=1<cr>
- nnoremap z2 :set foldlevel=2<cr>
- nnoremap z3 :set foldlevel=3<cr>
- nnoremap z4 :set foldlevel=4<cr>
- nnoremap z5 :set foldlevel=5<cr>
- " }}}
- " Editor layout {{{
- set termencoding=utf-8
- set encoding=utf-8
- set lazyredraw " don't update the display while executing macros
- set laststatus=2 " tell VIM to always put a status line in, even
- " if there is only one window
- set cmdheight=2 " use a status bar that is 2 rows high
- " }}}
- " Vim behaviour {{{
- set hidden " hide buffers instead of closing them this
- " means that the current buffer can be put
- " to background without being written; and
- " that marks and undo history are preserved
- set switchbuf=useopen " reveal already opened files from the
- " quickfix window instead of opening new
- " buffers
- set history=1000 " remember more commands and search history
- set undolevels=1000 " use many muchos levels of undo
- if v:version >= 730
- set undofile " keep a persistent backup file
- set undodir=~/.vim/.undo,~/tmp,/tmp
- endif
- set nobackup " do not keep backup files, it's 70's style cluttering
- set noswapfile " do not write annoying intermediate swap files,
- " who did ever restore from swap files anyway?
- set directory=~/.vim/.tmp,~/tmp,/tmp
- " store swap files in one of these directories
- " (in case swapfile is ever turned on)
- set viminfo='20,\"80 " read/write a .viminfo file, don't store more
- " than 80 lines of registers
- set wildmenu " make tab completion for files/buffers act like bash
- set wildmode=list:full " show a list when pressing tab and complete
- " first full match
- set wildignore=*.swp,*.bak,*.pyc,*.class
- set title " change the terminal's title
- set visualbell " don't beep
- set noerrorbells " don't beep
- set showcmd " show (partial) command in the last line of the screen
- " this also shows visual selection info
- set nomodeline " disable mode lines (security measure)
- set ttyfast " always use a fast terminal
- set cursorline " underline the current line, for quick orientation
- " }}}
- " Toggle the quickfix window {{{
- " From Steve Losh, http://learnvimscriptthehardway.stevelosh.com/chapters/38.html
- nnoremap <C-q> :call <SID>QuickfixToggle()<cr>
- let g:quickfix_is_open = 0
- function! s:QuickfixToggle()
- if g:quickfix_is_open
- cclose
- let g:quickfix_is_open = 0
- execute g:quickfix_return_to_window . "wincmd w"
- else
- let g:quickfix_return_to_window = winnr()
- copen
- let g:quickfix_is_open = 1
- endif
- endfunction
- " }}}
- " Toggle the foldcolumn {{{
- nnoremap <leader>f :call FoldColumnToggle()<cr>
- let g:last_fold_column_width = 4 " Pick a sane default for the foldcolumn
- function! FoldColumnToggle()
- if &foldcolumn
- let g:last_fold_column_width = &foldcolumn
- setlocal foldcolumn=0
- else
- let &l:foldcolumn = g:last_fold_column_width
- endif
- endfunction
- " }}}
- " Highlighting {{{
- if &t_Co > 2 || has("gui_running")
- syntax on " switch syntax highlighting on, when the terminal has colors
- endif
- " }}}
- " Shortcut mappings {{{
- " Since I never use the ; key anyway, this is a real optimization for almost
- " all Vim commands, as I don't have to press the Shift key to form chords to
- " enter ex mode.
- nnoremap ; :
- nnoremap <leader>; ;
- " Avoid accidental hits of <F1> while aiming for <Esc>
- noremap! <F1> <Esc>
- nnoremap <leader>Q :q<CR> " Quickly close the current window
- nnoremap <leader>q :bd<CR> " Quickly close the current buffer
- " Use Q for formatting the current paragraph (or visual selection)
- vnoremap Q gq
- nnoremap Q gqap
- " set breakindent on " keep paragraph indentation when re-wrapping text
- " Sort paragraphs
- vnoremap <leader>s !sort -f<CR>gv
- nnoremap <leader>s vip!sort -f<CR><Esc>
- " make p in Visual mode replace the selected text with the yank register
- vnoremap p <Esc>:let current_reg = @"<CR>gvdi<C-R>=current_reg<CR><Esc>
- " Shortcut to make
- nnoremap mk :make<CR>
- " Swap implementations of ` and ' jump to markers
- " By default, ' jumps to the marked line, ` jumps to the marked line and
- " column, so swap them
- nnoremap ' `
- nnoremap ` '
- " Use the damn hjkl keys
- " noremap <up> <nop>
- " noremap <down> <nop>
- " noremap <left> <nop>
- " noremap <right> <nop>
- " Remap j and k to act as expected when used on long, wrapped, lines
- nnoremap j gj
- nnoremap k gk
- " Easy window navigation
- noremap <C-h> <C-w>h
- noremap <C-j> <C-w>j
- noremap <C-k> <C-w>k
- noremap <C-l> <C-w>l
- " nnoremap <leader>w <C-w>v<C-w>l
- " Complete whole filenames/lines with a quicker shortcut key in insert mode
- inoremap <C-f> <C-x><C-f>
- inoremap <C-l> <C-x><C-l>
- " Use ,d (or ,dd or ,dj or 20,dd) to delete a line without adding it to the
- " yanked stack (also, in visual mode)
- nnoremap <silent> <leader>d "_d
- vnoremap <silent> <leader>d "_d
- " vnoremap <silent> x "_x TODODODOOo
- " Quick yanking to the end of the line
- nnoremap Y y$
- " YankRing stuff
- let g:yankring_history_dir = '$HOME/.vim/.tmp'
- nnoremap <leader>r :YRShow<CR>
- " Edit the vimrc file
- nnoremap <silent> <leader>ev :e $MYVIMRC<CR>
- nnoremap <silent> <leader>sv :so $MYVIMRC<CR>
- " Clears the search register
- nnoremap <silent> <leader>/ :nohlsearch<CR>
- " Pull word under cursor into LHS of a substitute (for quick search and
- " replace)
- nnoremap <leader>z :%s#\<<C-r>=expand("<cword>")<CR>\>#
- " Keep search matches in the middle of the window and pulse the line when moving
- " to them.
- nnoremap n n:call PulseCursorLine()<cr>
- nnoremap N N:call PulseCursorLine()<cr>
- " Quickly get out of insert mode without your fingers having to leave the
- " home row (either use 'jj' or 'jk')
- inoremap jj <Esc>
- " Quick alignment of text
- nnoremap <leader>al :left<CR>
- nnoremap <leader>ar :right<CR>
- nnoremap <leader>ac :center<CR>
- " Sudo to write
- cnoremap w!! w !sudo tee % >/dev/null
- " Ctrl+W to redraw
- nnoremap <C-w> :redraw!<cr>
- " Jump to matching pairs easily, with Tab
- nnoremap <Tab> %
- vnoremap <Tab> %
- " Folding
- nnoremap <Space> za
- vnoremap <Space> za
- " Strip all trailing whitespace from a file, using ,W
- nnoremap <leader>W :%s/\s\+$//<CR>:let @/=''<CR>
- " Use The Silver Searcher over grep, iff possible
- if executable('ag')
- " Use ag over grep
- set grepprg=ag\ --nogroup\ --nocolor
- " Use ag in CtrlP for listing files. Lightning fast and respects .gitignore
- let g:ctrlp_user_command = 'ag %s -l --nocolor -g ""'
- " ag is fast enough that CtrlP doesn't need to cache
- let g:ctrlp_use_caching = 0
- endif
- " grep/Ack/Ag for the word under cursor
- " vnoremap <leader>a y:grep! "\b<c-r>"\b"<cr>:cw<cr>
- " nnoremap <leader>a :grep! "\b<c-r><c-w>\b"
- vnoremap <leader>a y:Ag <c-r><cr>:cw<cr>
- nnoremap <leader>a :Ag <c-r><c-w>
- nnoremap K *N:grep! "\b<c-r><c-w>\b"<cr>:cw<cr>
- " Allow quick additions to the spelling dict
- nnoremap <leader>g :spellgood <c-r><c-w>
- " Define "Ag" command
- command -nargs=+ -complete=file -bar Ag silent! grep! <args> | cwindow | redraw!
- " bind \ (backward slash) to grep shortcut
- nnoremap \ :Ag<SPACE>
- " Creating folds for tags in HTML
- "nnoremap <leader>ft Vatzf
- " Reselect text that was just pasted with ,v
- nnoremap <leader>v V`]
- " }}}
- " NERDTree settings {{{
- nnoremap <leader>n :NERDTreeFocus<CR>
- nnoremap <leader>m :NERDTreeClose<CR>:NERDTreeFind<CR>
- nnoremap <leader>N :NERDTreeClose<CR>
- " Store the bookmarks file
- let NERDTreeBookmarksFile=expand("$HOME/.vim/NERDTreeBookmarks")
- " Show the bookmarks table on startup
- let NERDTreeShowBookmarks=1
- " Show hidden files, too
- let NERDTreeShowFiles=1
- let NERDTreeShowHidden=1
- " Quit on opening files from the tree
- let NERDTreeQuitOnOpen=1
- " Highlight the selected entry in the tree
- let NERDTreeHighlightCursorline=1
- " Use a single click to fold/unfold directories and a double click to open
- " files
- let NERDTreeMouseMode=2
- " Don't display these kinds of files
- let NERDTreeIgnore=[ '\.pyc$', '\.pyo$', '\.py\$class$', '\.obj$',
- \ '\.o$', '\.so$', '\.egg$', '^\.git$', '__pycache__', '\.DS_Store' ]
- " }}}
- " vim-flake8 default configuration
- let g:flake8_show_in_gutter=1
- " vim-airline enable
- let g:airline_powerline_fonts = 1
- if !exists('g:airline_symbols')
- let g:airline_symbols = {}
- endif
- " unicode symbols
- let g:airline_left_sep = '»'
- let g:airline_left_sep = '▶'
- let g:airline_right_sep = '«'
- let g:airline_right_sep = '◀'
- let g:airline_symbols.linenr = '␊'
- let g:airline_symbols.linenr = ''
- let g:airline_symbols.linenr = '¶'
- let g:airline_symbols.branch = '⎇'
- let g:airline_symbols.paste = 'ρ'
- let g:airline_symbols.paste = 'Þ'
- let g:airline_symbols.paste = '∥'
- let g:airline_symbols.whitespace = 'Ξ'
- " airline symbols
- let g:airline_left_sep = ''
- let g:airline_left_alt_sep = ''
- let g:airline_right_sep = ''
- let g:airline_right_alt_sep = ''
- let g:airline_symbols.branch = ''
- let g:airline_symbols.readonly = ''
- let g:airline_symbols.linenr = ''
- " Conflict markers {{{
- " highlight conflict markers
- match ErrorMsg '^\(<\|=\|>\)\{7\}\([^=].\+\)\?$'
- " shortcut to jump to next conflict marker
- nnoremap <silent> <leader>c /^\(<\\|=\\|>\)\{7\}\([^=].\+\)\?$<CR>
- " }}}
- " Filetype specific handling {{{
- " only do this part when compiled with support for autocommands
- if has("autocmd")
- augroup invisible_chars "{{{
- au!
- " Show invisible characters in all of these files
- autocmd filetype vim setlocal list
- autocmd filetype python,rst setlocal list
- autocmd filetype ruby setlocal list
- autocmd filetype javascript,css setlocal list
- augroup end "}}}
- augroup vim_files "{{{
- au!
- " Bind <F1> to show the keyword under cursor
- " general help can still be entered manually, with :h
- autocmd filetype vim noremap <buffer> <F1> <Esc>:help <C-r><C-w><CR>
- autocmd filetype vim noremap! <buffer> <F1> <Esc>:help <C-r><C-w><CR>
- augroup end "}}}
- augroup html_files "{{{
- au!
- " This function detects, based on HTML content, whether this is a
- " Django template, or a plain HTML file, and sets filetype accordingly
- fun! s:DetectHTMLVariant()
- let n = 1
- while n < 50 && n < line("$")
- " check for django
- if getline(n) =~ '{%\s*\(extends\|load\|block\|if\|for\|include\|trans\)\>'
- set ft=htmldjango.html
- return
- endif
- let n = n + 1
- endwhile
- " go with html
- set ft=html
- endfun
- " Auto-tidy selection
- vnoremap <leader>x :!tidy -q -i --show-errors 0 --show-body-only 1 --wrap 0<cr><cr>
- autocmd BufNewFile,BufRead *.html,*.htm,*.j2 call s:DetectHTMLVariant()
- " Auto-closing of HTML/XML tags
- let g:closetag_default_xml=1
- autocmd filetype html,htmldjango let b:closetag_html_style=1
- autocmd filetype html,xhtml,xml source ~/.vim/scripts/closetag.vim
- augroup end " }}}
- augroup python_files "{{{
- au!
- " This function detects, based on Python content, whether this is a
- " Django file, which may enabling snippet completion for it
- fun! s:DetectPythonVariant()
- let n = 1
- while n < 50 && n < line("$")
- " check for django
- if getline(n) =~ 'import\s\+\<django\>' || getline(n) =~ 'from\s\+\<django\>\s\+import'
- set ft=python.django
- "set syntax=python
- return
- endif
- let n = n + 1
- endwhile
- " go with html
- set ft=python
- endfun
- autocmd BufNewFile,BufRead *.py call s:DetectPythonVariant()
- " PEP8 compliance (set 1 tab = 4 chars explicitly, even if set
- " earlier, as it is important)
- autocmd filetype python setlocal textwidth=78
- autocmd filetype python match ErrorMsg '\%>120v.\+'
- " But disable autowrapping as it is super annoying
- autocmd filetype python setlocal formatoptions-=t
- " Folding for Python (uses syntax/python.vim for fold definitions)
- "autocmd filetype python,rst setlocal nofoldenable
- "autocmd filetype python setlocal foldmethod=expr
- " Python runners
- autocmd filetype python noremap <buffer> <F5> :w<CR>:!python %<CR>
- autocmd filetype python inoremap <buffer> <F5> <Esc>:w<CR>:!python %<CR>
- autocmd filetype python noremap <buffer> <S-F5> :w<CR>:!ipython %<CR>
- autocmd filetype python inoremap <buffer> <S-F5> <Esc>:w<CR>:!ipython %<CR>
- " Automatic insertion of breakpoints
- autocmd filetype python nnoremap <buffer> <leader>bp :normal oimport pdb; pdb.set_trace() # TODO: BREAKPOINT # noqa<Esc>
- " Toggling True/False
- autocmd filetype python nnoremap <silent> <C-t> mmviw:s/True\\|False/\={'True':'False','False':'True'}[submatch(0)]/<CR>`m:nohlsearch<CR>
- " Run a quick static syntax check every time we save a Python file
- autocmd BufWritePost *.py call Flake8()
- " Defer to isort for sorting Python imports (instead of using Unix sort)
- autocmd filetype python nnoremap <leader>s mX:%!isort -<cr>`X:redraw!<cr>
- augroup end " }}}
- augroup js_files "{{{
- " Defer to import-sort for sorting JavaScript imports (instead of using Unix sort)
- autocmd filetype javascript nnoremap <leader>s :write<cr>mX:!import-sort --overwrite %<cr>:edit!<cr>`X
- augroup end " }}}
- augroup clojure_files "{{{
- au!
- " Set up <leader>r to run the entire file with vim-fireplace
- autocmd filetype clojure nnoremap <leader>r :%Eval<cr>
- autocmd filetype clojure RainbowParenthesesActivate
- autocmd filetype clojure RainbowParenthesesLoadRound
- autocmd filetype clojure RainbowParenthesesLoadSquare
- autocmd filetype clojure RainbowParenthesesLoadBraces
- augroup end " }}}
- augroup supervisord_files "{{{
- au!
- autocmd BufNewFile,BufRead supervisord.conf set ft=dosini
- augroup end " }}}
- augroup markdown_files "{{{
- au!
- autocmd filetype markdown noremap <buffer> <leader>p :w<CR>:!open -a 'Marked 2' %<CR><CR>
- augroup end " }}}
- augroup ruby_files "{{{
- au!
- augroup end " }}}
- augroup rst_files "{{{
- au!
- " Auto-wrap text around 74 chars
- autocmd filetype rst setlocal textwidth=74
- autocmd filetype rst setlocal formatoptions+=nqt
- autocmd filetype rst match ErrorMsg '\%>74v.\+'
- augroup end " }}}
- augroup css_files "{{{
- au!
- autocmd filetype css,less setlocal foldmethod=marker foldmarker={,}
- augroup end "}}}
- augroup javascript_files "{{{
- au!
- autocmd filetype javascript setlocal expandtab
- autocmd filetype javascript setlocal listchars=trail:·,extends:#,nbsp:·
- autocmd filetype javascript setlocal foldmethod=marker foldmarker={,}
- " Toggling True/False
- autocmd filetype javascript nnoremap <silent> <C-t> mmviw:s/true\\|false/\={'true':'false','false':'true'}[submatch(0)]/<CR>`m:nohlsearch<CR>
- " Enable insertion of "debugger" statement in JS files
- autocmd filetype javascript nnoremap <leader>b Odebugger;<esc>
- " Use prettier to format JS files
- autocmd FileType javascript set formatprg=bin/prettier-stdin
- autocmd BufWritePre *.js,*.jsx Neoformat
- augroup end "}}}
- augroup textile_files "{{{
- au!
- autocmd filetype textile set tw=78 wrap
- " Render YAML front matter inside Textile documents as comments
- autocmd filetype textile syntax region frontmatter start=/\%^---$/ end=/^---$/
- autocmd filetype textile highlight link frontmatter Comment
- augroup end "}}}
- augroup git_files "{{{
- au!
- " Don't remember the last cursor position when editing commit
- " messages, always start on line 1
- autocmd filetype gitcommit call setpos('.', [0, 1, 1, 0])
- augroup end "}}}
- endif
- " }}}
- " Skeleton processing {{{
- if has("autocmd")
- "if !exists('*LoadTemplate')
- "function LoadTemplate(file)
- "" Add skeleton fillings for Python (normal and unittest) files
- "if a:file =~ 'test_.*\.py$'
- "execute "0r ~/.vim/skeleton/test_template.py"
- "elseif a:file =~ '.*\.py$'
- "execute "0r ~/.vim/skeleton/template.py"
- "endif
- "endfunction
- "endif
- "autocmd BufNewFile * call LoadTemplate(@%)
- endif " has("autocmd")
- " }}}
- " Restore cursor position upon reopening files {{{
- autocmd BufReadPost *
- \ if &filetype != "gitcommit" && line("'\"") > 0 && line("'\"") <= line("$") |
- \ exe "normal! g`\"" |
- \ endif
- " }}}
- " Common abbreviations / misspellings {{{
- "source ~/.vim/autocorrect.vim
- " }}}
- " Extra vi-compatibility {{{
- " set extra vi-compatible options
- set cpoptions+=$ " when changing a line, don't redisplay, but put a '$' at
- " the end during the change
- set formatoptions-=o " don't start new lines w/ comment leader on pressing 'o'
- au filetype vim set formatoptions-=o
- " somehow, during vim filetype detection, this gets set
- " for vim files, so explicitly unset it again
- " }}}
- " Extra user or machine specific settings {{{
- "source ~/.vim/user.vim
- " }}}
- "set guifont=Anonymous\ for\ Powerline:h12 linespace=2
- "set guifont=Droid\ Sans\ Mono:h14 linespace=0
- "set guifont=Mensch\ for\ Powerline:h14 linespace=0
- "set guifont=saxMono:h14 linespace=3
- "set guifont=Ubuntu\ Mono:h18 linespace=3
- "set guifont=Source\ Code\ Pro\ Light:h10 linespace=0
- "if has("gui_running")
- " Remove toolbar, left scrollbar and right scrollbar
- " set guioptions-=T
- " set guioptions-=l
- " set guioptions-=L
- " set guioptions-=r
- " set guioptions-=R
- " set guifont=Source\ Code\ Pro\ Light:h13 linespace=0
- "else
- " set bg=dark
- "endif
- colorscheme molokai
- "colorscheme mustang
- "colorscheme mustang_silent
- "colorscheme wombat256
- "colorscheme jellybeans
- "colorscheme onedark
- " Pulse ------------------------------------------------------------------- {{{
- function! PulseCursorLine()
- let current_window = winnr()
- windo set nocursorline
- execute current_window . 'wincmd w'
- setlocal cursorline
- redir => old_hi
- silent execute 'hi CursorLine'
- redir END
- let old_hi = split(old_hi, '\n')[0]
- let old_hi = substitute(old_hi, 'xxx', '', '')
- hi CursorLine guibg=#3a3a3a
- redraw
- sleep 20m
- hi CursorLine guibg=#4a4a4a
- redraw
- sleep 30m
- hi CursorLine guibg=#3a3a3a
- redraw
- sleep 30m
- hi CursorLine guibg=#2a2a2a
- redraw
- sleep 20m
- execute 'hi ' . old_hi
- windo set cursorline
- execute current_window . 'wincmd w'
- endfunction
- " }}}
- " Powerline configuration ------------------------------------------------- {{{
- let g:Powerline_symbols = 'compatible'
- "let g:Powerline_symbols = 'fancy'
- " }}}
- " Python mode configuration ----------------------------------------------- {{{
- " Don't run pylint on every save
- let g:pymode = 1
- let g:pymode_breakpoint = 0
- let g:pymode_breakpoint_bind = '<leader>b'
- let g:pymode_doc = 0
- let g:pymode_doc_bind = 'K'
- let g:pymode_folding = 0
- let g:pymode_indent = 0
- let g:pymode_lint = 0
- let g:pymode_lint_checkers = ['pyflakes', 'pep8', 'mccabe']
- let g:pymode_lint_cwindow = 1
- let g:pymode_lint_ignore = ''
- let g:pymode_lint_message = 1
- let g:pymode_lint_on_fly = 0
- let g:pymode_lint_on_write = 0
- let g:pymode_lint_select = ''
- let g:pymode_lint_signs = 1
- let g:pymode_motion = 0
- let g:pymode_options = 0
- let g:pymode_paths = []
- let g:pymode_quickfix_maxheight = 6
- let g:pymode_quickfix_minheight = 3
- let g:pymode_rope = 1
- let g:pymode_rope_completion = 0
- let g:pymode_rope_regenerate_on_write = 0
- let g:pymode_run = 0
- let g:pymode_run_bind = '<leader>r'
- let g:pymode_trim_whitespaces = 0
- " }}}
- " Ignore common directories
- let g:ctrlp_custom_ignore = {
- \ 'dir': 'node_modules\|bower_components',
- \ }
- " Invoke CtrlP, but CommandT style
- nnoremap <leader>t :CtrlP<cr>
- nnoremap <leader>. :CtrlPTag<cr>
- nnoremap <leader>b :CtrlPBuffer<cr>
- " Learn Vim Script the Hard Way Exercises
- noremap - ddp
- noremap _ ddkP
- " C-U in insert/normal mode, to uppercase the word under cursor
- inoremap <c-u> <esc>viwUea
- nnoremap <c-u> viwUe
- " Quote words under cursor
- nnoremap <leader>" viW<esc>a"<esc>gvo<esc>i"<esc>gvo<esc>3l
- nnoremap <leader>' viW<esc>a'<esc>gvo<esc>i'<esc>gvo<esc>3l
- " Quote current selection
- " TODO: This only works for selections that are created "forwardly"
- vnoremap <leader>" <esc>a"<esc>gvo<esc>i"<esc>gvo<esc>ll
- vnoremap <leader>' <esc>a'<esc>gvo<esc>i'<esc>gvo<esc>ll
- " Use shift-H and shift-L for move to beginning/end
- nnoremap H 0
- nnoremap L $
- " Define operator-pending mappings to quickly apply commands to function names
- " and/or parameter lists in the current line
- onoremap inf :<c-u>normal! 0f(hviw<cr>
- onoremap anf :<c-u>normal! 0f(hvaw<cr>
- onoremap in( :<c-u>normal! 0f(vi(<cr>
- onoremap an( :<c-u>normal! 0f(va(<cr>
- " "Next" tag
- onoremap int :<c-u>normal! 0f<vit<cr>
- onoremap ant :<c-u>normal! 0f<vat<cr>
- " Function argument selection (change "around argument", change "inside argument")
- onoremap ia :<c-u>execute "normal! ?[,(]\rwv/[),]\rh"<cr>
- vnoremap ia :<c-u>execute "normal! ?[,(]\rwv/[),]\rh"<cr>
- " Split previously opened file ('#') in a split window
- nnoremap <leader>sh :execute "leftabove vsplit" bufname('#')<cr>
- nnoremap <leader>sl :execute "rightbelow vsplit" bufname('#')<cr>
- " Grep searches
- "nnoremap <leader>g :silent execute "grep! -R " . shellescape('<cword>') . " ."<cr>:copen 12<cr>
- "nnoremap <leader>G :silent execute "grep! -R " . shellescape('<cWORD>') . " ."<cr>:copen 12<cr>
- " Rope config
- nnoremap <leader>A :RopeAutoImport<cr>
- " Switch from block-cursor to vertical-line-cursor when going into/out of
- " insert mode
- let &t_SI = "\<Esc>]50;CursorShape=1\x7"
- let &t_EI = "\<Esc>]50;CursorShape=0\x7"
- " Configure vim-expand-region, for easy selection precision
- vmap v <Plug>(expand_region_expand)
- vmap <C-v> <Plug>(expand_region_shrink)
- " Configure ArgWrap
- let g:argwrap_tail_comma = 1
- nnoremap <leader>w :ArgWrap<cr>
- " Default settings. (NOTE: Remove comments in dictionary before sourcing)
- let g:expand_region_text_objects = {
- \ 'iw' :0,
- \ 'i"' :0,
- \ 'i''' :0,
- \ 'a"' :0,
- \ 'a''' :0,
- \ 'i)' :1,
- \ 'i}' :1,
- \ 'i]' :1,
- \ 'a)' :1,
- \ 'a}' :1,
- \ 'a]' :1,
- \ }
- " HTML specific region expansions
- " call expand_region#custom_text_objects('html', {
- " \ 'it': 1,
- " \ 'at': 1,
- " \ })
|