" Do not try to be compatible with vi set nocompatible " Formatting for JSON files au FileType json setlocal equalprg=python\ -m\ json.tool if has("autocmd") " Clear existing autocmd autocmd! endif " Register plugins if filereadable(expand("~/dotfiles/vim/plugins.vim")) source ~/dotfiles/vim/plugins.vim endif filetype plugin indent on " Automatically detect file types. if has("autocmd") " Source the vimrc file after saving it autocmd BufWritePost .vimrc nested source $MYVIMRC endif """""""" "" Tabs and Text Formatting """""""""""""""""""""""""""""""""""""""""""""""""""""" syntax on " Syntax highlighting set nowrap set cursorline " Highlight current line set expandtab " convert tab characters into spaces set tabstop=2 " actual tab press distance set softtabstop=2 " let backspace delete by indents set shiftround " indent to nearest tabstops set shiftwidth=2 " amount to indent with > and < set smarttab " backspace tabs where appropriate even if spaces set textwidth=80 " try to keep text within 80 characters set colorcolumn=+1 " mark out the limits of the textwidth set hidden set mouse=a set nojoinspaces " Prevents inserting two spaces after punctuation on a join (J) set splitright " Puts new vsplit windows to the right of the current set splitbelow " Puts new split windows to the bottom of the current set backspace=indent,eol,start " Backspace for dummies set linespace=0 " No extra spaces between rows set number " Line numbers on set relativenumber set showmatch " Show matching brackets/parenthesis set incsearch " Find as you type search set hlsearch " Highlight search terms set winminheight=0 " Windows can be 0 line high set ignorecase " Case insensitive search set smartcase " Case sensitive when uc present set wildmenu " Show list instead of just completing set modeline " Support vim modelines at the top of files "set wildmode=list:longest,full " Command completion, list matches, then longest common part, then all. set whichwrap=b,s,h,l,<,>,[,] " Backspace and cursor keys wrap too set shortmess+=filmnrxoOtT " Abbrev. of messages (avoids 'hit enter') set scrolloff=5 " Minimum lines to keep above and below cursor set foldenable " Auto fold code set list set listchars=tab:›\ ,trail:•,extends:#,nbsp:. " Highlight problematic whitespace if has('persistent_undo') set undofile " So is persistent undo ... set undolevels=1000 " Maximum number of changes that can be undone set undoreload=10000 " Maximum number lines to save for undo on a buffer reload endif """""""" "" Key Remaps """""""""""""""""""""""""""""""""""""""""""""""""""""""" let mapleader = ',' " More convenient escape inoremap kj inoremap jk " Yank from the cursor to the end of the line, to be consistent with C and D. nnoremap Y y$ " Remap vim's 'increment next number' to since is used by tmux. nnoremap nnoremap w :set wrap! wrap? " Toggle paste mode - no autoindenting of pasted material nnoremap p :set paste! paste? " Toggle visible whitespace characters nnoremap l :set list! list? " Toggle scrollbind for moving multiple splits in sync together nnoremap s :set scrollbind! scrollbind? " Backspace to clear current search (and stop highlighting) nnoremap :call ClearSearch() function! ClearSearch() if (@/ != "") let @/="" redraw endif endfunction " Allow using the repeat operator with a visual selection (!) " http://stackoverflow.com/a/8064607/127816 vnoremap . :normal . """"""""" Source local scripts/plugins for filePath in split(globpath('~/dotfiles/vim/settings', '*.vim'), '\n') execute 'source' filePath endfor