Skip to content
Go to file
Cannot retrieve contributors at this time
266 lines (238 sloc) 7.91 KB
" Load man.vim
runtime ftplugin/man.vim
colo flattened_light
" VI compatability is overrated
set nocompatible
syntax on
filetype plugin indent on
" Use the right goddamn keys
inoremap <Up> <NOP>
inoremap <Down> <NOP>
inoremap <Left> <NOP>
inoremap <Right> <NOP>
noremap <Up> <NOP>
noremap <Down> <NOP>
noremap <Left> <NOP>
noremap <Right> <NOP>
" Disable welcome message
set shortmess+=I
" Set default encoding
set encoding=utf-8
" Keep three lines of context when scrolling up/down
set scrolloff=3
" Easier to see what line we're on. Seems to slow down vim? disabling for now.
" set cursorline
" Hopefully we're on a 'fast' tty
set ttyfast
" Automagically indent things
set smartindent
" Code folding for readability
set foldenable
set foldmethod=marker
" Tabs are two (spaces) wide
set shiftwidth=2
set tabstop=2
set softtabstop=2
" Round to multiples of shiftwidth when < or >ing
set shiftround
" Disable modelines for security reasons
set modelines=0
" Tabs insert spaces, not a tab character
set expandtab
set smarttab
" Make backspace not be retarded
set backspace=indent,eol,start
" Hide buffers on switching instead of abandoning them
set hidden
" Autoload hidden buffers on change
set autoread
" show tabs and EOL characters
set list
set listchars=tab:▸\ ,eol
" Split to right, not left
set splitright
" Tab completion
" set wildmode=list:longest,list:full
set wildignore+=*.o,*.obj,.git,*.rbc
" Change leader from \ to ,. Easier to hit
let mapleader = ","
" Always show a status line.
set laststatus=2
set statusline=%F%m%r%h " file, modified, ro, help tags
if v:version >= 703
set statusline+=%q " quickfix tag
set statusline+=\ [%{&ff}]%y " file format (dos/unix) and type
set statusline+=%#warningmsg#
set statusline+=%*
set statusline+=\ %=#%n " start right-align. buffer number
set statusline+=\ %l/%L,%c " lines/total, column
set statusline+=\ [%P] " percentage in file
" set statusline=%F%m%r%h%w\ [%{&ff}]%y\ %{fugitive#statusline()}\ %=#%n\ %l/%L,%c\ [%P]
" Shortcuts to navigate split windows
map <C-h> <C-w>h
map <C-j> <C-w>j
map <C-k> <C-w>k
map <C-l> <C-w>l
" Leader+w splits a new window to the left.
map <leader>w <C-w>v<C-w>l
" j and k go by actual line on the screen and not the entire wrapped line
nnoremap j gj
nnoremap k gk
" Write a file as root
cmap w!! w !sudo tee % >/dev/null
" use semicolon as colon. one less keystroke
nnoremap ; :
" Search options
" Ignore case when searching
set ignorecase
" Unless the search term has capital letters
set smartcase
" Global search and replace by default; use s/a/b/g to override
set gdefault
" Start searching as soon as text is typed
set incsearch
" Jump back to matching bracket briefly when closing one is inserted.
set showmatch
" Highlight search results. Can be annoying, so
set hlsearch
" leader+space will clear it.
"nnoremap <leader><space> :noh<cr>
" Use jj to exit insert mode. Should be fine as 2 js in a row never happens
" unless you're commenting your vimrc and you have this mapping in there.
inoremap jj <Esc>
" Wrap long lines
set wrap
" Lines longer than 80 chars are bad
set textwidth=79
set formatoptions=qrn1
" Backups
set backupdir=~/.vim/tmp/backup// " backups
set directory=~/.vim/tmp/swap// " swap files
set backup " enable backups
set backupskip=/tmp/*,/private/tmp/*,/var/folders/*
" lUseful if you're running in a console on linux. Breaks MacVim.
"set mouse=a
"set ttymouse=xterm
" Enable shiny new options in vim 7.3, if we're running vim 7.3
if v:version >= 703
" set colorcolumn=85 " Color bar to the left for visual
" representation of too-long lines
let g:usingRelNum = 1 " Used to toggle relnum on or off
let g:pasteMode = 0 " Used for paste mode
set relativenumber " Start with it on
set undofile " Persistent undo is awesome
set undodir=~/.vim/tmp/undo// " Don't clog working dir with undo files
func! SwitchNum() " Switch between relative and static number
if g:usingRelNum == 1
let g:usingRelNum = 0
set nu
let g:usingRelNum = 1
set rnu
func! PasteMode()
if g:pasteMode == 0
let g:pasteMode = 1
if g:usingRelNum == 1
setl norelativenumber
setl nonumber
setl nolist
let g:pasteMode = 0
if g:usingRelNum == 1
setl relativenumber
setl number
setl list
" Maps to call the switch function on the fly.
nmap <leader>n :call SwitchNum()<CR>
map <F6> :call SwitchNum()<CR>
imap <F6> <C-o>:call SwitchNum()<CR>
" Maps to toggle paste mode
nmap <leader>l :call PasteMode()<CR>
" If we don't have shiny new features, at least enable line numbers
set number
" Assorted keybindings
" VIM even has spell checking.
map <F8> :setlocal spell! spelllang=en_us<CR>
imap <F8> <C-o>:setlocal spell! spelllang=en_us<CR>
" Toggle paste mode to avoid auto-indent issues
set pastetoggle=<F2>
" Easier start/end of line
noremap H ^
noremap L g_
" Stop accidentally triggering help
inoremap <F1> <ESC>
nnoremap <F1> <ESC>
vnoremap <F1> <ESC>
" Un-wrap hard-wrapped text.
nnoremap <leader>q vipJ
" And the opposite
nnoremap <leader>Q gqap
" Re-indent the whole document.
nnoremap <leader>re G=gg
" find merge conflict markers
nmap <silent> <leader>fc <ESC>/\v^[<=>]{7}( .*\|$)<CR>
" cd to the directory of the currently open file
nmap <silent> <leader>cd :lcd %:h<CR>
" Stolen from Janus
" Remember last location in file
if has("autocmd")
au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$")
\| exe "normal g'\"" | endif
" Make vim useful-er as a text editor/markdown editor
function s:setupWrapping()
"set wrap
set wm=2
set textwidth=90
function s:setupMarkup()
call s:setupWrapping()
"map <buffer> <Leader>p :Hammer <CR>
nnoremap <leader>p :silent !open -a '%:p'<cr>:redraw!<cr>
" Clean up the QuickFix window
au FileType qf setlocal colorcolumn=0 nolist nocursorline nowrap
" I think this works. Set right spacing for VHDL files
au FileType vhdl setlocal shiftwidth=2 tabstop=2 softtabstop=2
au FileType verilog setlocal shiftwidth=2 tabstop=2 softtabstop=2
" Move ftdetect stuff here instead of in runtime/ftdetect/meh
" md, markdown, and mk are markdown and define buffer-local preview
au BufRead,BufNewFile *.{md,markdown,mdown,mkd,mkdn} call s:setupMarkup()
au BufRead,BufNewFile *.txt call s:setupWrapping()
" Set format options for LaTeX as well (cribbed from the markdown syntax)
au BufRead,BufNewFile *.tex setlocal ft=tex formatoptions+=tcqln formatoptions-=r formatoptions-=o
" Set ruby filetype for Vagrantfiles and others
au BufRead,BufNewFile {Gemfile,Rakefile,Vagrantfile,Thorfile,Procfile,,*.rake} set ft=ruby
" Set AMPLE filetype for MGC AMPLE files
au BufRead,BufNewFile *.ample set filetype=ample
" conkyrc files
au BufNewFile,BufRead *conkyrc* set filetype=conkyrc
au BufNewFile,BufRead conky.conf set filetype=conkyrc
" tmux.conf
au BufNewFile,BufRead .tmux.conf*,tmux.conf* setf tmux
" nginx
au BufNewFile,BufRead *nginx*.conf setf nginx
" Makefiles like hardtabs
au FileType make setlocal noexpandtab
" Force all syntax highlighting for python
let python_highlight_all=1
" This should hilight conflict markers in vcs diffs
match ErrorMsg '^\(<\|=\|>\)\{7\}\([^=].\+\)\?$'
" Make the gutter less ugly
highlight clear SignColumn
" Complete options (disable preview scratch window)
set completeopt=menu,menuone,longest
" Limit popup menu height
set pumheight=15
set printoptions=number:y,left:2pc,right:2pc,paper:letter
You can’t perform that action at this time.