Home of the Boogie-Woogie Feng Shui
.vimrc
Here is the .vimrc I have cobbled together by borrowing from other people. There is a good thread at Stack Overflow on what is in your .vimrc?. I just made this, so it is is not super well organized and there are probably repeated commands.
At some point I will put the file onto the Git repository I am setting up.
Complete text after the break…
"{{{Auto Commands
" Automatically cd into the directory that the file is in
autocmd BufEnter * execute "chdir ".escape(expand("%:p:h"), ' ')
" Remove any trailing whitespace that is in the file
autocmd BufRead,BufWrite * if ! &bin | silent! %s/\s\+$//ge | endif
" Restore cursor position to where it was before
augroup JumpCursorOnEdit
au!
autocmd BufReadPost *
\ if expand(":p:h") !=? $TEMP |
\ if line("'"") > 1 && line("'"") <= line("$") | \ let JumpCursorOnEdit_foo = line("'"") | \ let b:doopenfold = 1 | \ if (foldlevel(JumpCursorOnEdit_foo) > foldlevel(JumpCursorOnEdit_foo - 1)) |
\ let JumpCursorOnEdit_foo = JumpCursorOnEdit_foo - 1 |
\ let b:doopenfold = 2 |
\ endif |
\ exe JumpCursorOnEdit_foo |
\ endif |
\ endif
" Need to postpone using "zv" until after reading the modelines.
autocmd BufWinEnter *
\ if exists("b:doopenfold") |
\ exe "normal zv" |
\ if(b:doopenfold > 1) |
\ exe "+".1 |
\ endif |
\ unlet b:doopenfold |
\ endif
augroup END
"}}}
"{{{Misc Settings
" Necesary for lots of cool vim things
set nocompatible
" This shows what you are typing as a command. I love this!
set showcmd
" Folding Stuffs
set foldmethod=marker
" Needed for Syntax Highlighting and stuff
filetype on
filetype plugin on
syntax enable
set grepprg=grep\ -nH\ $*
" Who doesn't like autoindent?
set autoindent
" Spaces are better than a tab character
set expandtab
set smarttab
" Who wants an 8 character tab? Not me!
set shiftwidth=4
set softtabstop=4
" Use english for spellchecking, but don't spellcheck by default
if version >= 700
set spl=en spell
set nospell
endif
" Real men use gcc
"compiler gcc
" Cool tab completion stuff
set wildmenu
set wildmode=list:longest,full
" Enable mouse support in console
set mouse=a
" Got backspace?
set backspace=2
" Line Numbers PWN!
set number
" Ignoring case is a fun trick
set ignorecase
" And so is Artificial Intellegence!
set smartcase
" Incremental searching is sexy
set incsearch
" Highlight things that we find with the search
set hlsearch
" Since I use linux, I want this
let g:clipbrdDefaultReg = '+'
" When I close a tab, remove the buffer
set nohidden
" Set off the other paren
highlight MatchParen ctermbg=4
" }}}
"{{{Look and Feel
" Favorite Color Scheme
if has("gui_running")
colorscheme wombat
" Remove Toolbar
set guioptions-=T
"Terminus is AWESOME
set guifont=Terminus\ 9
else
colorscheme wombat
endif
"Status line gnarliness
set laststatus=2
set statusline=%F%m%r%h%w\ (%{&ff}){%Y}\ [%l,%v][%p%%]
" }}}
"{{{ Functions
"{{{ Open URL in browser
function! Browser ()
let line = getline (".")
let line = matchstr (line, "http[^ ]*")
exec "!chrome ".line
endfunction
"}}}
"}}}
"{{{ Mappings
" Open Url on this line with the browser \w
map w :call Browser ()
" Next Tab
nnoremap :tabnext
" Previous Tab
nnoremap :tabprevious
" New Tab
nnoremap :tabnew
" DOS is for fools.
nnoremap :%s/$//g:%s// /g
" Edit vimrc \ev
nnoremap ev :tabnew:e ~/.vimrc
" Edit gvimrc \gv
nnoremap gv :tabnew:e ~/.gvimrc
" Good call Benjie (r for i)
nnoremap i r
nnoremap a r
" Create Blank Newlines and stay in Normal mode
nnoremap zj o
nnoremap zk O
" Space will toggle folds!
nnoremap za
" Search mappings: These will make it so that going to the next one in a
" search will center on the line it's found in.
map N Nzz
map n nzz
"}}}
filetype plugin indent on
syntax on
set undofile
set undodir=/tmp
" make sure that max lines are displayed
" (80 and 120 are from ZF Coding standards)
set colorcolumn=80,120
" Turn off annoying error bells
set noerrorbells
set visualbell
set t_vb=
" Make cursor move as expected with wrapped lines:
inoremap gj
inoremap gk
" Lookup ctags "tags" file up the directory, until one is found:
set tags=tags;/
set showcmd " Show (partial) command in status line.
set showmatch " Show matching brackets.
set noautowrite " don't automagically write on :next
set scrolloff=5 " keep at least 5 lines above/below
set sidescrolloff=5 " keep at least 5 lines left/right
set backspace=indent,eol,start
set linebreak
set cmdheight=2 " command line two lines high
set undolevels=1000 " 1000 undos
set updatecount=100 " switch every 100 chars
set ttyfast " we have a fast terminal
set shell=bash
set fileformats=unix
set ff=unix
filetype on " Enable filetype detection
filetype indent on " Enable filetype-specific indenting
filetype plugin on " Enable filetype-specific plugins
set statusline=%2*%n\|%<%*%-.40F%2*\|\ %2*%M\ %3*%=%1*\ %1*%2.6l%2*x%1*%1.9(%c%V%)%2*[%1*%P%2*]%1*%2B
"{{{ Typo Fixes
:command WQ wq
:command Wq wq
:command W w
:command Q q
iab anf and
iab adn and
iab ans and
iab teh the
iab thre there
"}}}
imap ii
map :bprev " switch left tab
map :bnext " switch right tab
set hidden " this will go along