Skip to content

Instantly share code, notes, and snippets.

@csexton csexton/.vimrc
Created Apr 19, 2017

What would you like to do?
A not-too-opinionated version of my vimrc file's basic settings
" Plugins {{{
" A few plugis I like and recomend:
" # for scss
" }}}
" Settings {{{
syntax on
filetype plugin indent on
let mapleader = ","
set t_Co=256
silent! colorscheme spacemanspiff
set fillchars=vert:\ ,fold:-
"set nofoldenable " Disable code folding
set number " We need line numbers
set nowrap " Don't wrap lines
set cmdheight=1 " Command like height is forced to one line
set dictionary+=/usr/share/dict/words
set gdefault " When on, the ":substitute" flag 'g' is default on.
set guioptions=egmtc " Get rid of the scrollbar, toolbar, and popups
set hidden " Allow dirty unsaved buffers
set history=1000 " Remember more history
set hlsearch " Highlight searches
set ignorecase " Ignore case in searches.
set laststatus=2 " Always show status line
set list " show trailing whiteshace and tabs
set listchars=tab\ ,trail:\ ,extends:→,precedes:←,nbsp:‗ " Show whitespace glyphs
set modelines=5 " Debian likes to disable this
set mousemodel=popup " Right mouse button pops up a menu
set spelllang=en_us " Make vim speak 'merican
set suffixes+=.dvi " Lower priority in wildcards
set timeoutlen=1200 " A little bit more time for macros
set virtualedit=block " Let the cursor go where there is nothing
set visualbell " No more ding sounds
set winwidth=80 " Keep vsplits at least 80 cols
set tabstop=2 softtabstop=0 expandtab shiftwidth=2 smarttab " Indent settings for things not set by the file type
" Wildmenu completion
set wildmenu
set wildmode=list:longest
set wildmode=longest:full,full
set wildignore+=*~
set wildignore+=.hg,.git,.svn " Version control
set wildignore+=*.aux,*.out,*.toc " LaTeX intermediate files
set wildignore+=*.jpg,*.bmp,*.gif,*.png,*.jpeg " binary images
set wildignore+=*.o,*.obj,*.exe,*.dll,*.manifest " compiled object files
set wildignore+=*.spl " compiled spelling word lists
set wildignore+=*.sw? " Vim swap files
set wildignore+=*.DS_Store " OS X silliness
set wildignore+=*.luac " Lua byte code
set wildignore+=migrations " Django migrations
set wildignore+=*.pyc " Python byte code
set wildignore+=*.orig " Merge resolution files
set wildignore+=./vendor/bundle/ruby/*
" Backups
set noswapfile " It's 2012, Vim.
set backupskip=/tmp/*,/private/tmp/*" " Make Vim able to edit crontab files again.
set backupskip+=*.tmp,crontab.*
" Persistant Undo
if has('persistent_undo')
set undodir=~/.vim/undo
set undofile
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
augroup settings
autocmd BufNewFile,BufRead *.md,*.markdown set ft=markdown
autocmd BufNewFile,BufRead *.haml,*.jst set ft=haml
autocmd BufNewFile,BufRead *.slim set ft=slim
autocmd BufNewFile,BufRead *.feature,*.story set ft=cucumber
autocmd BufNewFile,BufRead *.coffee setl foldmethod=indent nofoldenable
autocmd FileType javascript,coffee setlocal et sw=2 sts=2 isk+=$
autocmd FileType html,xhtml,css,scss,scss.css setlocal et sw=2 sts=2 isk+=-
autocmd FileType eruby,yaml,ruby setlocal et sw=2 sts=2
autocmd FileType cucumber setlocal et sw=2 sts=2
autocmd FileType gitcommit setlocal spell
autocmd FileType gitconfig setlocal noet sw=8 sts=8 tabstop=8
autocmd FileType ruby setlocal comments=:#\ tw=79
autocmd FileType vim setlocal et sw=2 sts=2 keywordprg=:help
autocmd FileType python setlocal sts=4 ts=4 sw=4 textwidth=79
autocmd FileType c setlocal et sw=2 sts=2
autocmd FileType objc,objcpp setlocal et sw=4 sts=4
autocmd FileType sh,zsh setlocal et sw=2 sts=2 ff=unix
autocmd FileType make setlocal noet ts=8 sw=8 sts=0
autocmd FileType markdown setlocal linebreak formatoptions=1 breakat=\ @-+;:,./?^I wrap nolist textwidth=0 wrapmargin=0 fo-=t
" Omni completion.
autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS
autocmd FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags
autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS
autocmd FileType python setlocal omnifunc=pythoncomplete#Complete
autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags
autocmd FileType ruby set omnifunc=rubycomplete#Complete
autocmd FileType ruby let g:rubycomplete_buffer_loading=1
autocmd FileType ruby let g:rubycomplete_classes_in_global=1
autocmd FileType ruby imap <C-l> <Space>=><Space>
autocmd BufEnter *.rb syn match error contained "\<binding.pry\>"
autocmd BufEnter *.rb syn match error contained "\<debugger\>"
autocmd BufEnter *.rb syn match error contained "\<byebug\>"
autocmd BufEnter *.coffee syn match error contained "\<debugger\>"
augroup END
" }}}
" Mappings {{{
nnoremap j gj
nnoremap k gk
inoremap <C-C> <Esc>`^
cnoremap <C-O> <Up>
inoremap <M-o> <C-O>o
inoremap <C-X><C-@> <C-A>
cnoremap %% <C-R>=expand('%:h').'/'<cr>
vnoremap <M-y> "+y
nnoremap <silent> <C-L> :nohlsearch<CR><C-l>
" Sacrilege: emacs like bindings in command and insert
inoremap <C-A> <C-O>^
cnoremap <C-A> <Home>
cnoremap <C-X><C-A> <C-A>
cnoremap <C-P> <Up>
cnoremap <C-N> <Down>
inoremap <C-k> <C-O>D
cnoremap <C-k> <C-\>e getcmdpos() == 1 ? '' : getcmdline()[:getcmdpos()-2]<CR>
" }}}
" vim: set foldenable fdm=marker fmr={{{,}}}:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.