execute pathogen#infect() " Use the Solarized Dark theme set background=dark colorscheme solarized let g:solarized_termtrans=1 " Enable syntax highlighting syntax on " Make Vim more useful set nocompatible " Use the OS clipboard by default (on versions compiled with `+clipboard`) set clipboard=unnamed " Enhance command-line completion set wildmenu " Allow cursor keys in insert mode set esckeys " Allow backspace in insert mode set backspace=indent,eol,start " Optimize for fast terminal connections set ttyfast " Add the g flag to search/replace by default set gdefault " Use UTF-8 without BOM set encoding=utf-8 nobomb " Don’t add empty newlines at the end of files set binary set noeol " Centralize backups, swapfiles and undo history set backupdir=~/.vim/backups set directory=~/.vim/swaps if exists("&undodir") set undodir=~/.vim/undo endif " Don’t create backups when editing files in certain directories set backupskip=/tmp/*,/private/tmp/* " Respect modeline in files set modeline set modelines=4 " Enable per-directory .vimrc files and disable unsafe commands in them set exrc set secure " Enable line numbers set number " Highlight current line set cursorline " Make tabs as wide as two spaces set tabstop=2 " Show “invisible” characters set lcs=tab:▸\ ,trail:·,eol:¬,nbsp:_ set list " Highlight searches set hlsearch " Ignore case of searches set ignorecase " Highlight dynamically as pattern is typed set incsearch " Always show status line set laststatus=2 " Enable mouse in all modes set mouse=a " Disable error bells set noerrorbells " Don’t reset cursor to start of line when moving around. set nostartofline " Show the cursor position set ruler " Don’t show the intro message when starting Vim set shortmess=atI " Show the current mode set showmode " Show the filename in the window titlebar set title " Show the (partial) command as it’s being typed set showcmd " Use relative line numbers if exists("&relativenumber") set relativenumber au BufReadPost * set relativenumber endif " Start scrolling three lines before the horizontal window border set scrolloff=3 " Force the cursor onto a new line after 80 characters set textwidth=80 " However, in Git commit messages, let’s make it 72 characters autocmd FileType gitcommit set textwidth=72 " Colour the 81st (or 73rd) column so that we don’t type over our limit set colorcolumn=+1 " In Git commit messages, also colour the 51st column (for titles) autocmd FileType gitcommit set colorcolumn+=51 " Strip trailing whitespace (,ss) function! StripWhitespace() let save_cursor = getpos(".") let old_query = getreg('/') :%s/\s\+$//e call setpos('.', save_cursor) call setreg('/', old_query) endfunction " Automatic commands if has("autocmd") " Enable file type detection filetype on filetype plugin indent on " Treat .json files as .js autocmd BufNewFile,BufRead *.json setfiletype json syntax=javascript " Treat .md files as Markdown autocmd BufNewFile,BufRead *.md setlocal filetype=markdown endif " Change mapleader let mapleader="," nnoremap b :CtrlPBuffer nnoremap d :NERDTreeToggle nnoremap f :NERDTreeFind nnoremap t :CtrlP nnoremap T :CtrlPClearCache:CtrlP noremap :call StripWhitespace() " Save a file as root (,W) noremap W :w !sudo tee % > /dev/null " plugin settings let g:ctrlp_match_window = 'order:ttb,max:20' let g:NERDSpaceDelims=1 " Local config if filereadable(expand("~/.vimrc.local")) " In your .vimrc.local, you might like: " " set autowrite " set nocursorline " set nowritebackup " set whichwrap+=<,>,h,l,[,] " Wrap arrow keys between lines " " autocmd! bufwritepost .vimrc source ~/.vimrc " noremap! jj source ~/.vimrc.local endif