Created
September 23, 2012 15:40
-
-
Save ajankovic/3772072 to your computer and use it in GitHub Desktop.
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
" General "{{{ | |
set encoding=UTF-8 | |
set nocompatible " be iMproved | |
set history=256 " Number of things to remember in history. | |
set timeoutlen=250 " Time to wait after ESC (default causes an annoying delay) | |
set clipboard+=unnamed " Yanks go on clipboard instead. | |
set pastetoggle=<F10> " toggle between paste and normal: for 'safer' pasting from keyboard | |
set shiftround " round indent to multiple of 'shiftwidth' | |
set tags=./tags;$HOME " walk directory tree upto $HOME looking for tags | |
set modeline | |
set modelines=5 " default numbers of lines to read for modeline instructions | |
set autowrite " Writes on make/shell commands | |
set autoread | |
set nobackup | |
set nowritebackup | |
set directory=/tmp// " prepend(^=) $HOME/.tmp/ to default path; use full path as backup filename(//) | |
set noswapfile " | |
set hidden " The current buffer can be put to the background without writing to disk | |
set hlsearch " highlight search | |
set ignorecase " be case insensitive when searching | |
set smartcase " be case sensitive when input has a capital letter | |
if has('win32') | |
else | |
set wildignorecase " be case insensitive for file completition | |
endif | |
set incsearch " show matches while typing | |
let g:is_posix = 1 " vim's default is archaic bourne shell, bring it up to the 90s | |
let mapleader = ',' | |
let maplocalleader = ' ' " Tab as a local leader | |
" "}}} | |
" Formatting "{{{ | |
set fo+=o " Automatically insert the current comment leader after hitting 'o' or 'O' in Normal mode. | |
set fo-=r " Do not automatically insert a comment leader after an enter | |
" set fo-=t " Do no auto-wrap text using textwidth (does not apply to comments) | |
set formatoptions+=w | |
set wrap | |
set textwidth=80 " Don't wrap lines by default | |
set tabstop=4 " tab size eql 2 spaces | |
set softtabstop=4 | |
set shiftwidth=4 " default shift width for indents | |
set expandtab " replace tabs with ${tabstop} spaces | |
set smarttab " | |
set backspace=indent | |
set backspace+=eol | |
set backspace+=start | |
set autoindent | |
set cindent | |
set indentkeys-=0# " do not break indent on # | |
set cinkeys-=0# | |
set cinoptions=:s,ps,ts,cs | |
set cinwords=if,else,while,do | |
set cinwords+=for,switch,case | |
" "}}} | |
" Visual "{{{ | |
syntax on " enable syntax | |
" set synmaxcol=250 " limit syntax highlighting to 128 columns | |
set mouse=a "enable mouse in GUI mode | |
set mousehide " Hide mouse after chars typed | |
set number " line numbers Off | |
set showmatch " Show matching brackets. | |
set matchtime=2 " Bracket blinking. | |
set wildmode=longest,list " At command line, complete longest common string, then list alternatives. | |
set completeopt+=preview | |
set novisualbell " No blinking | |
set noerrorbells " No noise. | |
set vb t_vb= " disable any beeps or flashes on error | |
set laststatus=2 " always show status line. | |
set shortmess=atI " shortens messages | |
set showcmd " display an incomplete command in statusline | |
set scrolloff=10 | |
set statusline=%<%f\ " custom statusline | |
set stl+=[%{&ff}] " show fileformat | |
set stl+=%y%m%r%= | |
set stl+=%-14.(%l,%c%V%)\ %P | |
set foldenable " Turn on folding | |
set foldmethod=marker " Fold on the marker | |
set foldlevel=100 " Don't autofold anything (but I can still fold manually) | |
set foldopen=block,hor,tag " what movements open folds | |
set foldopen+=percent,mark | |
set foldopen+=quickfix | |
set virtualedit=block | |
set colorcolumn=80 | |
set textwidth=80 | |
set splitbelow | |
set splitright | |
set list " display unprintable characters f12 - switches | |
set listchars=tab:\ ·,eol:¬ | |
set listchars+=trail:· | |
set listchars+=extends:»,precedes:« | |
map <silent> <F12> :set invlist<CR> | |
if has('gui_running') | |
set guioptions=cMg " console dialogs, do not show menu and toolbar | |
if has("gui_gtk2") | |
set guifont=Inconsolata\ 11 | |
set columns=170 | |
set lines=40 | |
elseif has("gui_win32") | |
set guifont=Consolas:h11:cANSI | |
au GUIEnter * simalt ~x | |
endif | |
endif | |
" "}}} | |
nnoremap j gj | |
nnoremap k gk | |
xnoremap j gj | |
xnoremap k gk | |
nnoremap <leader>z :Vexplore %:p:h<CR> | |
" Key mappings " {{{ | |
" Duplication | |
nnoremap <leader>c mz"dyy"dp`z | |
vnoremap <leader>c "dymz"dP`z | |
nnoremap <leader>rs :source ~/.vimrc<CR> | |
nnoremap <leader>rt :tabnew ~/.vim/vimrc<CR> | |
nnoremap <leader>re :e ~/.vim/vimrc<CR> | |
nnoremap <leader>rd :e ~/.vim/ <CR> | |
if has('win32') | |
nnoremap <leader>rs :source ~/_vimrc<CR> | |
nnoremap <leader>rt :tabnew ~/vimfiles/vimrc<CR> | |
nnoremap <leader>re :e ~/vimfiles/vimrc<CR> | |
nnoremap <leader>rd :e ~/vimfiles/ <CR> | |
endif | |
" Tabs | |
nnoremap <M-h> :tabprev<CR> | |
nnoremap <M-l> :tabnext<CR> | |
" Esc | |
noremap <leader><leader> <Esc> | |
noremap <localleader><space> <Esc> | |
" noremap <Esc> <NOP> | |
" Buffers | |
nnoremap <localleader>- :bd<CR> | |
nnoremap <localleader>-- :bd!<CR> | |
" Split line(opposite to S-J joining line) | |
nnoremap <C-J> gEa<CR><ESC>ew | |
" map <silent> <C-W>v :vnew<CR> | |
" map <silent> <C-W>s :snew<CR> | |
" copy filename | |
map <silent> <leader>. :let @+=expand('%:p').':'.line('.')<CR> | |
" copy path | |
map <silent> <leader>/ :let @+=expand('%:p:h')<CR> | |
map <S-CR> A<CR><ESC> | |
map <leader>E :Explore<CR> | |
map <leader>EE :Vexplore!<CR><C-W>= | |
map <leader>q :q<CR> | |
" Make Control-direction switch between windows (like C-W h, etc) | |
nmap <silent> <C-k> <C-W><C-k> | |
nmap <silent> <C-j> <C-W><C-j> | |
nmap <silent> <C-h> <C-W><C-h> | |
nmap <silent> <C-l> <C-W><C-l> | |
nmap <silent> <leader><SPACE> :silent :nohlsearch<CR> | |
" Escape special characters in a string for exact matching. | |
" This is useful to copying strings from the file to the search tool | |
" Based on this - http://peterodding.com/code/vim/profile/autoload/xolox/escape.vim | |
function! EscapeString (string) | |
let string=a:string | |
" Escape regex characters | |
let string = escape(string, '^$.*\/~[]') | |
" Escape the line endings | |
let string = substitute(string, '\n', '\\n', 'g') | |
return string | |
endfunction | |
" Get the current visual block for search and replaces | |
" This test passed the visual block through a string escape test | |
" Based on this - http://stackoverflow.com/questions/676600/vim-replace-selected-text/677918#677918 | |
function! GetVisual() range | |
" Save the current register and clipboard | |
let reg_save = getreg('"') | |
let regtype_save = getregtype('"') | |
let cb_save = &clipboard | |
set clipboard& | |
" Put the current visual selection in the " register | |
normal! ""gvy | |
let selection = getreg('"') | |
" Put the saved registers and clipboards back | |
call setreg('"', reg_save, regtype_save) | |
let &clipboard = cb_save | |
"Escape any special characters in the selection | |
let escaped_selection = EscapeString(selection) | |
return escaped_selection | |
endfunction | |
" Start the find and replace command across the entire file | |
vnoremap <expr> <C-d> '<Esc>:%s/<c-r>=GetVisual()<cr>/'.input('Replace with:').'/cg<CR>' | |
nnoremap <expr> <C-d> ':%s/\<'.expand('<cword>').'\>/'.input('Replace with:').'/cg<CR>' | |
nnoremap <leader>v :vnew<CR> | |
" Control+S and Control+Q are flow-control characters: disable them in your terminal settings. | |
" $ stty -ixon -ixoff | |
noremap <C-S> :update<CR> | |
vnoremap <C-S> <C-C>:update<CR> | |
inoremap <C-S> <C-O>:update<CR> | |
" | |
" generate HTML version current buffer using current color scheme | |
map <leader>2h :runtime! syntax/2html.vim<CR> | |
ab #e # encoding: UTF-8 | |
" " }}} | |
" AutoCommands " {{{ | |
au BufRead,BufNewFile {Gemfile,Rakefile,Capfile,*.rake,config.ru} set ft=ruby tabstop=2 softtabstop=2 shiftwidth=2 expandtab smarttab | |
au BufRead,BufNewFile {*.md,*.mkd,*.markdown} set ft=markdown | |
au! BufReadPost {COMMIT_EDITMSG,*/COMMIT_EDITMSG} set ft=gitcommit noml list| norm 1G | |
au! BufWritePost *.snippet call ReloadAllSnippets() | |
" open help in vertical split | |
au BufWinEnter *.txt if &ft == 'help' | wincmd H | endif | |
" " }}} | |
" Scripts and Bundles " {{{ | |
filetype off | |
runtime macros/matchit.vim | |
if has('win32') | |
set rtp+=~/vimfiles/bundle/vundle/ | |
else | |
set rtp+=~/.vim/bundle/vundle/ | |
endif | |
call vundle#rc() | |
Bundle 'gmarik/vundle' | |
Bundle 'Townk/vim-autoclose' | |
Bundle 'edsono/vim-matchit' | |
" Colorscheme | |
Bundle 'molokai' | |
Bundle 'Wombat' | |
Bundle 'altercation/vim-colors-solarized' | |
colorscheme wombat | |
" Programming | |
Bundle 'jQuery' | |
" Snippets | |
Bundle 'gmarik/snipmate.vim' | |
Bundle 'honza/snipmate-snippets' | |
"TODO: extact my stuff | |
" Syntax highlight | |
Bundle 'gmarik/vim-markdown' | |
" Git integration | |
Bundle 'tpope/vim-git' | |
Bundle 'tpope/vim-fugitive' | |
nnoremap <leader>W :Gwrite<CR> | |
nnoremap <leader>C :Gcommit -v<CR> | |
nnoremap <leader>S :Gstatus \| 7<CR> | |
inoremap <leader>W <Esc><leader>W | |
inoremap <leader>C <Esc><leader>C | |
inoremap <leader>S <Esc><leader>S | |
Bundle 'tpope/vim-unimpaired' | |
" bubble current line | |
nmap <M-j> ]e | |
nmap <M-k> [e | |
" bubble visual selection lines | |
vmap <M-j> ]egv | |
vmap <M-k> [egv | |
" (HT|X)ml tool | |
Bundle 'ragtag.vim' | |
" Utility | |
Bundle 'michaeljsmith/vim-indent-object' | |
Bundle 'AndrewRadev/splitjoin.vim' | |
nmap sj :SplitjoinJoin<cr> | |
nmap sk :SplitjoinSplit<cr> | |
Bundle 'kana/vim-textobj-user' | |
Bundle 'gmarik/ide-popup.vim' | |
Bundle 'gmarik/sudo-gui.vim' | |
Bundle 'Gundo' | |
Bundle 'mkitt/browser-refresh.vim' | |
com! ONRRB :au! BufWritePost <buffer> :RRB | |
com! NORRB :au! BufWritePost <buffer> | |
Bundle 'repeat.vim' | |
Bundle 'surround.vim' | |
" Bundle 'SuperTab' | |
Bundle 'file-line' | |
Bundle 'Align' | |
Bundle 'lastpos.vim' | |
Bundle 'Lokaltog/vim-easymotion' | |
" let g:EasyMotion_leader_key='<Leader>' | |
Bundle 'Indent-Guides' | |
let g:indent_guides_guide_size = 1 | |
Bundle 'ZoomWin' | |
noremap <leader>o :ZoomWin<CR> | |
vnoremap <leader>o <C-C>:ZoomWin<CR> | |
inoremap <leader>o <C-O>:ZoomWin<CR> | |
Bundle 'tlib' | |
Bundle 'tComment' | |
nnoremap // :TComment<CR> | |
vnoremap // :TComment<CR> | |
Bundle 'gmarik/hlmatch.vim' | |
nnoremap # :<C-u>HlmCword<CR> | |
nnoremap <leader># :<C-u>HlmGrepCword<CR> | |
vnoremap # :<C-u>HlmVSel<CR> | |
vnoremap <leader># :<C-u>HlmGrepVSel<CR> | |
nnoremap ## :<C-u>HlmPartCword<CR> | |
nnoremap <leader>## :<C-u>HlmPartGrepCword<CR> | |
vnoremap ## :<C-u>HlmPartVSel<CR> | |
vnoremap <leader>## :<C-u>HlmPartGrepVSel<CR> | |
function! NumberToggle() | |
if(&relativenumber == 1) | |
set number | |
else | |
set relativenumber | |
endif | |
endfunc | |
nnoremap <C-g> :call NumberToggle()<cr> | |
" FuzzyFinder | |
Bundle 'L9' | |
Bundle 'FuzzyFinder' | |
" FuF customisations "{{{ | |
let g:fuf_modesDisable = [] | |
nnoremap <leader>h :FufHelp<CR> | |
nnoremap <leader>1 :FufTag<CR> | |
nnoremap <leader>2 :FufFileWithCurrentBufferDir<CR> | |
nnoremap <leader>@ :FufFile<CR> | |
nnoremap <leader>3 :FufBuffer<CR> | |
nnoremap <leader>4 :FufDirWithCurrentBufferDir<CR> | |
nnoremap <leader>$ :FufDir<CR> | |
nnoremap <leader>5 :FufChangeList<CR> | |
nnoremap <leader>6 :FufMruFile<CR> | |
nnoremap <leader>7 :FufLine<CR> | |
nnoremap <leader>9 :FufTaggedFile<CR> | |
" nnoremap <leader>p :FufDir ~/src/<CR> | |
" nnoremap <leader>gn :vnew \| :FufFile ~/src/notes/<CR> | |
" " }}} | |
" | |
Bundle 'kien/ctrlp.vim' | |
let g:ctrlp_map = '<leader>t' | |
let g:ctrlp_max_files = 50000 | |
" Bundle 'int3/vim-extradite' | |
Bundle 'Lokaltog/vim-powerline' | |
Bundle 'gregsexton/gitv' | |
Bundle 'thinca/vim-quickrun.git' | |
Bundle 'gh:thinca/vim-poslist.git' | |
Bundle 'mattn/webapi-vim' | |
Bundle 'github:mattn/gist-vim.git' | |
Bundle 'rstacruz/sparkup.git', {'rtp': 'vim/'} | |
Bundle 'vim-scripts/php.vim-html-enhanced' | |
Bundle 'ludovicPelle/vim-xdebug' | |
Bundle 'scrooloose/nerdtree' | |
nnoremap <leader>n :NERDTreeToggle<CR> | |
let NERDTreeChDirMode=2 | |
filetype plugin indent on " Automatically detect file types. | |
" " }}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment