dotfiles / vimrc

set formatoptions=crqn
set tabstop=4
set softtabstop=4
set shiftwidth=4
set expandtab
set ignorecase
set smartcase
syntax enable 		" Turn on syntax hilighting
filetype on         " Enable filetype detection
filetype indent on  " Enable filetype-specific indenting
filetype plugin on  " Enable filetype-specific plugins
set autoindent
set nocompatible 	" Keep vim from trying to be 100% vi compatible
set backspace=indent,eol,start " Better backspacing
set t_kb=         " Fix backspace problems on some machines
fixdel
set ruler			" Vim will always tell me where she is
set lz              " Don't re-draw while running macros
set hid             " Can hide buffers without closing them
set shortmess=atI   " shortens messages to avoid 'press a key' prompt 
set matchtime=1
set scrolloff=3     " Always keep three lines above or below the cursor

set wildmenu    " Pretty command-line option matching
set wildignore=*.bak,*.o,*.e,*~,*.pyc
" Suffixes that get lower priority when doing tab completion for filenames.
" These are files we are not likely to want to edit or read.
set suffixes=.bak,~,.swp,.o,.info,.aux,.log,.dvi,.bbl,.blg,.brf,.cb,.ind,.idx,.ilg,.inx,.out,.toc,.class,.pyc
set tags=tags;/
set statusline=%f%m%r%h%w\ [%Y]\ [HEX=\%02.2B]%=Y=%04l,\ X=%04v\ %p%%\ of\ %L\ (buf\ %n)
set laststatus=2 " Always show status line

set foldmethod=marker

if has("autocmd")
	" Change to the directory the file in your current buffer is in
	autocmd BufEnter * :lcd %:p:h
	autocmd BufEnter * map <C-A> :!%:p
	autocmd BufEnter *.c map <C-X> :make
	autocmd BufEnter *.c map <C-A> :make run
	autocmd BufEnter *.c map <C-B> :!make debug
    autocmd BufEnter *.py map <C-A> :!python %
    autocmd BufEnter *.py set foldmethod=indent
    autocmd BufEnter *.html,*.htm,*.xml,*.js setlocal indentexpr= " Stop auto-indenting on HTMl
    autocmd BufEnter *.js setlocal nocin
    autocmd BufEnter *.js setlocal si
    autocmd BufEnter *.js setlocal ai
endif " has("autocmd")

let py_source = '\(Py3k-svn\|Python-trunk\)'
let path = expand('%:p:h')
if path =~ py_source
    let path = substitute(path, '\(.*/' . py_source . '\).*', '\1', '')
    execute('source ' . path . '/Misc/Vim/vimrc')
endif

" Make p in Visual mode replace the selected text with the "" register.
vnoremap p <Esc>:let current_reg = @"<CR>gvdi<C-R>=current_reg<CR><Esc>

noremap 0 ^
noremap ^ 0

set showcmd             " Show (partial) command in status line.
set showmatch           " Show matching brackets.
set incsearch           " Incremental search
set hlsearch		    " Hilight searches

nmap j gj
nmap k gk

" map c-o to new line below, then go back to normal, c-s-o to new line above and normal
map <C-O> ok
map � Oj

" NetRW stuff
let g:netrw_sort_sequence='[\/]$,*,\.bak$,\.o$,\.h$,\.info$,\.swp$,\.obj$,\.pyc$'
let g:netrw_keepdir=0
let g:netrw_browse_split=0

" map \ to nohlsearch
map \ :noh

" Some windowing convinience methods
map <c-h> <c-w>h
map <c-j> <c-w>j
map <c-k> <c-w>k
map <c-l> <c-w>l
map <c-@> <c-w>_
map <c-space> <c-w>_
map + <c-w>+
map - <c-w>-

map <right> :bn<return>
map <left> :bp<return>

map  :!gnome-terminal &<Enter><Enter>

map <F9> Oimport rpdb2; rpdb2.start_embedded_debugger("asdf") #BREAK
map <F8> Ofrom nose.tools import set_trace; set_trace() #BREAK
map <F7> Oimport traceback, sys; traceback.print_exception(*sys.exc_info()) #TRACEBACK

" Match braces just by white-bolding them, not making them cyan
hi MatchParen ctermbg=none ctermfg=white                                                                                                                             
" Make <c-_> source the closetag script then close the current tag
function! s:my_close_tag()
    if !exists("b:loaded_closetag")
        source ~/.vim/plugin/closetag.vim 
        " closetag will overwrite these mappings -- put them back in place
        inoremap <C-_> <C-R>=my_close_tag<CR>
        map <C-_> a<C-_><ESC>
    endif
    return GetCloseTag()         
endfunction
inoremap <C-_> <C-R>=my_close_tag<CR>
map <C-_> a<C-_><ESC>
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.