Created
April 1, 2014 03:06
-
-
Save blockloop/9906968 to your computer and use it in GitHub Desktop.
.vimrc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" vim: se ff=unix : | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" => Variables | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
let $DBVIMRC = '~/Dropbox/configs/dotfiles/.vimrc' | |
let $DBGVIMRC = '~/Dropbox/configs/dotfiles/.gvimrc' | |
" Auto watch vimrc and reload it if it changes | |
augroup myvimrc | |
au! | |
au BufWritePost .vimrc,_vimrc,vimrc,.gvimrc,_gvimrc,gvimrc so $MYVIMRC | if has('gui_running') | so $MYGVIMRC | endif | |
augroup END | |
syntax on "this is needed to see syntax | |
filetype off " required! | |
" set runtime path for vundle | |
set rtp+=~/.vim/bundle/vundle/ | |
call vundle#rc() | |
Bundle "pangloss/vim-javascript" | |
Bundle "kchmck/vim-coffee-script" | |
Bundle "digitaltoad/vim-jade" | |
Bundle 'scrooloose/nerdtree' | |
Bundle 'tpope/vim-rails' | |
Bundle 'tpope/vim-commentary' | |
Bundle 'tpope/vim-rake' | |
Bundle 'snipMate' | |
Bundle 'bsh.vim' | |
Bundle 'OrangeT/vim-csharp' | |
Bundle 'Lokaltog/vim-distinguished' | |
Bundle 'surround.vim' | |
Bundle 'kien/ctrlp.vim' | |
Bundle 'Shutnik/jshint2.vim' | |
Bundle 'PProvost/vim-ps1' | |
Bundle 'gregsexton/MatchTag' | |
Bundle 'vim-scripts/VCard-syntax' | |
Bundle 'tpope/vim-liquid' | |
Bundle 'briancollins/vim-jst' | |
Bundle 'vim-stylus' | |
Bundle 'brettof86/vim-swigjs' | |
Bundle 'xmledit' | |
Bundle 'lunaru/vim-less' | |
Bundle 'plasticboy/vim-markdown' | |
Bundle 'jistr/vim-nerdtree-tabs' | |
" Bundle 'nosami/Omnisharp' | |
Bundle 'ervandew/supertab' | |
Bundle 'tpope/vim-dispatch' | |
Bundle 'mileszs/ack.vim' | |
Bundle 'sjl/gundo.vim' | |
" Bundle 'jamestomasino/vim-writeroom' | |
" Bundle 'marijnh/tern_for_vim' | |
" Bundle 'adamclerk/vim-razor' | |
colors | |
Bundle 'jnurmine/Zenburn' | |
Bundle 'altercation/vim-colors-solarized' | |
Bundle 'morhetz/gruvbox' | |
Bundle 'brettof86/vim-codeschool' | |
Bundle 'imsizon/wombat.vim' | |
filetype plugin indent on " required! | |
" NOTE: comments after Bundle command are not allowed.. e.g. Bundle 'user/project' " comment here | |
" colors twilight, codeschool, gruvbox, solarized | |
colorscheme gruvbox | |
" make auto complete work | |
autocmd FileType xml set omnifunc=xmlcomplete#CompleteTags noci | |
autocmd FileType html set omnifunc=htmlcomplete#CompleteTags noci | |
" F10 shows what highliting rule has applied at cursor | |
map <F10> :echo "hi<" . synIDattr(synID(line("."),col("."),1),"name") . '> trans<' | |
\ . synIDattr(synID(line("."),col("."),0),"name") . "> lo<" | |
\ . synIDattr(synIDtrans(synID(line("."),col("."),1)),"name") . ">"<CR> | |
" With a map leader it's possible to do extra key combinations | |
" like <leader>w saves the current file | |
let mapleader="," | |
let g:mapleader="," | |
" Fast saving | |
nmap <leader>w :w!<cr> | |
nmap <leader>q :q<cr> | |
nmap <leader>h :set hlsearch!<cr> | |
nmap <silent> <leader>t :NERDTreeTabsToggle<CR> | |
nmap <leader>l :NERDTreeFind<CR> | |
nmap <leader>n :tabnew | |
" make Y work like D and C | |
nmap Y y$ | |
" imap ii <Esc> | |
" reindent file | |
" ms saves cursor to 's'; `s goes to the 's' storage position; | |
" it seems like it moves down one row so add 'k' to go up one | |
nmap <c-k><c-d> msggVG=`sk<cr> | |
" start replace | |
map <leader>r :%s/ | |
vmap <leader>r :s/ | |
" Remap VIM 0 to first non-blank character | |
map 0 ^ | |
" tab movement | |
nnoremap th :tabfirst<CR> | |
nnoremap tj :tabprev<CR> | |
nnoremap tk :tabnext<CR> | |
nnoremap tl :tablast<CR> | |
" No annoying sound on errors | |
set noerrorbells | |
set novisualbell | |
set t_vb= | |
set tm=500 | |
" Turn backup off, since most stuff is in SVN, git etc anyway... | |
set nobackup | |
set nowb | |
set noswapfile | |
" Treat long lines as break lines (useful when moving around in them) | |
map j gj | |
map k gk | |
" Smart way to move between 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 | |
" Switch CWD to the directory of the open buffer | |
map <leader>cd :cd %:p:h<cr>:pwd<cr> | |
" Move a line of text using ALT+[jk] | |
nmap <M-j> mz:m+<cr>`z | |
nmap <M-k> mz:m-2<cr>`z | |
vmap <M-j> :m'>+<cr>`<my`>mzgv`yo`z | |
vmap <M-k> :m'<-2<cr>`>my`<mzgv`yo`z | |
" or Comamnd+[jk] on mac | |
if has("mac") || has("macunix") | |
nmap <D-j> <M-j> | |
nmap <D-k> <M-k> | |
vmap <D-j> <M-j> | |
vmap <D-k> <M-k> | |
endif | |
" ctrl space is autocomplete | |
imap <c-space> <c-x><c-]> | |
" gundo | |
nmap <leader>g :GundoToggle<cr> | |
" ###################################################################################### | |
" ################################## OMNISHARP ######################################### | |
" ###################################################################################### | |
" func! BindOmnisharp() | |
" if exists("g:OmniSharp_loaded") | |
" "Set the type lookup function to use the preview window instead of the status line | |
" let g:OmniSharp_typeLookupInPreview = 1 | |
" nnoremap <leader>od :OmniSharpGotoDefinition<cr> | |
" nnoremap <leader>oi :OmniSharpFindImplementations<cr> | |
" nnoremap <leader>ou :OmniSharpFindUsages<cr> | |
" nnoremap <leader>ob :OmniSharpBuildAsync<cr> | |
" nnoremap <leader>or :OmniSharpRename<cr> | |
" nnoremap <leader>of :OmniSharpGetCodeActions<cr> | |
" nnoremap <leader>oe :OmniSharpFindSyntaxErrors<cr> | |
" nnoremap <F5> :wa!<cr>:OmniSharpBuildAsync<cr> | |
" nnoremap <leader>fi :OmniSharpFindImplementations<cr> | |
" nnoremap <leader>ft :OmniSharpFindType<cr> | |
" nnoremap <leader>fs :OmniSharpFindSymbol<cr> | |
" nnoremap <leader>fm :OmniSharpFindMembersInBuffer<cr> | |
" nnoremap <leader>tt :OmniSharpTypeLookup<cr> | |
" " won't work if I'm using ctrl space for auto complete | |
" " nnoremap <space> :OmniSharpGetCodeActions<cr> | |
" endif | |
" endfunc | |
" autocmd BufRead,BufNewFile *.{cs,vb} :call BindOmnisharp() | |
" ###################################################################################### | |
" ################################## END OMNISHARP ##################################### | |
" ###################################################################################### | |
let g:neocomplcache_enable_at_startup = 1 | |
" Use smartcase. | |
let g:neocomplcache_enable_smart_case = 1 | |
" Use camel case completion. | |
let g:neocomplcache_enable_camel_case_completion = 1 | |
" Use underscore completion. | |
let g:neocomplcache_enable_underbar_completion = 1 | |
" Sets minimum char length of syntax keyword. | |
let g:neocomplcache_min_syntax_length = 0 | |
"////////////// functions | |
" Delete trailing white space on save, useful for Python and CoffeeScript ;) | |
func! DeleteTrailingWS() | |
exe "normal mz" | |
%s/\s\+$//ge | |
exe "normal `z" | |
endfunc | |
autocmd BufWrite *.coffee :call DeleteTrailingWS() | |
function! SetupWritingEnv() | |
set background=light | |
set spell | |
set foldenable | |
set lbr | |
set so=0 | |
if has("gui_gtk2") " linux | |
set guifont=Cousine\ 14 | |
else | |
set guifont=Cousine:h17 | |
end | |
endfunction | |
" open Marked.app preview for markdown | |
function! s:setupMarkup() | |
" nnoremap <leader>p :silent !open -a Marked.app '%:p'<cr> | |
nnoremap <leader>p :call SetupWritingEnv()<cr> | |
endfunction | |
au BufRead,BufNewFile *.{md,markdown,mdown,mkd,mkdn} call s:setupMarkup() | |
function! MarkdownLevel() | |
if getline(v:lnum) =~ '^# .*$' | |
return ">1" | |
endif | |
if getline(v:lnum) =~ '^## .*$' | |
return ">2" | |
endif | |
if getline(v:lnum) =~ '^### .*$' | |
return ">3" | |
endif | |
if getline(v:lnum) =~ '^#### .*$' | |
return ">4" | |
endif | |
if getline(v:lnum) =~ '^##### .*$' | |
return ">5" | |
endif | |
if getline(v:lnum) =~ '^###### .*$' | |
return ">6" | |
endif | |
return "=" | |
endfunction | |
au BufEnter *.{md,markdown,mdown,mkd,mkdn} setlocal foldexpr=MarkdownLevel() | |
au BufEnter *.{md,markdown,mdown,mkd,mkdn} setlocal foldmethod=expr | |
au BufEnter *.{md,markdown,mdown,mkd,mkdn} set syntax=mkd | |
" stay out of insert mode :) | |
inoremap <Left> <NOP> | |
inoremap <Right> <NOP> | |
inoremap <Up> <NOP> | |
inoremap <Down> <NOP> | |
" Remove the Windows ^M - when the encodings gets messed up | |
noremap <Leader>m mmHmt:%s/<C-V><cr>//ge<cr>'tzt'm | |
" open a NERDTree automatically when vim starts up if no files were specified | |
" autocmd vimenter * if !argc() | NERDTree | endif | |
let g:nerdtree_tabs_open_on_gui_startup=0 | |
" close vim if the only window left open is a NERDTree | |
" autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif | |
" highlight lines longer than 80 characters | |
" highlight OverLength ctermbg=gray ctermfg=white guibg=#333333 | |
" match OverLength /\%80v.\+/ | |
" Configure backspace so it acts as it should act | |
set backspace=eol,start,indent | |
set whichwrap+=<,>,h,l | |
" To enable the saving and restoring of screen positions. | |
let g:screen_size_restore_pos = 1 | |
" To save and restore screen for each Vim instance. | |
" This is useful if you routinely run more than one Vim instance. | |
" For all Vim to use the same settings, change this to 0. | |
let g:screen_size_by_vim_instance = 1 | |
" wild menu is awesome | |
set wildmenu | |
set wildignore+=*/tmp/*,*.zip,*node_modules*,bower_components,spendonlife/*/us | |
set background=dark "makes it easier to read with black background | |
" set ls=2 "allways show status line | |
set incsearch "do incremental searching | |
set nohlsearch "NO highlight searches | |
set ruler "show the cursor position all the time | |
set visualbell t_vb= "turn off error beep/flash | |
set ignorecase "ignore case while searching | |
" set number "put numbers on side | |
set nocompatible " be iMproved | |
set tabstop=2 | |
set softtabstop=2 | |
set shiftwidth=2 | |
set clipboard=unnamed | |
set autoindent | |
set ignorecase | |
set noexpandtab | |
" set autochdir | |
set scrolloff=15 | |
set autoread " Set to auto read when a file is changed from the outside | |
set smartcase " When searching try to be smart about cases | |
set lazyredraw " Don't redraw while executing macros (good performance config) | |
set magic " For regular expressions turn magic on | |
set showmatch " Show matching brackets when text indicator is over them | |
set mat=2 | |
set cursorline " highlight current line | |
set nofoldenable | |
" hide things from netrw | |
" comma delimited regex | |
let g:netrw_list_hide = "\.bak,\.git,^node_modules/" | |
" nerdtree | |
let NERDTreeIgnore = ['\.git$',"node_modules"] | |
let NERDTreeChDirMode=2 | |
let NERDTreeShowHidden=0 | |
" override ctrlp enter to open in new tab | |
let g:ctrlp_prompt_mappings = { | |
\ 'AcceptSelection("t")': ['<cr>', '<2-LeftMouse>'], | |
\ 'AcceptSelection("e")': ['<c-t>'] | |
\ } | |
let g:ctrlp_map = '<c-p>' | |
let g:ctrlp_cmd = 'CtrlP' | |
"""""" supertab | |
let g:SuperTabDefaultCompletionType = "<c-n>" | |
" autostart omnisharp | |
" let g:Omnisharp_start_server = 0 | |
" F9 saves and validates ruby when writing ruby code | |
autocmd FileType ruby map <F9> :w<CR>:!ruby -c %<CR> | |
autocmd FileType coffee set ts=2 sts=2 sw=2 | |
autocmd FileType jade set ts=2 sts=2 sw=2 | |
autocmd FileType javascript set ts=4 sts=4 sw=4 | |
" filetypes with 4 space indention | |
" au BufNewFile,BufRead *.vb,*.cs set ts=4 sts=4 sw=4 | |
au BufNewFile,BufRead *.md,*.markdown,*.mdown,*.mkd,*.mkdn setf mkd | |
au BufNewFile,BufRead *.iced setf coffee | |
au BufNewFile,BufRead *.cshtml setf html | |
inoremap kj <esc> | |
au FileType xml exe ":silent 1,$!xmllint --format --recover - 2>/dev/null" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment