" .vimrc " Author: Nicola Paolucci " Source: https://bitbucket.org/durdn/cfg/src " Preamble with Pathogen "{{{ execute pathogen#infect() "}}} " Basic settings and variables"{{{ filetype plugin indent on syntax on set encoding=utf-8 set visualbell noerrorbells " don't beep set hlsearch incsearch " hightlight search and incremental search set gdefault " global replace by default set nowrap " not wrap lines set nu " show line numbers set foldlevel=1 " default foldlevel 1 to see headings set nobackup noswapfile " stop backup and swap files set nocompatible ignorecase smartcase set nocindent noautoindent nosmartindent indentexpr= "disable autoindents set tabstop=4 shiftwidth=4 expandtab "setup default tab/shift/expand set showmode showcmd ttyfast set guioptions=a " hide scrollbars/menu/tabs let mapleader = "," let maplocalleader = ";" set foldmethod=marker " sets the fold method to {{{ }}} markers set shortmess=atI " disable welcome screen set listchars=tab:\|\ ,trail:·,eol:¬ " End Basic settings and variables}}} " Auto-commands {{{ aug nick " Remove all autocommands for the current group. au! " .md extension is markdown au BufRead,BufNewFile *.md set ft=markdown foldlevel=2 wrap linebreak textwidth=0 wrapmargin=0 au BufRead,BufNewFile *.wp set ft=markdown foldlevel=2 wrap linebreak textwidth=0 wrapmargin=0 if v:version > 703 au BufRead,BufNewFile *.md set colorcolumn=80 au BufRead,BufNewFile *.wp set colorcolumn=80 endif " Spelling on markdown au FileType markdown set spell au FileType go set ts=4 " run go test on Dispatch au FileType go let b:dispatch = 'go build' " javascript tabstop 2 expandtab au BufRead,BufNewFile *.js set ft=javascript foldlevel=2 ts=2 sw=2 expandtab textwidth=79 if v:version > 703 au BufRead,BufNewFile *.js set colorcolumn=80 endif aug END " End Auto-commands }}} " Keyboard Shortcuts and remappings "{{{ " Space to toggle folds. nnoremap za vnoremap za "reload the .vimrc nmap rv :source ~/.vimrc "show spaces" nmap s :set nolist! "show line numbers" nmap l :set nonu! "wrap lines" nmap w :set nowrap! "hide hightlight of searches" nmap // :nohlsearch " Movements shortcuts {{{ " C-h/j/k/l to move between buffers map h map j map k map l " Buffer switching/management, might as well use those keys for something useful map :bnext imap :bnext map :bprev imap :bprev " Maximize only this window" nmap m :only "vertical split" nmap v :bel :vne "horizontal split" nmap f :bel :new "close viewport buffer" nmap x :hid " }}} " Wordpress workarounds {{{ nmap pr :%s/\`\([^`]\+\)`/\\1<\/span>/p:set nohlsearch nmap pu :%s/\(.\{-}\)<\/span>/`\1`/p:set nohlsearch " }}} " Code on retina {{{ nnoremap 9 :call CodeOnRetina() let g:retina_code_environment_on = 0 function! CodeOnRetina() set fuopt=maxvert if g:retina_code_environment_on if has('gui_macvim') set noantialias|set gfn=Terminus\ (TTF):h14|set co=80 else set noantialias|set gfn=Terminus\ (TTF):h14|set co=80 endif let g:retina_code_environment_on = 0 else set antialias|set gfn=Inconsolata:h16|set co=80 let g:retina_code_environment_on = 1 endif endfunction " }}} " Writing environment {{{ nnoremap 0 :call ToggleWritingEnvironment() let g:writing_environment_on = 0 function! ToggleWritingEnvironment() set fuopt=maxvert if g:writing_environment_on if has('gui_macvim') set noantialias|set gfn=Terminus\ (TTF):h14|set co=80 else set noantialias|set gfn=Terminus\ (TTF):h14|set co=80 endif let g:writing_environment_on = 0 else set antialias|set gfn=Inconsolata:h22|set co=180 " set foldcolumn=12 let g:writing_environment_on = 1 endif endfunction " }}} " Paste and visual paste improvments {{{ vnoremap y y`] vnoremap p p`] nnoremap p p`] " vp doesn't replace paste buffer function! RestoreRegister() let @" = s:restore_reg return '' endfunction function! s:Repl() let s:restore_reg = @" return "p@=RestoreRegister()\" endfunction vmap p Repl() " }}} " End Keyboard Shortcuts}}} " Theme and Color {{{ set background=dark colorscheme solarized "font is antialiased Terminus " set noantialias " set guifont=Terminus\ (TTF):h14 set guifont=Hack:h14 "draw vertical column at 80 if v:version > 703 set colorcolumn=80 endif " End Theme and Color }}} " Quick editing {{{ " Edit the .bashrc" nmap eb :e ~/.bashrc " Edit the .vimrc" nmap ev :e ~/.vimrc " Edit the .gitconfig" nmap eg :e ~/.gitconfig " Edit the .tmux.conf" nmap et :e ~/.tmux.conf " Edit slate configuration nmap el :e ~/.slate " Open a scratch file nmap eh :e ~/scratch.txt " Open dev tools content folder nmap ec :e ~/c/source " End Quick editing }}} " Plugins configuration"{{{ " Nerdtree "{{{ map d :execute 'NERDTreeToggle ' . getcwd() let NERDTreeIgnore=['node_modules$[[dir]]', '\.git$[[dir]]'] "}}} " Vim Airline {{{ set laststatus=2 if !exists('g:airline_symbols') let g:airline_symbols = {} endif let g:airline_left_sep = '' let g:airline_right_sep = '' " }}} " ctrlp {{{ let g:ctrlp_map = '' let g:ctrlp_dotfiles = 1 let g:ctrlp_working_path_mode = 2 let g:ctrlp_match_window_bottom = 0 let g:ctrlp_match_window_reversed = 0 let g:ctrlp_custom_ignore = { \ 'dir': 'build/.*\|/temp/.*', \ 'file': '\.jar$\|\.ear$|\.zip', \ } let g:ctrlp_user_command = 'git ls-files %s' " }}} " vim-go {{{ let g:go_fmt_command = "goimports" au FileType go nmap gd (go-doc) au FileType go nmap gv (go-doc-vertical) au FileType go nmap t (go-test) au FileType go nmap rr (go-run) au FileType go nmap e (go-rename) au FileType go nmap ds (go-def-split) au FileType go nmap dv (go-def-vertical) au FileType go nmap dt (go-def-tab) " }}} " Vim Dispatch {{{ nnoremap gt :Dispatch " }}} " End Plugins configuration"}}} " Platform specific configuration {{{ if has('gui_win64') "set noantialias "set guifont=Terminus:h12 set guifont=Hack:h12 set lines=85 nmap ev :e $VIM/_vimrc "overwrite mapping to reload the .vimrc" nmap rv :source $VIM/_vimrc endif if has('gui_win32') "set noantialias "set guifont=Terminus:h12 set guifont=Hack:h12 set lines=85 "overwrite mapping to edit the .vimrc" nmap ev :e $VIM/_vimrc "overwrite mapping to reload the .vimrc" nmap rv :source $VIM/_vimrc endif if has("gui_macvim") set fuopt=maxvert "set noantialias "set guifont=Terminus\ (TTF):h14 set guifont=Hack:h14 command! ToggleFullScreen if &fu|set noantialias|set gfn=Terminus\ (TTF):h14|set co=80|set nofu|else|set antialias|set gfn=Inconsolata:h22|set co=100|set fu|endif an Window.Toggle\ Full\ Screen\ Mode :ToggleFullScreen endif " End Platform specific configuration }}}