Created
June 23, 2014 14:38
-
-
Save vmeyet/dbb3e52717683d99e0d1 to your computer and use it in GitHub Desktop.
This file contains 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
scriptencoding utf-8 | |
set encoding=utf-8 | |
" {{{ settings | |
set nocompatible " Use Vim defaults instead of 100% vi compatibility | |
set backspace=indent,eol,start " more powerful backspacing | |
set autoindent " always set auto-indenting on | |
set hidden " allow to cycle and hide modified buffers | |
set nobackup " Don't keep a backup file | |
set esckeys " allow usage of curs keys within insert mode | |
set timeout | |
set ttimeoutlen=10 | |
set timeoutlen=10 " set timout for esc to 1ms | |
set listchars=eol:\ ,tab:\»\ ,trail:-,extends:>,precedes:< | |
set list | |
set joinspaces " insert two spaces after a period with every joining of lines. | |
" This is very nice! | |
set lazyredraw " [VIM5]; do not update screen while executing macros | |
set magic " Use some magic in search patterns? Certainly! | |
set modeline " Allow the last line to be a modeline - useful when | |
" the last line in sig gives the preferred text-width | |
" for replies. | |
set modelines=5 | |
set pastetoggle=<F4> | |
set nonumber | |
set report=0 " show a report when N lines were changed. | |
" report=0 thus means "show all changes"! | |
set laststatus=2 " show status line? Yes, always! | |
set noruler " show cursor position? Yep! | |
set statusline=<\ %f\ %r%y\ %=\ %l,%c%V\ \ %P\ > | |
set shiftwidth=4 " Number of spaces to use for each insertion of | |
" (auto)indent. | |
set shortmess=at " Kind of messages to show. Abbreviate them all! | |
" New since vim-5.0v: flag 'I' to suppress "intro message". | |
set scrolloff=0 " context | |
set noshowcmd " Show current uncompleted command? Absolutely! | |
set showmatch " Show the matching bracket for the last ')'? | |
set showmode " Show the current mode? YEEEEEEEEESSSSSSSSSSS! | |
set suffixes=.bak,~,.swp,.o,.info,.aux,.log,.dvi,.bbl,.blg,.brf,.cb,.ind,.idx,.ilg,.inx,.out,.toc,.cmi,.cmo | |
" Suffixes to ignore in file completion | |
set tabstop=4 " tabstop | |
set softtabstop=4 " sts | |
set expandtab " expand tabs | |
set notextmode " no - I am using Vim on UNIX! | |
set textwidth=0 " Don't wrap words by default | |
set notitle " Permet de voir le tit. du doc. crt. ds les XTERM | |
if version >= 700 | |
set viminfo='1000,/1000,:1000,<1000,@1000,n~/.viminfo | |
endif | |
set history=1000 | |
" What info to store from an editing session | |
" in the viminfo file; can be used at next session. | |
set sessionoptions-=blank | |
set sessionoptions-=folds | |
set ignorecase " Do case insensitive matching | |
set smartcase " use case-sensitive if a uppercas in the search | |
set incsearch " Incremental search | |
set hlsearch " hilight search | |
set whichwrap=<,>,[,] " | |
set wildchar=<TAB> " the char used for "expansion" on the command line | |
" default value is "<C-E>" but I prefer the tab key: | |
set wildmenu " Completion on the command line shows a menu | |
set winminheight=0 " Minimum height of VIM's windows opened | |
set mouse=a | |
set mousefocus | |
set wrapmargin=0 | |
set nowritebackup | |
set foldmethod=marker | |
set cpoptions-=C " enable commands that continue on the next line | |
" use ctrl-n ctrl-n instead of ctrl-x ctrl-k | |
set complete-=k complete+=k | |
set tags+=./.tags,.tags | |
set cinoptions= | |
set cinoptions+=,t0 " type on the line before the functions is not idented | |
set cinoptions+=,:2,=2 " indent case ...: of 2 from the switch { | |
set cinoptions+=,(0,W4 " indent in functions ( ... ) when it breaks | |
set cinoptions+=,g2,h2 " indent C++ scope of 2, and the members from 2 from it | |
"set cinoptions+=l1 " align closing brace with the case | |
"set cinoptions+=b1 " align break; with case ...: | |
set diffopt=filler,context:5,iwhite | |
set fillchars+=diff:\ | |
set makeprg=LC_ALL=C\ make | |
exe "set path=." . system("echo | cpp -v 2>&1 | grep '^ .*/include' | tr -d \"\n\" | tr \" \" \",\"") | |
autocmd BufWritePre * :%s/\s\+$//e | |
filetype indent off | |
" }}} | |
" {{{ vim 7 settings | |
if version >= 700 | |
set autochdir " autochdir... | |
set virtualedit=onemore " Yes I want to be able to be "on \n" | |
set spelllang=en_us,fr | |
set pumheight=16 | |
" make <enter> work in popup | |
" inoremap <cr> <C-R>=pumvisible() ? "\<lt>C-Y>" : "\<lt>cr>"<cr> | |
inoremap <expr> <CR> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>" | |
function! Len(str) | |
return len(a:str) | |
endfunction | |
else | |
au BufEnter * :lcd %:p:h | |
function! Len(str) | |
return strlen(a:str) | |
endfunction | |
endif | |
" }}} | |
" {{{ Window magic | |
function! DeleteBuffer() | |
let bid = bufnr("%") | |
bnext | |
exe "bdel " . bid | |
redraw | |
endfunction | |
map <C-W>d :call DeleteBuffer()<cr> | |
"map <C-W>k :bd<cr> | |
map <C-W>g :bo cw 8<cr> | |
" }}} | |
" {{{ Mappings | |
" {{{ Tab Key magic ... | |
vmap <tab> >gv | |
vmap <bs> <gv | |
function! TabAlign() | |
let col = col('.') | |
let lnum = line('.') | |
while lnum > 1 | |
let lnum = lnum - 1 | |
let ln = strpart(getline(lnum), col-1) | |
let ms = matchstr(ln, '[^ ]* *[^ ]') | |
if ms != "" | |
break | |
endif | |
endwhile | |
if lnum == 1 | |
return "\<Tab>" | |
else | |
let @z = substitute(strpart(ms, 0, strlen(ms)-1), '.', ' ', 'g') | |
if col > strlen(getline('.')) | |
return "\<C-O>\"zp" | |
else | |
return "\<C-O>\"zP" | |
endif | |
endif | |
endfunction | |
function! CleverTab() | |
let c = strpart(getline('.'), col('.')-2, 1) | |
if c == ' ' || c == '\t' || c == '' | |
return TabAlign() | |
else | |
return "\<C-P>" | |
endif | |
endfunction | |
"inoremap <Tab> <C-R>=CleverTab()<CR> | |
inoremap <S-Tab> <C-R>=TabAlign()<CR> | |
function! Smart_TabComplete() | |
let line = getline('.') " current line | |
let substr = strpart(line, -1, col('.')+1) " from the start of the current | |
" line to one character right | |
" of the cursor | |
let substr = matchstr(substr, "[^ \t]*$") " word till cursor | |
if (strlen(substr)==0) " nothing to match on empty string | |
return "\<tab>" | |
endif | |
let has_period = match(substr, '\.') != -1 " position of period, if any | |
let has_slash = match(substr, '\/') != -1 " position of slash, if any | |
if (!has_period && !has_slash) | |
return "\<C-X>\<C-P>" " existing text matching | |
elseif ( has_slash ) | |
return "\<C-X>\<C-F>" " file matching | |
else | |
return "\<C-X>\<C-O>" " plugin matching | |
endif | |
endfunction | |
inoremap <tab> <c-r>=Smart_TabComplete()<CR> | |
" }}} | |
map + :cn<cr> | |
map - :cp<cr> | |
map <kPlus> :cn<cr> | |
map <kMinus> :cp<cr> | |
map Q gq | |
nnoremap \l :setlocal number!<CR> | |
nnoremap \o :set paste!<CR> | |
noremap \e :NERDTreeToggle<CR> | |
noremap j gj | |
noremap k gk | |
noremap <F2> :set mouse=a<cr> | |
inoremap <F2> <esc>:set mouse=a<cr> | |
noremap <F3> :set mouse=h<cr> | |
inoremap <F3> <esc>:set mouse=h<cr> | |
noremap <F5> :source ~/.vimrc<cr> | |
inoremap <F6> <c-o>mzviwU`z | |
noremap <F7> :set ai!<CR>:set ai?<cr> | |
inoremap <F7> <space><esc><F7>a<bs> | |
noremap <F9> :bp<cr> | |
inoremap <F9> <esc>:bp<cr> | |
noremap <F10> :bn<cr> | |
inoremap <F10> <esc>:bn<cr> | |
noremap <F11> :make!<cr>:bo cw 8<cr><cr> | |
inoremap <F11> <esc>:make!<cr>:bo cw 8<cr><cr> | |
noremap <S-F11> :make clean<cr><cr> | |
inoremap <S-F11> <esc>:make clean<cr><cr> | |
cnoremap <C-a> <Home> | |
cnoremap <C-e> <End> | |
cnoremap <C-p> <Up> | |
cnoremap <C-n> <Down> | |
cnoremap <C-b> <Left> | |
cnoremap <C-f> <Right> | |
cnoremap <M-b> <S-Left> | |
cnoremap <M-f> <S-Right> | |
noremap <C-p> <esc>:Unite file_rec<cr> | |
noremap <C-b> <esc>:Unite buffer<cr> | |
nnoremap <space>/ :Unite grep:.<cr> | |
"nmap ; :CtrlPBuffer<CR> | |
" }}} | |
"{{{ FTYPES | |
fun! FindProjectRoot() | |
let s:depth = system("make -s echo-root 2> /dev/null") | |
let s:tagsf = system("make -s echo-tags 2> /dev/null") | |
if Len(s:depth) | |
exe 'setlocal path+=./' . s:depth | |
endif | |
if Len(s:tagsf) | |
exe 'setlocal tags+=./' . s:tagsf | |
endif | |
endfun | |
if has("autocmd") | |
filetype plugin indent on | |
syntax on | |
au BufReadPost * | |
\ if line("'\"") > 0 && line("'\"") <= line("$") | | |
\ exe "normal g`\"" | | |
\ endif | |
au VimLeave * mksession! ~/.cache/session.vim | |
au FileType debchangelog normal zO | |
au FileType javascript setlocal cindent tw=78 iskeyword+=$ | |
au FileType mail setlocal noet iskeyword+=- tw=72 | |
au FileType c,cpp setlocal noignorecase "fo-=ro | |
au FileType ocaml,acute,omlet setlocal sw=2 sts=2 tw=78 | |
au FileType php setlocal et fo+=ro tw=120 indentexpr= cin | |
au FileType python setlocal foldmethod=indent foldnestmax=1 | |
au FileType diff setlocal nofoldenable | |
au FileType html,xhtml,xml,smarty setlocal sw=2 | |
au FileType mail setlocal spell | |
" make error list special | |
au BufRead quickfix setlocal nobuflisted nowrap number | |
au FileType svn setlocal spell | |
au FileType git setlocal spell tw=76 | |
let ocaml_noindent_let=1 | |
let git_diff_spawn_mode=2 | |
let c_gnu=1 | |
au FileType * call FindProjectRoot() | |
endif " has ("autocmd") | |
" }}} | |
" {{{ PLUGINS | |
"Pathogen | |
" Download pathogen for awesome plugin at https://github.com/tpope/vim-pathogen | |
"call pathogen#infect() | |
"ctrl-P | |
if exists('~/.vim/bundle/ctrlp.vim') | |
set runtimepath^=~/.vim/bundle/ctrlp.vim | |
endif | |
runtime macros/matchit.vim | |
"runtime macros/justify.vim | |
runtime ftplugin/man.vim | |
nmap ! :exe "Man" expand("<cword>")<cr> | |
" }}} | |
" {{{ COLORS, GUI and FOLDING | |
if has("gui_running") | |
" {{{ GUI | |
set guioptions=aeit | |
set guifont=terminus | |
set guicursor=a:blinkon0 | |
set background=light | |
syntax reset | |
hi Normal gui=none guifg=#d0d0e0 guibg=#000010 | |
hi MoreMsg gui=none guifg=#d0d0e0 guibg=#000010 | |
hi Comment gui=none guifg=#b0b0ff guibg=#101030 | |
hi Folded gui=none guifg=#b0b0ff guibg=#101030 | |
hi SpecialKey gui=none guifg=#d0d0e0 guibg=#101030 | |
hi Todo gui=underline guifg=white guibg=NONE | |
hi Error gui=bold guifg=white guibg=red | |
hi Function gui=none guifg=#50d0d0 guibg=NONE | |
"hi Function gui=none guifg=#d0d0e0 guibg=#000010 | |
hi Identifier gui=none guifg=#50d0d0 guibg=NONE | |
hi Cursor gui=reverse guifg=#d0d0e0 guibg=black | |
hi Visual gui=reverse guifg=#d0d0e0 guibg=NONE | |
hi IncSearch gui=underline guifg=white guibg=NONE | |
hi Search gui=underline guifg=white guibg=NONE | |
hi StatusLine gui=none guifg=white guibg=#404080 | |
hi StatusLineNc gui=none guifg=#d0d0e0 guibg=#101030 | |
hi WildMenu gui=none guifg=white guibg=#101030 | |
hi VertSplit gui=none guifg=darkgray guibg=#101030 | |
hi NonText gui=none guifg=darkgray guibg=NONE | |
hi MatchParen gui=none guifg=white guibg=#101030 | |
hi Pmenu gui=none guifg=#d0d0e0 guibg=#101030 | |
hi PmenuSel gui=none guifg=white guibg=#404080 | |
hi PmenuSbar gui=none guifg=white guibg=#101030 | |
hi PmenuThumb gui=none guifg=#404080 guibg=#404080 | |
hi SpellBad gui=underline guifg=lightred guibg=NONE | |
hi SpellCap gui=none guifg=lightred guibg=NONE | |
hi SpellLocal gui=underline guifg=darkgreen guibg=NONE | |
hi SpellRare gui=none guifg=NONE guibg=NONE | |
hi Label gui=none guifg=#aa5500 guibg=NONE | |
hi Conditional gui=none guifg=#aa5500 guibg=NONE | |
hi Repeat gui=none guifg=#aa5500 guibg=NONE | |
hi Statement gui=none guifg=#aa5500 guibg=NONE | |
hi StorageClass gui=none guifg=#40c040 guibg=NONE | |
hi Type gui=none guifg=#40c040 guibg=NONE | |
hi Structure gui=none guifg=#40c040 guibg=NONE | |
hi Directory gui=none guifg=#40c040 guibg=NONE | |
hi Include gui=none guifg=#c010c0 guibg=NONE | |
hi PreProc gui=none guifg=#c010c0 guibg=NONE | |
hi Macro gui=none guifg=#c010c0 guibg=NONE | |
hi SpecialChar gui=none guifg=#c010c0 guibg=NONE | |
hi Character gui=none guifg=#c01010 guibg=NONE | |
hi String gui=none guifg=#c01010 guibg=NONE | |
hi Constant gui=none guifg=#c01010 guibg=NONE | |
" Custom | |
hi def link htmlTag htmlStatement | |
hi def link htmlEndTag htmlStatement | |
" diff | |
hi DiffAdd gui=none guifg=NONE guibg=#003010 | |
hi DiffDelete gui=none guifg=NONE guibg=#300010 | |
hi DiffChange gui=none guifg=NONE guibg=#000040 | |
hi DiffText gui=reverse guifg=NONE guibg=NONE | |
hi diffRemoved gui=none guifg=#c010c0 guibg=NONE | |
" }}} | |
else | |
set background=dark | |
syntax reset | |
hi Comment cterm=none ctermfg=blue ctermbg=none | |
hi Folded cterm=none ctermfg=green ctermbg=none | |
hi Cursor gui=reverse guifg=gray guibg=black | |
hi Visual cterm=reverse ctermfg=gray ctermbg=none | |
hi IncSearch cterm=underline ctermfg=white ctermbg=none | |
hi Search cterm=underline ctermfg=white ctermbg=none | |
hi StatusLine cterm=none ctermfg=white ctermbg=blue | |
hi StatusLineNc cterm=none ctermfg=black ctermbg=white | |
hi WildMenu cterm=none ctermfg=white ctermbg=none | |
hi VertSplit cterm=none ctermfg=darkgray ctermbg=none | |
hi NonText cterm=none ctermfg=darkgray ctermbg=none | |
hi MatchParen cterm=underline ctermfg=none ctermbg=none | |
hi Pmenu cterm=none ctermfg=gray ctermbg=black | |
hi PmenuSel cterm=none ctermfg=black ctermbg=gray | |
hi PmenuSbar cterm=none ctermfg=blue ctermbg=blue | |
hi PmenuThumb cterm=none ctermfg=gray ctermbg=gray | |
hi SpellBad cterm=underline ctermfg=lightred ctermbg=none | |
hi SpellCap cterm=none ctermfg=lightred ctermbg=none | |
hi SpellLocal cterm=underline ctermfg=darkgreen ctermbg=none | |
hi SpellRare cterm=none ctermfg=none ctermbg=none | |
endif | |
" }}} | |
if exists('/usr/share/vim-scripts/plugin/bufexplorer.vim') | |
so /usr/share/vim-scripts/plugin/bufexplorer.vim | |
endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment