Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
" Scott's vimrc file
set autoindent " auto indent the next line when you hit enter
set backspace=2 " Backspace over everything in insert mode
set tabstop=4 " Tabs display as three spaces
set shiftwidth=4 " Shiftwidth is X for < and > moves
set softtabstop=4 " Soft tab stop
set noexpandtab " Don't expand tabs in insert mode
set ruler " Show what line/char you're on
set t_Co=256 " use 256 colors
set exrc " Enable reading .vimrc in the current dir to complement global one
set hlsearch " Highlight search results, <DEL> turns it off temporarily
set incsearch " Show the search WHILE you're typing it
"set smartcase ignorecase " case insensitive searches
set smartcase " case insensitive searches
syntax on " Turn on syntax highlighting
set background=dark
colorscheme distinguished
" Highlight uneeded whitespace
"highlight RedundantWhitespace ctermbg=red ctermfg=white guibg=red
"match RedundantWhitespace /\s\+$\|\t+$/
" Map K to the appropriate man page program depending on language
autocmd FileType perl setlocal keywordprg="perldoc -f"
autocmd FileType php setlocal keywordprg=pman
" Select the appropriate tags file, depending on the file type
autocmd Filetype php set tags+=~/tags/php.tags
autocmd Filetype perl set tags+=~/tags/perl.tags
autocmd Filetype javascript set tags+=~/tags/javascript.tags
" Force a syntax for .stpl files
autocmd BufNewFile,BufReadPost *.stpl set filetype=smarty
" Make brightscript files highlight as C++ files
autocmd BufNewFile,BufReadPost *.brs set filetype=cpp
" To restore the last cursor location
function! ResCur()
if line("'\"") <= line("$")
normal! g`"
return 1
endif
endfunction
augroup resCur
autocmd!
autocmd BufWinEnter * call ResCur()
augroup END
" Change the characters that are used when list is enabled
set listchars=tab:»·,trail:·,eol:¶,nbsp:·
" Treat $/@/% and word chars for diw
set iskeyword=@,48-57,_,192-255,\$,\@,\%
" Store swap files in ~/.vim/ so they don't pollute .
set directory=~/.vim/
""""""""""""""""""""""""
" Various key mappings "
""""""""""""""""""""""""
" Disable any highlighted searches
nmap <DEL> :nohlsearch<CR>
" Map the spacebar to save
nnoremap <Space> :w!<CR>
" Convert var_set() to get_in()
nnoremap , :.!~/nova-stuff/var_set_fix.pl<CR>
vnoremap , !~/nova-stuff/var_set_fix.pl<CR>
" This makes control-p toggle paste mode
"nmap <C-P> :set paste!<CR>
" Toggle list mode (show spaces/tabs)
nmap <C-L> :set list!<CR>
" Quit all (good for vimdiff)
nmap Q :qall!<CR>
" When you type / do /\v instead to use more "real" regexp searches
nmap / /\v
" Add better regexp replaces to search/replace
nmap s :%s/\v/g<LEFT><LEFT>
vmap s :s/\v/g<LEFT><LEFT>
" Map < > jump to most recent edits
nmap > g,
nmap < g;
" Map F4 to shell out and run ACK
"map <F4> # :!cd $RATS_BASE_PATH/.. ; ack <cword> ; cd $OLDPWD<Cr>
map <F4> :Ack <cword><CR>
" CTRL + O = covert tabs to four spaces
"nmap <C-O> :set softtabstop=4 tabstop=4 shiftwidth=4 expandtab<CR>:retab<CR>
nmap <C-O> :set expandtab!<CR>:retab<CR>
" Backspace cleans up trailing whitespace
nmap <BS> :%s/\v\s+$//g<CR>
" Make up/down work inside of wrapped lines
" http://vim.wikia.com/wiki/Move_through_wrapped_lines
imap <silent> <Down> <C-o>gj
imap <silent> <Up> <C-o>gk
nmap <silent> <Down> gj
nmap <silent> <Up> gk
" Override the default behavior for shift-up (page-up)
map <S-Up> <Up>
map <S-Down> <Down>
" Setup maps for di/ di| di* da% etc... "delete" "inside" "/" good for regexs
" http://www.reddit.com/r/vim/comments/1ya6y6/how_do_i_add_some_new_text_objects_so_i_can/
for char in [ '_', '.', ':', ',', ';', '<bar>', '/', '<bslash>', '*', '+', '%', '@' ]
execute 'omap i' . char . ' :<C-U>normal! T' . char . 'vt' . char . '<CR>'
execute 'omap a' . char . ' :<C-U>normal! F' . char . 'vf' . char . '<CR>'
endfor
" If you dd on an empty line, don't put it in the buffer
nnoremap <expr> dd match(getline('.'), '^\s*$') == -1 ? 'dd' : '"_dd'
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Make sure we're running in Vim mode (not vi mode)
" http://stackoverflow.com/questions/636721/how-to-detect-vi-not-vim-in-vimrc
if version >= 500
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Vundle Commands = :PluginUpdate / :PluginInstall / :PluginClean
" Vundle CLI = vim +PluginInstall +qall
filetype off " Required by Vundle, we enable it again later
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Enable EasyMotion
"Plugin 'Lokaltog/vim-easymotion'
Plugin 'wilywampa/vim-easymotion'
let g:EasyMotion_keys = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
" Tab is the EazyMotion search character
nmap <TAB> <Plug>(easymotion-s)
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Enable airline
Plugin 'bling/vim-airline'
" Always show the airline bar
set laststatus=2
" Don't check for mixed indent, lots of false positives
let g:airline#extensions#whitespace#checks = [ 'trailing' ]
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Smart Comments
Plugin 'ervandew/nerdcommenter'
" Comments should align at leftmost indent
let g:NERDDefaultAlign = 'left'
nmap C <Plug>NERDCommenterToggle
vmap C <Plug>NERDCommenterToggle
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" split/join arrays onto/from multiple lines
" gS and gJ respectively
Plugin 'AndrewRadev/splitjoin.vim'
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Auto-detect indent type spaces/tabs
"Plugin 'tpope/vim-sleuth'
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" map Ctrl + P to insert mode paste
Plugin 'tpope/vim-unimpaired'
nmap <C-P> <Plug>unimpairedPaste<CR>o
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Run a code linter on every save
Plugin 'tomtom/checksyntax_vim'
let g:checksyntax#auto_enable_rx = '.'
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" <Leader>k highlight word under cursor
Plugin 'vasconcelloslf/vim-interestingwords'
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Operate on function arguments
" di, = delete current argument
" <, = move argument to the left
"Plugin 'PeterRincker/vim-argumentative'
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
endif
" Properly indent code using the = key
" Has to be enabled AFTER Vundle
filetype plugin indent on
augroup CSS_EQALIGN
autocmd!
autocmd FileType css nmap <buffer><silent> - :call EQAS_Align('nmap', {'pattern':':'})<CR>
augroup END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment