vimrc / .vimrc

" An example for a vimrc file.
" Maintainer:	Bram Moolenaar <>
" Last change:	2006 Aug 12
" To use it, copy it to
"     for Unix and OS/2:  ~/.vimrc
"	      for Amiga:  s:.vimrc
"  for MS-DOS and Win32:  $VIM\_vimrc
"	    for OpenVMS:  sys$login:.vimrc

" When started as "evim", evim.vim will already have done these settings.
if v:progname =~? "evim"

" Use Vim settings, rather then Vi settings (much better!).
" This must be first, because it changes other options as a side effect.
set nocompatible

" allow backspacing over everything in insert mode
set backspace=indent,eol,start

if has("vms")
  set nobackup		" do not keep a backup file, use versions instead
  set backup		" keep a backup file
set history=50		" keep 50 lines of command line history
set ruler		" show the cursor position all the time
set showcmd		" display incomplete commands
set incsearch		" do incremental searching

" For Win32 GUI: remove 't' flag from 'guioptions': no tearoff menu entries
" let &guioptions = substitute(&guioptions, "t", "", "g")

" Don't use Ex mode, use Q for formatting
map Q gq

" In an xterm the mouse should work quite well, thus enable it.
" Can cause problems with screen in older versions of VIM 7, so disable it 
" if you like to use screen.  (You should.)
"set mouse=a

" This is an alternative that also works in block mode, but the deleted
" text is lost and it only works for putting the current register.
"vnoremap p "_dp

" Switch syntax highlighting on, when the terminal has colors
" Also switch on highlighting the last used search pattern.
if &t_Co > 2 || has("gui_running")
  syntax on
  set hlsearch

" Only do this part when compiled with support for autocommands.
if has("autocmd")

  " Enable file type detection.
  " Use the default filetype settings, so that mail gets 'tw' set to 72,
  " 'cindent' is on in C files, etc.
  " Also load indent files, to automatically do language-dependent indenting.
  filetype plugin indent on

  " Put these in an autocmd group, so that we can delete them easily.
  augroup vimrcEx

  " For all text files set 'textwidth' to 78 characters.
  autocmd FileType text setlocal textwidth=78

  " When editing a file, always jump to the last known cursor position.
  " Don't do it when the position is invalid or when inside an event handler
  " (happens when dropping a file on gvim).
  autocmd BufReadPost *
    \ if line("'\"") > 0 && line("'\"") <= line("$") |
    \   exe "normal g`\"" |
    \ endif

  augroup END


  set autoindent		" always set autoindenting on

endif " has("autocmd")

" Convenient command to see the difference between the current buffer and the
" file it was loaded from, thus the changes you made.
command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis
	 	\ | wincmd p | diffthis

" move all the swap files to a specific directory
" requires the directory to exist
" see comment by
" Chouser
set directory=~/.vim/swap//,.

" move all the backup files to a specific directory
" requires the directory to exist.
" see for more info
set backupdir=~/.vim/backup//,.

" set the color scheme to something I can actually see
color desert

" folding!!!
set foldmethod=indent

" vertical minibuf explorer
let g:miniBufExplVSplit = 20   " column width in chars

"yongan, 06/30/09
set dictionary+=/usr/share/dict/words

set nocompatible

set tabstop=2
set softtabstop=2
set shiftwidth=2
"set expandtab

set list!
set listchars=trail:-,tab:>-

set autoindent
set smartindent

set showmatch

"set laststatus

set number
set numberwidth=5

"set to auto read when a file is changed from the outside
set autoread

"highlight current
if has("gui_running")
    set cursorline
    hi cursorline guibg=#333333
    hi CursorColumn guibg=#333333

"Ignore case when searching
set ignorecase
set incsearch

function! SwitchToBuf(filename)
	"let fullfn = substitute(a:filename, "^\\~/", $HOME . "/", "")
	"find in current tab
	let bufwinnr = bufwinnr(a:filename)
	if bufwinnr != -1
		exec bufwinnr . "wincmd w"
		"find in each tab
		let tab = 1
		while tab <= tabpagenr("$")
			let bufwinnr = bufwinnr(a:filename)
			if bufwinnr != -1
				exec "normal" . tab . "gt"
				exec bufwinnr . "wincmd w"
			let tab = tab + 1
		"not exist, new tab
		exec "tabnew" . a:filename

"set mapleader
let mapleader = ","

"fasssssst reloading of the .vimrc
map <silent> <leader>ss :source ~/.vimrc<cr>
"fast editing of .vimrc
map <silent> <leader>ee :call SwitchToBuf("~/.vimrc")<cr>
"when .vimrc is edited, reload it
autocmd! bufwritepost .vimrc source ~/.vimrc