Skip to content

Instantly share code, notes, and snippets.

@stasiek
Last active December 15, 2015 14:58
Show Gist options
  • Select an option

  • Save stasiek/5278131 to your computer and use it in GitHub Desktop.

Select an option

Save stasiek/5278131 to your computer and use it in GitHub Desktop.
osx
" NERDTree, Pathogen
" Tagbar http://majutsushi.github.com/tagbar/
" Gundo http://sjl.bitbucket.org/gundo.vim
" https://github.com/vim-scripts/Gundo
" When started as "evim", evim.vim will already have done these settings.
if v:progname =~? "evim"
finish
endif
" Use Vim settings, rather than 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
else
set backup " keep a backup file
endif
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
" CTRL-U in insert mode deletes a lot. Use CTRL-G u to first break undo,
" so that you can undo CTRL-U after inserting a line break.
inoremap <C-U> <C-G>u<C-U>
" In many terminal emulators the mouse works just fine, thus enable it.
if has('mouse')
set mouse=a
endif
" 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
endif
" 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
au!
" 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).
" Also don't do it when the mark is in the first line, that is the default
" position when opening a file.
autocmd BufReadPost *
\ if line("'\"") > 1 && line("'\"") <= line("$") |
\ exe "normal! g`\"" |
\ endif
augroup END
else
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.
" Only define it when not defined already.
if !exists(":DiffOrig")
command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis
\ | wincmd p | diffthis
endif
set shiftwidth=2 tabstop=2 expandtab
" set diffexpr=MyDiff()
"function MyDiff()
" let opt = '-a --binary '
" if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif
" if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif
" let arg1 = v:fname_in
" if arg1 =~ ' ' | let arg1 = '"' . arg1 . '"' | endif
" let arg2 = v:fname_new
" if arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endif
" let arg3 = v:fname_out
" if arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endif
" let eq = ''
" if $VIMRUNTIME =~ ' '
" if &sh =~ '\<cmd'
" let cmd = '""' . $VIMRUNTIME . '\diff"'
" let eq = '"'
" else
" let cmd = substitute($VIMRUNTIME, ' ', '" ', '') . '\diff"'
" endif:w
"
" else
" let cmd = $VIMRUNTIME . '\diff'
" endif
" silent execute '!' . cmd . ' ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3 . eq
" endfunction
"=====================================================================================
" KEYBINDINGS
"=====================================================================================
"GVIM
nnoremap <C-F1> :if &go=~#'m'<Bar>set go-=m<Bar>else<Bar>set go+=m<Bar>endif<CR>
nnoremap <C-F2> :if &go=~#'T'<Bar>set go-=T<Bar>else<Bar>set go+=T<Bar>endif<CR>
nnoremap <C-F3> :if &go=~#'r'<Bar>set go-=r<Bar>else<Bar>set go+=r<Bar>endif<CR>
"VIM
"-------------------------------------------------------------------------------
" some additional hot keys
"-------------------------------------------------------------------------------
" F2 - write file without confirmation
" F3 - call file explorer Ex
" F4 - show tag under curser in the preview window (tagfile must exist!)
" F5 - open quickfix error window
" F6 - close quickfix error window
" F7 - display previous error
" F8 - display next error
"-------------------------------------------------------------------------------
"
nmap <F9> :TagbarToggle<CR> " mapping f9 to TagbarToggle
nmap <F10> :NERDTreeToggle<CR> " mapping f10 to NERDTreeToggle
nmap <F11> :NumbersToggle<CR> " mapping f11 to NumbersToggle
noremap <F12> :GundoToggle<CR> " mapping f12 to Gundo
map <silent> <F2> :write<CR>
map <silent> <F3> :Explore<CR>
nmap <silent> <F4> :exe ":ptag ".expand("<cword>")<CR>
map <silent> <F5> :copen<CR>
map <silent> <F6> :cclose<CR>
map <silent> <F7> :cp<CR>
map <silent> <F8> :cn<CR>
"
imap <silent> <F2> <Esc>:write<CR>
imap <silent> <F3> <Esc>:Explore<CR>
imap <silent> <F4> <Esc>:exe ":ptag ".expand("<cword>")<CR>
imap <silent> <F5> <Esc>:copen<CR>
imap <silent> <F6> <Esc>:cclose<CR>
imap <silent> <F7> <Esc>:cp<CR>
imap <silent> <F8> <Esc>:cn<CR>
"
"-------------------------------------------------------------------------------
" Fast switching between buffers
" The current buffer will be saved before switching to the next one.
" Choose :bprevious or :bnext
"-------------------------------------------------------------------------------
"
map <silent> <s-tab> <Esc>:if &modifiable && !&readonly &&
\ &modified <CR> :write<CR> :endif<CR>:bprevious<CR>
imap <silent> <s-tab> <Esc>:if &modifiable && !&readonly &&
\ &modified <CR> :write<CR> :endif<CR>:bprevious<CR>
"
"-------------------------------------------------------------------------------
" Leave the editor with Ctrl-q : Write all changed buffers and exit Vim
"-------------------------------------------------------------------------------
nmap <C-q> :wqa<CR>
"
"-------------------------------------------------------------------------------
" comma always followed by a space
"-------------------------------------------------------------------------------
"inoremap , ,<Space>
"
"
"-------------------------------------------------------------------------------
" autocomplete parenthesis, brackets and braces
"-------------------------------------------------------------------------------
"inoremap ( ()<Left>
"inoremap [ []<Left>
"inoremap { {}<Left>
"
vnoremap ( s()<Esc>P<Right>%
vnoremap [ s[]<Esc>P<Right>%
vnoremap { s{}<Esc>P<Right>%
"
"-------------------------------------------------------------------------------
" autocomplete quotes (visual and select mode)
"-------------------------------------------------------------------------------
xnoremap ' s''<Esc>P<Right>
xnoremap " s""<Esc>P<Right>
xnoremap ` s``<Esc>P<Right>
"
"-------------------------------------------------------------------------------
" Change the working directory to the directory containing the current file
"-------------------------------------------------------------------------------
if has("autocmd")
autocmd BufEnter * :lchdir %:p:h
endif " has("autocmd")
"
"===================================================================================
" VARIOUS PLUGIN CONFIGURATIONS
"===================================================================================
"
"-------------------------------------------------------------------------------
" c.vim
"-------------------------------------------------------------------------------
"
" --empty --
"
"-------------------------------------------------------------------------------
" taglist.vim : toggle the taglist window
" taglist.vim : define the title texts for make
" taglist.vim : define the title texts for qmake
"-------------------------------------------------------------------------------
noremap <silent> <F11> <Esc><Esc>:Tlist<CR>
inoremap <silent> <F11> <Esc><Esc>:Tlist<CR>
let Tlist_GainFocus_On_ToggleOpen = 1
let Tlist_Close_On_Select = 1
let tlist_make_settings = 'make;m:makros;t:targets'
let tlist_qmake_settings = 'qmake;t:SystemVariables'
if has("autocmd")
" ---------- qmake : set filetype for *.pro ----------
autocmd BufNewFile,BufRead *.pro set filetype=qmake
endif " has("autocmd")
"
"
"-------------------------------------------------------------------------------
" Leave the editor with Ctrl-q : Write all changed buffers and exit Vim
"----------------------------------------------------------------------------------
nmap <C-q> :wqa<CR>
"
"
"Ctrl+C + Ctrl+V
nmap <C-v> "+gP
imap <C-v> <ESC><C-v>
vmap <C-c> "+y
call pathogen#infect()
"----------------------------------------------------------------------------------
" Layout
"----------------------------------------------------------------------------------
set number
colorscheme vitamins
highlight OverLength ctermbg=black ctermfg=white guibg=black
match OverLength /\%85v.*/
"set textwidth=80
"set colorcolumn=80 " line to show 85 character mark
"set colorcolumn=-2
"highlight ColorColumn ctermbg=black guibg=black
" Use Vim settings, rather than Vi settings (much better!).
" This must be first, because it changes other options as a side effect.
set nocompatible
"===================================================================================
"Vundle config. Like Pathogen + git, etc (Emacs: el-get)
"===================================================================================
filetype off
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
" let Vundle manage Vundle
" required!
Bundle 'gmarik/vundle'
" " The bundles you install will be listed here
Bundle 'Lokaltog/powerline', {'rtp': 'powerline/bindings/vim/'}
Bundle 'scrooloose/nerdtree'
" Python
Bundle 'davidhalter/jedi-vim'
Bundle 'ivanov/vim-ipython'
" Erlang
Bundle 'jimenezrick/vimerl'
"
" End of Vundle config
filetype plugin indent on
"===================================================================================
" Powerline config
"===================================================================================
set encoding=utf-8 " Necessary to show Unicode glyphs
let g:Powerline_symbols = 'fancy'
set guifont=Sauce\ Code\ Powerline\ 10
set laststatus=2
" " The rest of your config follows here
" NERDTree, Pathogen
" Tagbar http://majutsushi.github.com/tagbar/
" Gundo http://sjl.bitbucket.org/gundo.vim
" https://github.com/vim-scripts/Gundo
" When started as "evim", evim.vim will already have done these settings.
if v:progname =~? "evim"
finish
endif
" 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
else
set backup " keep a backup file
endif
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
" CTRL-U in insert mode deletes a lot. Use CTRL-G u to first break undo,
" so that you can undo CTRL-U after inserting a line break.
inoremap <C-U> <C-G>u<C-U>
" In many terminal emulators the mouse works just fine, thus enable it.
if has('mouse')
set mouse=a
endif
" 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
endif
" 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
au!
" 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).
" Also don't do it when the mark is in the first line, that is the default
" position when opening a file.
autocmd BufReadPost *
\ if line("'\"") > 1 && line("'\"") <= line("$") |
\ exe "normal! g`\"" |
\ endif
augroup END
else
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.
" Only define it when not defined already.
if !exists(":DiffOrig")
command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis
\ | wincmd p | diffthis
endif
set shiftwidth=2 tabstop=2 expandtab
" set diffexpr=MyDiff()
"function MyDiff()
" let opt = '-a --binary '
" if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif
" if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif
" let arg1 = v:fname_in
" if arg1 =~ ' ' | let arg1 = '"' . arg1 . '"' | endif
" let arg2 = v:fname_new
" if arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endif
" let arg3 = v:fname_out
" if arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endif
" let eq = ''
" if $VIMRUNTIME =~ ' '
" if &sh =~ '\<cmd'
" let cmd = '""' . $VIMRUNTIME . '\diff"'
" let eq = '"'
" else
" let cmd = substitute($VIMRUNTIME, ' ', '" ', '') . '\diff"'
" endif:w
"
" else
" let cmd = $VIMRUNTIME . '\diff'
" endif
" silent execute '!' . cmd . ' ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3 . eq
" endfunction
"=====================================================================================
" KEYBINDINGS
"=====================================================================================
"GVIM
nnoremap <C-F1> :if &go=~#'m'<Bar>set go-=m<Bar>else<Bar>set go+=m<Bar>endif<CR>
nnoremap <C-F2> :if &go=~#'T'<Bar>set go-=T<Bar>else<Bar>set go+=T<Bar>endif<CR>
nnoremap <C-F3> :if &go=~#'r'<Bar>set go-=r<Bar>else<Bar>set go+=r<Bar>endif<CR>
"VIM
"-------------------------------------------------------------------------------
" some additional hot keys
"-------------------------------------------------------------------------------
" F2 - NerdTreeToggle
" F3 - call file explorer Ex
" F4 - show tag under curser in the preview window (tagfile must exist!)
" F5 - open quickfix error window
" F6 - close quickfix error window
" F7 - display previous error
" F8 - display next error
"-------------------------------------------------------------------------------
" Olds
" F2 - write file without confirmation: map <silent> <F2> :write<CR>
"-------------------------------------------------------------------------------
"
nmap <F9> :TagbarToggle<CR> " mapping f9 to TagbarToggle
nmap <F10> :NERDTreeToggle<CR> " mapping f10 to NERDTreeToggle
nmap <F11> :NumbersToggle<CR> " mapping f11 to NumbersToggle
noremap <F12> :GundoToggle<CR> " mapping f12 to Gundo
map <F2> :NERDTreeToggle<CR>
map <silent> <F3> :Explore<CR>
nmap <silent> <F4> :exe ":ptag ".expand("<cword>")<CR>
map <silent> <F5> :copen<CR>
map <silent> <F6> :cclose<CR>
map <silent> <F7> :cp<CR>
map <silent> <F8> :cn<CR>
"
imap <silent> <F2> <Esc>:write<CR>
imap <silent> <F3> <Esc>:Explore<CR>
imap <silent> <F4> <Esc>:exe ":ptag ".expand("<cword>")<CR>
imap <silent> <F5> <Esc>:copen<CR>
imap <silent> <F6> <Esc>:cclose<CR>
imap <silent> <F7> <Esc>:cp<CR>
imap <silent> <F8> <Esc>:cn<CR>
"
"-------------------------------------------------------------------------------
" Fast switching between buffers
" The current buffer will be saved before switching to the next one.
" Choose :bprevious or :bnext
"-------------------------------------------------------------------------------
"
map <silent> <s-tab> <Esc>:if &modifiable && !&readonly &&
\ &modified <CR> :write<CR> :endif<CR>:bprevious<CR>
imap <silent> <s-tab> <Esc>:if &modifiable && !&readonly &&
\ &modified <CR> :write<CR> :endif<CR>:bprevious<CR>
"
"-------------------------------------------------------------------------------
" Leave the editor with Ctrl-q : Write all changed buffers and exit Vim
"-------------------------------------------------------------------------------
nmap <C-q> :wqa<CR>
"
"-------------------------------------------------------------------------------
" comma always followed by a space
"-------------------------------------------------------------------------------
"inoremap , ,<Space>
"
"
"-------------------------------------------------------------------------------
" autocomplete parenthesis, brackets and braces
"-------------------------------------------------------------------------------
"inoremap ( ()<Left>
"inoremap [ []<Left>
"inoremap { {}<Left>
"
vnoremap ( s()<Esc>P<Right>%
vnoremap [ s[]<Esc>P<Right>%
vnoremap { s{}<Esc>P<Right>%
"
"-------------------------------------------------------------------------------
" autocomplete quotes (visual and select mode)
"-------------------------------------------------------------------------------
xnoremap ' s''<Esc>P<Right>
xnoremap " s""<Esc>P<Right>
xnoremap ` s``<Esc>P<Right>
"
"-------------------------------------------------------------------------------
" Change the working directory to the directory containing the current file
"-------------------------------------------------------------------------------
if has("autocmd")
autocmd BufEnter * :lchdir %:p:h
endif " has("autocmd")
"
"===================================================================================
" VARIOUS PLUGIN CONFIGURATIONS
"===================================================================================
"
"-------------------------------------------------------------------------------
" c.vim
"-------------------------------------------------------------------------------
"
" --empty --
"
"-------------------------------------------------------------------------------
" taglist.vim : toggle the taglist window
" taglist.vim : define the title texts for make
" taglist.vim : define the title texts for qmake
"-------------------------------------------------------------------------------
noremap <silent> <F11> <Esc><Esc>:Tlist<CR>
inoremap <silent> <F11> <Esc><Esc>:Tlist<CR>
let Tlist_GainFocus_On_ToggleOpen = 1
let Tlist_Close_On_Select = 1
let tlist_make_settings = 'make;m:makros;t:targets'
let tlist_qmake_settings = 'qmake;t:SystemVariables'
if has("autocmd")
" ---------- qmake : set filetype for *.pro ----------
autocmd BufNewFile,BufRead *.pro set filetype=qmake
endif " has("autocmd")
"
"
"-------------------------------------------------------------------------------
" Leave the editor with Ctrl-q : Write all changed buffers and exit Vim
"----------------------------------------------------------------------------------
nmap <C-q> :wqa<CR>
"
"
"Ctrl+C + Ctrl+V
nmap <C-v> "+gP
imap <C-v> <ESC><C-v>
vmap <C-c> "+y
call pathogen#infect()
"----------------------------------------------------------------------------------
" Layout
"----------------------------------------------------------------------------------
set number
colorscheme molokai
set term=screen-256color "fixe's backgroun bleed in tmux
" Pyflakes error highlighting
highlight clear SpellBad
highlight SpellBad term=standout ctermfg=1 term=underline cterm=underline
highlight clear SpellCap
highlight SpellCap term=underline cterm=underline
highlight clear SpellRare
highlight SpellRare term=underline cterm=underline
highlight clear SpellLocal
highlight SpellLocal term=underline cterm=underline
"highlight OverLength ctermbg=black ctermfg=white guibg=black
"match OverLength /\%85v.*/
"set textwidth=80
"set colorcolumn=80 " line to show 85 character mark
"set colorcolumn=-2
"highlight ColorColumn ctermbg=black guibg=black
"----------------------------------------------------------------------------------
" Commenting in vim
" ,cc to comment
" ,cu uncomment
"----------------------------------------------------------------------------------
autocmd FileType c,cpp,java,scala let b:comment_leader = '// '
autocmd FileType sh,ruby,python let b:comment_leader = '# '
autocmd FileType conf,fstab let b:comment_leader = '# '
autocmd FileType tex let b:comment_leader = '% '
autocmd FileType mail let b:comment_leader = '> '
autocmd FileType vim let b:comment_leader = '" '
noremap <silent> ,cc :<C-B>silent<C-E>s/^/<C-R>=escape(b:comment_leader,'\/')<CR>/<CR>:nohlsearch<CR>
noremap <silent> ,cu :<C-B>silent<C-E>s/^\V<C-R>=escape(b:comment_leader,'\/')<CR>//e<CR>:nohlsearch<CR>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment