set nocompatible " VIM extensions, not very VI compatible; " this setting must be set because when vim " finds a .vimrc on startup, it will set " itself as "compatible" with vi if has("syntax") syntax on endif if has('cmdline_info') set ruler " show the ruler " a ruler on steroids set rulerformat=%30(%=\:b%n%y%m%r%w\ %l,%c%V\ %P%) set showcmd " show partial commands in status line and " selected characters/lines in visual mode endif if has('statusline') set laststatus=1 " show statusline only if there are > 1 windows " a statusline, also on steroids set statusline=%<%f\ %=\:\b%n%y%m%r%w\ %l,%c%V\ %P endif " Ctrl+Backspace erases one word at a time (normal, command-line, insert mode) nnoremap db cnoremap inoremap db if has('gui_running') set guioptions-=T " No toolbar, thank you. else map map! set mouse=a set ttymouse=xterm set ttyfast endif nnoremap :TlistToggle if version >= 700 set spell spelllang=en_gb endif filetype plugin indent on " enable filetype detection, and plugins, and auto-indent. set lz " do not redraw while running macros (much faster) (LazyRedraw) set hid " you can change buffer without saving set wrap " wrap long lines set backspace=2 " make backspace work normally set autoindent " indent at the same level of the previous line "set smartindent " Do smart indenting... set shiftwidth=4 " use indents of 4 spaces set shiftround " Keep indentation at multiples of shiftwidth set tabstop=4 set sts=4 set expandtab set history=500 " Store 500 lines of command history. set smarttab " Smart tabbing, makes backspace be nice. set comments=sO:*-,mO:*,exO:*/,s1:/*,mb:*,ex:*/,f://,b:#,:%,:XCOMM,n:>,fb:- set formatoptions+=tcq " basic formatting of text and comments "set matchpairs+=<:> " match, to be used with % set grepprg=ack-grep\ -a if has("autocmd") " Skip these if vim wasn't compiled with autocmd support augroup vimrcAu " All following autocmds are in this group " clear any already in this group (in case we're sourced twice) auto! auto BufNewFile,BufRead *.[CcHh] set cindent fo=croq "auto BufNewFile,BufRead *.java,*.jsp set comments=sO:*\ -,mO:*\ \ ,exO:*/,s1:/*,mb:*,ex:*/,f://,b:#,:%,:XCOMM,n:>,fb:- fo=croq auto FileType php,javascript,java,python set comments=sO:*\ -,mO:*\ \ ,exO:*/,s1:/*,mb:*,ex:*/,f://,b:#,:%,:XCOMM,n:>,fb:- fo=croq "auto BufNewFile,BufRead *.pl,*.py set comments=sO:*\ -,mO:*\ \ ,exO:*/,s1:/*,mb:*,ex:*/,f://,b:#,:%,:XCOMM,n:>,fb:- fo=croq auto BufNewFile,BufRead *.pyt set filetype=xml fo=croq au BufRead,BufNewFile *.md set filetype=markdown autocmd! BufNewFile,BufRead *.pde setlocal cindent smartindent ft=arduino fo=croq auto FileType mail set tw=74 nosmartindent auto FileType ruby,eruby set tabstop=2 shiftwidth=2 sts=2 iskeyword+=? | iab ?> %> auto FileType coffee,markdown set tabstop=2 shiftwidth=2 sts=2 auto FileType python,django,htmldjango iab ?> %} autocmd FileType json set equalprg=json_reformat auto FileType none set nosmartindent auto BufWinEnter * if &ft !~ '\(txt\|text\|mail\)\?' | setlocal nospell | endif autocmd FileType php,javascript,python,ruby,css,javascript,less,html,djangohtml autocmd BufWritePre :keepjumps %s/\s+$//e "autocmd BufReadPost * :DetectIndent " Settings for SMR project autocmd BufNewFile,BufRead /home/alex/Code/Work/Siliconmilkroundabout/smr/* set tabstop=2 shiftwidth=2 sts=2 " Highlight words to avoid in tech writing " ======================================= " " obviously, basically, simply, of course, clearly, " just, everyone knows, However, So, easy " http://css-tricks.com/words-avoid-educational-writing/ highlight TechWordsToAvoid ctermbg=red ctermfg=white match TechWordsToAvoid /\cobviously\|basically\|simply\|of\scourse\|clearly\|just\|everyone\sknows\|however\|so,\|easy/ autocmd BufWinEnter text,markdown,mail,html match TechWordsToAvoid /\cobviously\|basically\|simply\|of\scourse\|clearly\|just\|everyone\sknows\|however,\|so,\|easy/ autocmd InsertEnter text,markdown,mail,html match TechWordsToAvoid /\cobviously\|basically\|simply\|of\scourse\|clearly\|just\|everyone\sknows\|however,\|so,\|easy/ autocmd InsertLeave text,markdown,mail,html match TechWordsToAvoid /\cobviously\|basically\|simply\|of\scourse\|clearly\|just\|everyone\sknows\|however,\|so,\|easy/ autocmd BufWinLeave text,markdown,mail,html call clearmatches() augroup END endif " Persistent undo and swapfiles in their own directories set undodir=~/.vim/tmp/undo/ set directory=~/.vim/tmp/swap/ set undofile if !isdirectory(expand(&undodir)) call mkdir(expand(&undodir), "p") endif if !isdirectory(expand(&directory)) call mkdir(expand(&directory), "p") endif set showmatch set autowrite set gdefault " Presume that we're replacing globally by default. " Go back to previous line if we have one. autocmd BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") | exe "normal g`\"" | endif " Save and restore folds etc. automatically. au BufWinLeave ?* silent mkview au BufWinEnter ?* silent loadview " Refresh syntax highlighting. noremap :syntax sync fromstart:filetype detect inoremap :syntax sync fromstart:filetype detecta " Make page up/page down work for tab switching noremap [5;5~ :tabp inoremap [5;5~ :tabpa noremap [6;5~ :tabn inoremap [6;5~ :tabna " Settings for Project. nmap :NERDTreeToggle " Settings for Taglist. let Tlist_Use_Right_Window = 1 " Position on the right. let Tlist_WinWidth = 30 " 20 characters wide. nnoremap :TlistToggle " Additions from http://items.sjbach.com/319/configuring-vim-right set hidden nnoremap ' ` nnoremap ` ' set history=1000 set wildmenu set wildmode=list:longest set wildignore=*.pyc set ignorecase set smartcase set title let &titleold=getcwd() set scrolloff=3 set listchars=tab:>-,trail:ยท,eol:$ " Some suggestions from http://statico.github.com/vim.html nmap l :setlocal number! nmap p :set paste! nmap h :set hlsearch! nmap n :set spell! nmap j gj nmap k gk nmap :e# " Write file out using sudo cmap w!! %!sudo tee > /dev/null % " Shortcut for tab editing nmap :tabe " F key shortcuts " Show/hide whitespace nmap :set nolist! " Save/load sessions nnoremap :mksession! .quicksave.vim nnoremap :source .quicksave.vim " Select the last thing pasted. nnoremap gV `[v`] " No entering visual mode from mouse dragging/clicing. noremap noremap! " Disable PHPCodeSniffer, because it is picky as all hell. let g:syntastic_php_checkers=['php', 'phpmd'] " Settings for DetectIndent. let g:detectindent_preferred_indent = 2 " Settings for ack.vim to use ag let g:ackprg = 'ag --nogroup --nocolor --column' " http://robots.thoughtbot.com/faster-grepping-in-vim/ 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 ""' let g:ctrlp_use_caching = 0 " bind K to grep word under cursor nnoremap K :grep! "\b\b":cw " Prevent Vim from clobbering the scrollback buffer. See http://www.shallowsky.com/linux/noaltscreen.html set t_ti= t_te= " Line numbers. set number highlight LineNr ctermfg=grey " Vundle plugin handling, and plugin loading. filetype off set rtp+=~/.vim/bundle/Vundle.vim call vundle#begin() Plugin 'gmarik/Vundle.vim' " Package management Plugin 'Lokaltog/vim-easymotion' " Nicer vim motions "Plugin 'SirVer/ultisnips' " Snippets "Plugin 'Valloric/YouCompleteMe' " Code completion Plugin 'altercation/vim-colors-solarized' " Colour scheme Plugin 'groenewege/vim-less' " Less CSS syntax highlighting "Plugin 'honza/vim-snippets' " Snippets for use with ultisnips Plugin 'jeffkreeftmeijer/vim-numbertoggle' " Relative numbers in normal mode Plugin 'kien/ctrlp.vim' " Fuzzy file matching. Plugin 'mileszs/ack.vim' " Fast search Plugin 'scrooloose/nerdtree' " Filesystem browser Plugin 'scrooloose/syntastic' " Inline style checking Plugin 'terryma/vim-multiple-cursors' " Multiple cursors Plugin 'tpope/vim-bundler' " Bundler support Plugin 'tpope/vim-characterize' " Better character information from ga Plugin 'tpope/vim-endwise' " Add 'end' to Ruby blocks Plugin 'tpope/vim-rails' " Rails help Plugin 'tpope/vim-repeat' " Repeat plugin actions with . Plugin 'tpope/vim-surround' " Wrap stuff with other stuff Plugin 'tpope/vim-unimpaired' " Go to start/end of things. call vundle#end() filetype plugin indent on