This doesn't include the 32 bundles I have installed in ~/.vim/bundle either.
" My Personal Vim settings
" Maintainer: Bryan Ross <bryanjamesross@gmail.com>
"
"
" Who wants compatible? Yuck...
"
set nocompatible
"
" Some default settings
"
set shiftwidth=2
set tabstop=2
set smarttab
set showtabline=1
set number
set cursorline
set encoding=utf-8
set scrolloff=5
set cindent
set smartindent
set autoindent
set expandtab
set nolist
set ignorecase
set smartcase
set wildmenu
set showmode
set incsearch
set hlsearch
set virtualedit=block
set nowrap
"
" Need to handle mac fileformats because of Flash, grrrr...
"
set ffs=unix,dos,mac
"
" Highlight dos files in red in status line
"
hi User9 term=reverse cterm=bold ctermbg=12 gui=bold guibg=Red
"
" Custom Status Line
"
set laststatus=2
set statusline=
set statusline+=%-3.3n
set statusline+=\[%{strlen(&ft)?&ft:'none'}]
set statusline+=\ %F
set statusline+=\ %9*%{&ff=='unix'?'':&ff.'\ format'}%*
set statusline+=%#warningmsg#
set statusline+=%{fugitive#statusline()}
set statusline+=%*
set statusline+=%=
set statusline+=0x%-8B
set statusline+=LINE\:\ %-6l\ CHAR\:\ %-6c\ COL\:\ %-6v
set statusline+=%<%P
"
" Syntastic
"
let g:syntastic_enable_signs=1
let g:syntastic_auto_loc_list=1
"
" Set height of command line, and show last cmd executed
"
set showcmd
set cmdheight=2
"
" Gah, can't stand these backup files. These lines disable them
"
set nobackup
set nowritebackup
set noswapfile
"
" Turn ~ into an operator (switch case)
"
set tildeop
"
" Enter key clears search
"
nnoremap <CR> :nohlsearch<CR>
"
" mapleader
"
let mapleader=","
"
" Pathogen!
"
runtime bundle/vim-pathogen/autoload/pathogen.vim
call pathogen#infect()
"
" Enable filetype indenting and plugins
"
filetype indent on
filetype plugin on
syntax on
set synmaxcol=3000
"
" Handle buffer switching
"
set switchbuf+=useopen
set switchbuf+=usetab
set hidden
"
" Fix Backspace
"
set backspace=indent,eol,start
"
" Map to set CWD to file being edited
"
map \lcd :lcd %:p:h<CR>
"
" Add a new line with Shift-Enter
"
nnoremap <silent><S-CR> <Esc>i<CR><Esc>
"
" Convenience mappings for running make and make clean
"
nmap <silent> \mm :wa<CR>:make<CR>
nmap <silent> \mc :wa<CR>:make clean<CR>
"
" Handle our gui settings
" - Font, color, size, etc...
"
if has("gui_running")
colorscheme ir_black
" basic sizing
set lines=50
" Gui options: hide scrolling, menubar, tabbar, etc
set guioptions=ehi
" Show only file name on tab
set guitablabel=%t
"
" Set font based on the type of gui we're using
"
if has("gui_gtk2")
if has("win32unix")
" Cygwin
set gfn=Consolas\ 11
else
" Linux, probably
set gfn=Source\ Code\ Pro\ 9
endif
elseif has("gui_win32")
" Win32/64 GVim
set gfn=Liberation_Mono:h8
" set gfn=Consolas:h10
set columns=160
set lines=65
elseif has("gui_macvim")
" MacVim
set gfn=Liberation\ Mono:h14
else
echo "Unknown GUI system!!!!"
endif
"
" Show or hide the menu bar with Control-F11
"
nmap <silent> <C-F11> :if &guioptions=~'m' \| set guioptions-=m \| else \| set guioptions+=m \| endif<CR>
"
" Disable the visual bell
"
set vb t_vb=
else
set t_Co=256
if &t_Co == 256
colorscheme ir_black
endif
endif
"
" Python Stuff
"
"
" Hide Bike Exceptions
"
let g:bike_exceptions = 0
"
" Highlight all python syntax items
"
let python_highlight_all = 1
"
" Runs the current buffer as python script, and sets the filetype of the
" buffer to be python
"
function! RunPythonBuffer()
pclose!
setlocal filetype=python
silent %y a | below new | silent put a | silent %!python -
setlocal previewwindow ro nomodifiable nomodified
winc p
endfunction
command! RunPyBuffer call RunPythonBuffer()
map \py :RunPyBuffer<cr>
"
" Buffer handling:
" Control-K goes to next buffer
" Control-J goes to previous buffer
" \ba Clears out up to 1000 buffers (probably overkill, but oh well)
" \bd Deletes the current buffer
"
nmap <silent> <C-j> :bprevious<cr>
nmap <silent> <C-k> :bnext<cr>
nmap <silent> \ba :1,1000bd!<cr>
nmap <silent> \bd :bd!<cr>
"
" Maps for ctrl-f (search) and ctrl-v (replace) in visual mode
"
function! GetVisual() range
let reg_save = getreg('"')
let regtype_save = getregtype('"')
let cb_save = &clipboard
set clipboard&
normal! ""gvy
let selection = escape(getreg('"'),'/\.*$^~[')
call setreg('"', reg_save, regtype_save)
let &clipboard = cb_save
return selection
endfunction
vmap <C-H> <Esc>:%s/<c-r>=GetVisual()<cr>/
vmap <C-F> <Esc>/<c-r>=GetVisual()<cr><cr>
"
" Trim Trailing spaces on save
"
function! FnTrimTrailing()
let savepos = getpos(".")
%s/\s\+$//g
nohl
call setpos(".", savepos)
endfunction
function! FnFileTypeTrim()
if &filetype != 'mkd'
call FnTrimTrailing()
endif
endfunction
command! TrimTrailing silent! call FnFileTypeTrim()
autocmd FileWritePre * :TrimTrailing
autocmd FileAppendPre * :TrimTrailing
autocmd FilterWritePre * :TrimTrailing
autocmd BufWritePre * :TrimTrailing
"
" Show trailing spaces
"
set listchars=tab:»·,trail:·
"
" Some customizations for ZenCoding
"
let g:user_zen_settings = {
\ 'php' : {
\ 'extends' : 'html',
\ 'filters' : 'c',
\ },
\ 'xml' : {
\ 'extends' : 'html',
\ },
\ 'mako' : {
\ 'extends' : 'html',
\ }
\}
"
" Convenience functions for handling leading tabs/spaces
"
command! -range=% -nargs=0 Tab2Space execute "silent! <line1>,<line2>s/^\\t\\+/\\=substitute(submatch(0), '\\t', repeat(' ', ".&ts."), 'g')" | nohls | redraw
command! -range=% -nargs=0 Space2Tab execute "silent! <line1>,<line2>s/^\\( \\{".&ts."\\}\\)\\+/\\=substitute(submatch(0), ' \\{".&ts."\\}', '\\t', 'g')" | nohls | redraw
"
" NERD_Commenter Defaults
"
let NERDSpaceDelims=1
"
" Use /* */ instead of // for PHP (personal preference)
"
let g:NERD_php_alt_style=1
"
" Map Control J/K to navigate command history
"
cmap <C-J> <Down>
cmap <C-K> <Up>
"
" Twiddle Case!
"
function! TwiddleCase(str)
if a:str ==# toupper(a:str)
let result = tolower(a:str)
elseif a:str ==# tolower(a:str)
let result = substitute(a:str,'\(\<\w\+\>\)', '\u\1', 'g')
else
let result = toupper(a:str)
endif
return result
endfunction
vnoremap <silent> ~ ygv"=TwiddleCase(@")<CR>Pgv
function! DoReformat(l1, l2)
execute a:l1.",".a:l2."g/./normal gqq"
nohlsearch
redraw
endfunction
command! -range=% -nargs=0 Reformat call DoReformat(<line1>, <line2>)
map <silent> \r :Reformat<CR>
" Hex mode
nnoremap <C-H> :Hexmode<CR>
inoremap <C-H> <Esc>:Hexmode<CR>
vnoremap <C-H> :<C-U>Hexmode<CR>
command -bar Hexmode call ToggleHex()
function! ToggleHex()
" hex mode should be considered a read-only operation
" save values for modified and read-only for restoration later,
" and clear the read-only flag for now
let l:modified=&mod
let l:oldreadonly=&readonly
let &readonly=0
let l:oldmodifiable=&modifiable
let &modifiable=1
if !exists("b:editHex") || !b:editHex
" save old options
let b:oldft=&ft
let b:oldbin=&bin
" set new options
setlocal binary " make sure it overrides any textwidth, etc.
let &ft="xxd"
" set status
let b:editHex=1
" switch to hex editor
%!xxd
else
" restore old options
let &ft=b:oldft
if !b:oldbin
setlocal nobinary
endif
" set status
let b:editHex=0
" return to normal editing
%!xxd -r
endif
" restore values for modified and read only state
let &mod=l:modified
let &readonly=l:oldreadonly
let &modifiable=l:oldmodifiable
endfunction
" autocmds to automatically enter hex mode and handle file writes properly
if has("autocmd")
" vim -b : edit binary using xxd-format!
augroup Binary
au!
" set binary option for all binary files before reading them
au BufReadPre *.bin,*.hex setlocal binary
" if on a fresh read the buffer variable is already set, it's wrong
au BufReadPost *
\ if exists('b:editHex') && b:editHex |
\ let b:editHex = 0 |
\ endif
" convert to hex on startup for binary files automatically
au BufReadPost *
\ if &binary | Hexmode | endif
" When the text is freed, the next time the buffer is made active it will
" re-read the text and thus not match the correct mode, we will need to
" convert it again if the buffer is again loaded.
au BufUnload *
\ if getbufvar(expand("<afile>"), 'editHex') == 1 |
\ call setbufvar(expand("<afile>"), 'editHex', 0) |
\ endif
" before writing a file when editing in hex mode, convert back to non-hex
au BufWritePre *
\ if exists("b:editHex") && b:editHex && &binary |
\ let oldro=&ro | let &ro=0 |
\ let oldma=&ma | let &ma=1 |
\ silent exe "%!xxd -r" |
\ let &ma=oldma | let &ro=oldro |
\ unlet oldma | unlet oldro |
\ endif
" after writing a binary file, if we're in hex mode, restore hex mode
au BufWritePost *
\ if exists("b:editHex") && b:editHex && &binary |
\ let oldro=&ro | let &ro=0 |
\ let oldma=&ma | let &ma=1 |
\ silent exe "%!xxd" |
\ exe "set nomod" |
\ let &ma=oldma | let &ro=oldro |
\ unlet oldma | unlet oldro |
\ endif
augroup END
endif