Skip to content

Instantly share code, notes, and snippets.

@hoffstein
Created July 18, 2011 15:42
Show Gist options
  • Save hoffstein/1089899 to your computer and use it in GitHub Desktop.
Save hoffstein/1089899 to your computer and use it in GitHub Desktop.
My gvimrc
set nocompatible
set backspace=indent,eol,start
set nobackup
set mouse=a
set confirm
" Windows settings
source $VIMRUNTIME/mswin.vim
behave mswin
" Turn off bells and flashes
set noerrorbells
if has('autocmd')
autocmd GUIEnter * set vb t_vb=
endif
" Font and color scheme
"set gfn=Consolas:h10:cANSI
set gfn=Inconsolata:h10:cANSI
"colorscheme fruity
colorscheme wombat
" Detect filetype and use syntax highlighting
filetype on
filetype plugin on
syntax on
" Keep a bunch of command line history
set history=1000
" Save swap files centrally if possible
set dir=c:\\temp
" Show the cursor position and line numbers
set ruler
set number
" Show incomplete commands and enable wild menu
set showcmd
set wildmenu
set wildmode=list:longest
" Enable incremental search but don't highlight matches
set incsearch
set nohlsearch
" Key binding F2 to toggle search highlighting
map <silent> <F2> :set invhlsearch<CR>
" Smart case sensitivity
set ignorecase
set smartcase
" Use spaces instead of tabs
set shiftwidth=4
set tabstop=4
set softtabstop=4
set expandtab
"Enabled auto-indenting
set autoindent
set smartindent
filetype plugin indent on
" Hide toolbar and menubar
set guioptions-=T
set guioptions-=m
" Leave some space at the bottom
set scrolloff=2
" Show matching brace
set showmatch
" Use Windows clipboard
set clipboard+=unnamed
" Set default window size
set lines=50 columns=100
" Don't wrap lines
set nowrap
" Speed optimizations
set lz
set ttyfast
" Automatically set current directory to file's location
set autochdir
" Permit changing buffers without saving
set hidden
" Folding
set foldmethod=marker
" Show tabs and trailing spaces so I can remove them
set list
set listchars=tab:»·,trail:·
" Save/Reload session
set sessionoptions=blank,buffers,curdir,folds,help,resize,tabpages,winsize
nmap <silent> <leader>ss <Esc>:mksession! $VIM/.session<CR>
nmap <silent> <leader>ls <Esc>:source $VIM/.session<CR>
" NERDTree settings (launch with \nt or \\)
let g:NERDTreeQuitOnOpen = 1
nmap <silent> <leader>nt <Esc>:NERDTreeToggle<CR>
nmap <silent> <leader>\ <Esc>:NERDTreeToggle<CR>
" bufexplorer settings (launch with \be or \])
nmap <silent> <unique> <leader>] <Esc>:BufExplorer<CR>
" Tab navigation
nmap <silent> <C-t> :tabnew<CR>
nmap <silent> <C-j> gT
nmap <silent> <C-k> gt
nmap <silent> <C-h> :tabfirst<CR>
nmap <silent> <C-l> :tablast<CR>
nmap <silent> <leader>ta <Esc>:tab ball<CR>
" Split window navigation
nmap <c-down> <c-w>w
nmap <c-up> <c-w>W
nmap <c-left> <c-w>h
nmap <c-right> <c-w>l
" Undo in Insert mode (CTRL+Z)
map <c-z> <c-o>u
" Remap omni-completion to CTRL+SPACE
inoremap <C-space> <C-x><C-o>
" Most recently used file list settings
"let MRU_Max_Entries = 50
" Use SQL Server syntax file for .sql files
let g:sql_type_default = "sqlserver"
" Text wrapping (\w wraps to 80 characters)
nmap <silent> <leader>w <Esc>:set textwidth=80<CR><Esc>Vgggq<CR>
" Functions for cleaning up tabs and spaces
function! RemoveTrailingSpaces()
%s/\s\+$//e
%s/
//ge
endfunction
function! ConvertTabsToSpaces()
%retab
endfunction
function! CleanFile()
call ConvertTabsToSpaces()
call RemoveTrailingSpaces()
endfunction
" Key binding \f to clean up file
nmap <silent> <leader>f <Esc>:call CleanFile()<CR>
" Format of GUI tab label
function! GuiTabLabel()
" add the tab number
let label = '['.tabpagenr()
" modified since the last save?
let buflist = tabpagebuflist(v:lnum)
for bufnr in buflist
if getbufvar(bufnr, '&modified')
let label .= '*'
break
endif
endfor
" count number of open windows in the tab
let wincount = tabpagewinnr(v:lnum, '$')
if wincount > 1
let label .= ', '.wincount
endif
let label .= '] '
" add the file name without path information
let n = bufname(buflist[tabpagewinnr(v:lnum) - 1])
let label .= fnamemodify(n, ':t')
return label
endfunction
set guitablabel=%{GuiTabLabel()}
" Python-specific settings
autocmd BufRead *.py set smartindent cinwords=if,elif,else,for,while,try,except,finally,def,class
autocmd BufWritePre *.py normal m`:%s/\s\+$//e ``
autocmd BufRead *.py set makeprg=python\ -c\ \"import\ py_compile,sys;\ sys.stderr=sys.stdout;\ py_compile.compile(r'%')\"
autocmd BufRead *.py set efm=%C\ %.%#,%A\ \ File\ \"%f\"\\,\ line\ %l%.%#,%Z%[%^\ ]%\\@=%m
autocmd FileType python set omnifunc=pythoncomplete#Complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment