set nocompatible
set t_Co=256
set background=dark
"set background=light
"colorscheme molokai
"colorscheme darkspectrum
colorscheme chela_light
set guifont=Envy_Code_B:h9
"----------------------------------------------------------------"
set autochdir
set fileformat=unix
set fileformats=unix,dos
set nocompatible
set backspace=indent,eol,start
syntax on
"----------------------------------------------------------------"
filetyp plugin indent on
"----------------------------------------------------------------"
set ruler " show the cursor position all the time
set showcmd " display incomplete commands
set incsearch nohlsearch " do incremental searching
set autoindent " always set autoindenting on
"----------------------------------------------------------------"
set go-=T " disable tabs
set go-=m " disable menu
set go-=L " disable left scrollbar
"set go-=r " disable right scrollbar
"----------------------------------------------------------------"
set encoding=utf8
try
lang en_US
catch
endtry
"----------------------------------------------------------------"
au BufRead,BufNewFile,BufNew,BufCreate set fileformat=unix
"----------------------------------------------------------------"
set foldcolumn=1
set nonu
set nohls
"----------------------------------------------------------------"
command! Bclose call <SID>BufcloseCloseIt()
function! <SID>BufcloseCloseIt()
let l:currentBufNum = bufnr("%")
let l:alternateBufNum = bufnr("#")
if buflisted(l:alternateBufNum)
buffer #
else
bnexc endif
if bufnr("%") == l:currentBufNum
new
endif
if buflisted(l:currentBufNum)
execute("bdelete! ".l:currentBufNum)
endif
endfunction
"----------------------------------------------------------------"
" Specify the behavior when switching between buffers
try
set switchbuf=usetab
set stal=1
catch
endtry
set nocp
"----------------------------------------------------------------"
" => General
"----------------------------------------------------------------"
set history=2000
set autoread
let mapleader = ","
let g:mapleader = ","
"----------------------------------------------------------------"
nmap <leader>r gg=Gg;
nmap <leader>u zc
nmap <leader>m zo
nmap J o<Esc>i
"----------------------------------------------------------------"
imap <c-f> <c-x><c-f>
"----------------------------------------------------------------"
map <leader>e :e! $VIM/_vimrc<cr>
autocmd! bufwritepost _vimrc source $VIM/_vimrc
"----------------------------------------------------------------"
" => VIM user interface
"----------------------------------------------------------------"
" Set 7 lines to the curors - when moving vertical..
set so=10
set wildmenu " Turn on WiLd menu
set ruler " Always show current position
set cmdheight=1 " The commandbar height
set hid " Change buffer - without saving
"----------------------------------------------------------------"
" Set backspace config
set backspace=eol,start,indent
set whichwrap+=<,>,h,l
set ignorecase " Ignore case when searching
set smartcase
set incsearch " Make search act like search in modern browsers
set nolazyredraw " Don't redraw while executing macros
set magic " Set magic on, for regular expressions
set showmatch " Show matching bracets when text indicator is over them
set mat=2 " How many tenths of a second to blink
"----------------------------------------------------------------"
" No sound on errors
set noerrorbells
set novisualbell
set t_vb=
set tm=500
"----------------------------------------------------------------"
" => Files, backups and undo
"----------------------------------------------------------------"
" Turn backup off, since most stuff is in SVN, git anyway...
set nobackup
set nowb
set noswapfile
"----------------------------------------------------------------"
"Persistent undo
try
if MySys() == "windows"
set undodir=C:\Windows\Temp
else
set undodir=~/.vim_runtime/undodir
endif
set undofile
catch
endtry
"----------------------------------------------------------------"
" => Text, tab and indent related
"----------------------------------------------------------------"
set expandtab
set shiftwidth=2
set tabstop=2
set smarttab
set lbr
set tw=500
set ai " Auto indent
set si " Smart indet
set wrap " Wrap lines
set linebreak
set nolist
set textwidth=0
set wrapmargin=0
"----------------------------------------------------------------"
" => Visual mode related
"----------------------------------------------------------------"
" Really useful!
" In visual mode when you press * or # to search for the current selection
vnoremap <silent> * :call VisualSearch('f')<CR>
vnoremap <silent> # :call VisualSearch('b')<CR>
"----------------------------------------------------------------"
" When you press gv you vimgrep after the selected text
vnoremap <silent> gv :call VisualSearch('gv')<CR>
"map <leader>2 :vimgrep // **/*.<left><left><left><left><left><left><left>
"----------------------------------------------------------------"
function! CmdLine(str)
exe "menu Foo.Bar :" . a:str
emenu Foo.Bar
unmenu Foo
endfunction
"----------------------------------------------------------------"
" From an idea by Michael Naumann
function! VisualSearch(direction) range
let l:saved_reg = @"
execute "normal! vgvy"
let l:pattern = escape(@", '\\/.*$^~[]')
let l:pattern = substitute(l:pattern, "\n$", "", "")
if a:direction == 'b'
execute "normal ?" . l:pattern . "^M"
elseif a:direction == 'gv'
call CmdLine("vimgrep " . '/'. l:pattern . '/' . ' **/*.')
elseif a:direction == 'f'
execute "normal /" . l:pattern . "^M"
endif
let @/ = l:pattern
let @" = l:saved_reg
endfunction
"----------------------------------------------------------------"
" => Moving around, tabs and buffers
"----------------------------------------------------------------"
" Map space to / (search) and c-space to ? (backwards search)
map <space> /
map <c-space> ?
map <silent> <leader><cr> :noh<cr>
"----------------------------------------------------------------"
" Smart way to move btw. windows
map <C-j> <C-W>j
map <C-k> <C-W>k
map <C-h> <C-W>h
map <C-l> <C-W>l
"----------------------------------------------------------------"
" Close the current buffer
map <leader>bd :bd<cr>
"----------------------------------------------------------------"
" Use the arrows to something usefull
map <leader>f :bn<cr>
map <leader>d :bp<cr>
"----------------------------------------------------------------"
" When pressing <leader>cd switch to the directory of the open buffer
map <leader>cd :cd %:p:h<cr>
"----------------------------------------------------------------"
" => Statusline
"----------------------------------------------------------------"
" Always hide the statusline
set laststatus=2
"----------------------------------------------------------------"
" Format the statusline
set statusline=\ Format:\ %{FileFormat()}\ \ %F%m%r%h\ %w\ \ CWD:\ %r%%h\ \ \ Line:\ %l/%L:%c
function! FileFormat()
return &fileformat
endfunction
"----------------------------------------------------------------"
function! HasPaste()
if &paste
return 'PASTE MODE '
else
return ''
endif
endfunction
"----------------------------------------------------------------"
if has('wildmenu')
set wildmenu
if has('menu')
if !has('gui_running')
runtime! menu.vim
endif
" override Ctrl-Z (minimize) by a text-mode menu
" we can still use :suspend for the original meaning
" of the key
set wildcharm=<C-T>
map <C-Z> :emenu <C-T>
imap <C-Z> <C-O>:emenu <C-T>
endif
endif
"----------------------------------------------------------------"
let g:user_zen_expandabbr_key = '<c-e>'
let g:use_zen_complete_tag = 1
"----------------------------------------------------------------"
set guicursor=a:blinkon0
"----------------------------------------------------------------"
" Tabularize Settings
if exists(":Tabularize")
nmap <leader>t vi}O<Esc><Esc>O<Esc>vi}:Tabularize /:\zs<cr>dd
vmap <leader>t <Esc>vi}O<Esc><Esc>O<Esc>vi}:Tabularize /:\zs<cr>dd
endif
"----------------------------------------------------------------"
" Colorscheming
" Show syntax highlighting groups for word under cursor
nmap <C-S-P> :call <SID>SynStack()<CR>
function! <SID>SynStack()
if !exists("*synstack")
return
endif
echo map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")')
endfunc
"----------------------------------------------------------------"
" Fix Movement Keys
nnoremap j gj
nnoremap k gk
vnoremap j gj
vnoremap k gk
"----------------------------------------------------------------"
" NERDTree controls
map <leader>t :NERDTreeToggle D:\Development\<cr>
let NERDTreeHijackNetrw = 0
let NERDTreeMouseMode = 2
let NERDTreeQuitOnOpen = 1
"----------------------------------------------------------------"
" Set Line To Title Case
map <leader>T :s/\<\(\w\)\(\w*\)\>/\u\1\L\2/g<cr>
"----------------------------------------------------------------"
" Splitting Commands
map <leader>vs :vsp<cr>
map <leader>s :sp<cr>
"----------------------------------------------------------------"
" Toggle spelling with the F7 key
nn <F7> :setlocal spell! spelllang=en_us<CR>
imap <F7> :setlocal spell! spelllang=en_us<CR>
"----------------------------------------------------------------"
" Set up spelling maps
map <leader>sf ]s
map <leader>sd [s
map <leader>sa zg
map <leader>ss z=
"----------------------------------------------------------------"
" Toggle menubar
map <F9> :set guioptions+=m<CR>:set guioptions+=T<CR>
map <F10> :set guioptions-=m<CR>:set guioptions-=T<CR>
"----------------------------------------------------------------"
" Insert time / date
nmap <F3> a<C-R>=strftime("%Y-%m-%d %a %I:%M %p")<CR><Esc>o<Esc>o
imap <F3> <C-R>=strftime("%Y-%m-%d %a %I:%M %p")<CR><Esc>o<Esc>o
"----------------------------------------------------------------"
" Open dialog
map <leader>g :bro e<CR>
"----------------------------------------------------------------"
" Save dialog
map <leader>b :bro w!<CR>
"----------------------------------------------------------------"
function! FoldColumn()
if &foldcolumn == 1
set foldcolumn=0
set nu
"normal mxggVG>g'x
elseif &foldcolumn == 0
set foldcolumn=1
set nonu
"normal mxggVG<g'x
endif
endfunction
map <leader>5 :call FoldColumn()<CR>
"----------------------------------------------------------------"
let g:html_indent_inctags = "html,body,head,tbody"
"----------------------------------------------------------------"
function PrintDate()
let l:date = strftime('%m.%d.%Y')
exe "normal i".l:date
return ''
endfunction
function PrintTime()
let l:date = strftime('%I:%M %p')
exe "normal i".l:date
return ''
endfunction
map <leader>4 :call PrintDate()<CR>i<End>
imap <leader>4 <C-R>=PrintDate()<CR><End>
map <leader>3 :call PrintTime()<CR>i<End>
imap <leader>3 <C-R>=PrintTime()<CR><End>
"----------------------------------------------------------------"
let VIMPRESS = [{'username':'ctruett',
\'password':'Ct14165!',
\'blog_url':'http://theywillknow.us/'
\}]
"----------------------------------------------------------------"
map <C-Y>/ <plug>NERDCommenterToggle
au BufRead,BufNewFile *.txt set nonu
au BufNewFile,BufRead *.chklst setf chklst
"----------------------------------------------------------------"
map <leader>we :BlogList<CR>
map <leader>wr :BlogOpen
map <leader>ww :BlogNew<CR>
map <leader>ws :BlogSave publish<CR>
"----------------------------------------------------------------"
map <leader>td :e $HOME\My\ Documents\todo.chklst<CR>
let g:checklist_use_timestamps = 0
set virtualedit=block
"-----------------------------------------------------------------
function! MakeStamp()
let time = strftime("%Y-%m-%d at %H:%M:%S")
let line = getline(1)
let match = '\d\{4}\-\d\{2}\-\d\{2} at \d\{2}:\d\{2}:\d\{2}'
if line =~ match
exe '1,1s/Last Modified: \zs'.match.'/'.time.'/i'
else
exe "normal ggOLast Modified: ".time
endif
return ""
endfunction
map <F3> :call MakeStamp()<CR>
"-----------------------------------------------------------------
set runtimepath+=$VIMRUNTIME/Ultisnips
"-----------------------------------------------------------------
function! ToggleColors()
if g:colors_name == "chela_light"
colo darkspectrum
elseif g:colors_name == "darkspectrum"
colo chela_light
endif
endfunction
map <F5> :call ToggleColors()<CR>
"-----------------------------------------------------------------
function! MyToHtml(line1, line2)
" delete unneeded lines
exec a:line1.','.a:line2.'TOhtml'
%g@<!DOCTYPE@d
%g@<html>@d
%g@</html>@d
%g@<body>@d
%g@</body>@d
%g@<title>@d
%g@<meta@d
%g@<head>@d
%g@</head>@d
%g@body {@d
%s/pre { /pre { padding:2px 6px; /g
endfunction
command! -range=% MyToHtml :call MyToHtml(<line1>,<line2>)
"----------------------------------------------------------------"
call pathogen#runtime_append_all_bundles()
"----------------------------------------------------------------"