1. Evgeny Podjachev
  2. my_vim_setup


my_vim_setup / .vimrc

" An example for a gvimrc file.
" The commands in this are executed when the GUI is started.
" Maintainer:	Bram Moolenaar <Bram@vim.org>
" Last change:	2001 Sep 02
" To use it, copy it to
"     for Unix and OS/2:  ~/.gvimrc
"	      for Amiga:  s:.gvimrc
"  for MS-DOS and Win32:  $VIM\_gvimrc
"	    for OpenVMS:  sys$login:.gvimrc

" Make external commands work through a pipe instead of a pseudo-tty
"set noguipty

set nocompatible               " be iMproved

" set the X11 font to use
if has('win32') || has('win64')
	set guifont=Courier_New:h12:cRUSSIAN
	set guifont=xos4\ Terminus\ 12
set ch=1		" Make command line 1 lines high

set mousehide		" Hide the mouse when typing text
set tabstop=4

set backspace=indent,eol,start  "allow backspacing over everything in insert mode
set autoindent    " always set autoindenting on
set cindent		" enables automatic C program indenting.
set copyindent    " copy the previous indentation on autoindenting

"set number        " always show line numbers
"set numberwidth=1 " width of number
"set cpoptions+=n  " use the number column for the text of wrapped lines

set shiftwidth=4 " number of spaces to use for autoindenting
set showmatch     " set show matching parenthesis
set smarttab      " insert tabs on the start of a line according to
                  "    shiftwidth, not tabstop
set hlsearch      " highlight search terms
set incsearch     " show search matches as you type
set history=1000         " remember more commands and search history
set undolevels=1000      " use many muchos levels of undo
if v:version >= 730
    set undofile                " keep a persistent backup file
    set undodir=~/.vim/.undo,~/tmp,/tmp

"set visualbell                  " don't beep
"set noerrorbells                " don't beep

set cursorline                  " underline the current line, for quick orientation

set ruler
set guioptions=aAe

set completeopt=menu,menuone

set nobackup
set noswapfile
set hidden

set path=./
set tags=~/.vim/tags/stl_tags
set tags+=./tags;/

"begin Vundle
filetype off                   " required!

set rtp+=~/.vim/bundle/vundle/
call vundle#rc()

" let Vundle manage Vundle
" required! 
Bundle 'gmarik/vundle'

" original repos on github
Bundle 'scrooloose/nerdtree'
Bundle 'fs111/pydoc.vim'
Bundle 'majutsushi/tagbar'
Bundle 'scrooloose/syntastic'
" vim-scripts repos
Bundle 'moria'
Bundle 'FSwitch'
Bundle 'snipMate'
Bundle 'OmniCppComplete'
Bundle 'vcscommand.vim'
Bundle 'FX-HLSL'
Bundle 'glsl.vim'
Bundle 'scons.vim'
Bundle 'Scons-compiler-plugin'
Bundle 'maxscript.vim'
Bundle 'pythoncomplete'
Bundle 'TagHighlight'
Bundle 'hexman.vim'
Bundle 'visual_studio.vim'

" non github repos
"end Vundle

"behave mswin

"set foldtext=/\\(\\S.*\\)/\+\\d\ \\f\ lines:\ \\1/
"set foldtext=v:folddashes.'lines:'.v:foldstart.v:folddashes.getline(v:foldstart)
set foldmethod=syntax
set foldignore=#,//
set foldcolumn=2
set shiftwidth=4
set foldlevel=0
set foldminlines=3

set encoding=utf-8

let python_highlight_all = 1
let moria_style = 'dark'
colorscheme moria

command FI :set foldmethod=indent
command FS :set foldmethod=syntax

map <C-F12> :!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q .<CR>
noremap <C-F12> :!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q .<CR>
vnoremap <C-F12> <C-C>:!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q .<CR>
inoremap <C-F12> <C-O>:!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q .<CR>

map <C-T>			:tab split<CR>
noremap <C-T>		:tab split<CR>
vnoremap <C-T>		<C-C>:tab split<CR>
inoremap <C-T>		<C-O>:tab split<CR>

map <C-G>			:call ShowMenu()<CR>
noremap <C-G>		:call ShowMenu()<CR>
vnoremap <C-G>		<C-C>:call ShowMenu()<CR>
inoremap <C-G>		<C-O>:call ShowMenu()<CR>

map <C-E>			:call ExpandFolds()<CR>
noremap <C-E>		:call ExpandFolds()<CR>
vnoremap <C-E>		<C-C>:call ExpandFolds()<CR>
inoremap <C-E>		<C-O>:call ExpandFolds()<CR>

" Make shift-insert work like in Xterm
map <S-Insert> <MiddleMouse>
map! <S-Insert> <MiddleMouse>

" CTRL-X and SHIFT-Del are Cut
" vnoremap <C-X> "+x

" CTRL-C are Copy
vnoremap <C-C> "+y

noremap <F6>		:YATE<CR>
vnoremap <F6>		<C-C>:YATE<CR>
inoremap <F6>		<C-O>:YATE<CR>

noremap <S-F6>		:YATEStationary<CR>
vnoremap <S-F6>		<C-C>:YATEStationary<CR>
inoremap <S-F6>		<C-O>:YATEStationary<CR>

noremap <F3>		:FFS<CR>
vnoremap <F3>		<C-C>:FFS<CR>
inoremap <F3>		<C-O>:FFS<CR>

noremap <C-F6>		:FSHere<CR>
vnoremap <C-F6>		<C-C>:FSHere<CR>
inoremap <C-F6>		<C-O>:FSHere<CR>

noremap <S-C-F6>		:FSSplitLeft<CR>
vnoremap <S-C-F6>		<C-C>:FSSplitLeft<CR>
inoremap <S-C-F6>		<C-O>:FSSplitLeft<CR>

map <F2>			:NERDTreeToggle<CR>
noremap <F2>		:NERDTreeToggle<CR>
vnoremap <F2>		<C-C>:NERDTreeToggle<CR>
inoremap <F2>		<C-O>:NERDTreeToggle<CR>

map <F7>			:wa<CR>:make -j4<CR>
noremap <F7>		:wa<CR>:make -j4<CR>
vnoremap <F7>		<C-C>:wa<CR><C-C>:make -j4<CR>
inoremap <F7>		<C-O>:wa<CR><C-O>:make -j4<CR>

map <F4>			:TagbarToggle<CR>
noremap <F4>		:TagbarToggle<CR>
vnoremap <F4>		<C-C>:TagbarToggle<CR>
inoremap <F4>		<C-O>:TagbarToggle<CR>

" Build
map <F8>			:wa<CR>:!scons<CR>
noremap <F8>		:wa<CR>:!scons<CR>
vnoremap <F8>		<C-C>:wa<CR><C-C>:!scons<CR>
inoremap <F8>		<C-O>:wa<CR><C-O>:!scons<CR>

map <F9>			:UpdateTypesFileOnly<CR>
noremap <F9>		:UpdateTypesFileOnly<CR>
vnoremap <F9>		<C-C>:UpdateTypesFileOnly<CR>
inoremap <F9>		<C-O>:UpdateTypesFileOnly<CR>

map <F10>			:VCSCommit<CR>
noremap <F10>		:VCSCommit<CR>
vnoremap <F10>		<C-C>:VCSCommit<CR>
inoremap <F10>		<C-O>:VCSCommit<CR>

map <F11>			:cwindow<CR>
noremap <F11>		:cwindow<CR>
vnoremap <F11>		<C-C>:cwindow<CR>
inoremap <F11>		<C-O>:cwindow<CR>

map <C-F11>			:tselect<CR>
noremap <C-F11>		:tselect<CR>
vnoremap <C-F11>	<C-C>:tselect<CR>
inoremap <C-F11>	<C-O>:tselect<CR>

" CTRL-V are Paste
"vnoremap <C-V>		"+gP

"map <C-V>			<MiddleMouse>
"map! <C-V>			<MiddleMouse>

noremap <C-S>		:update<CR>
vnoremap <C-S>		<C-C>:update<CR>
inoremap <C-S>		<C-O>:update<CR>

noremap <C-Z>		u
inoremap <C-Z>		<C-O>u
vnoremap <C-Z>		<C-C>:u<CR>
inoremap <C-Z>		<C-O>:u<CR>

nmap <silent> tc :tabc<cr>

" CTRL-A is Select all
noremap <C-A> gggH<C-O>G
inoremap <C-A> <C-O>gg<C-O>gH<C-O>G
cnoremap <C-A> <C-C>gggH<C-O>G

" I like highlighting strings inside C comments
let c_comment_strings=1

" Switch on syntax highlighting if it wasn't on yet.
if !exists("syntax_on")
syntax on

filetype on
"This makes vim invoke latex-suite when you open a tex file.
filetype plugin on
filetype indent on

" IMPORTANT: grep will sometimes skip displaying the file name if you
" search in a singe file. This will confuse latex-suite. Set your grep
" program to alway generate a file-name.
set grepprg=grep\ -nH\ $*

"Need by omnicppcomplete
set nocp

let OmniCpp_MayCompleteDot=1
let OmniCpp_MayCompleteArrow=1
let OmniCpp_MayCompleteScope=1
let OmniCpp_SelectFirstItem = 2 " select first item (but don't insert)
let OmniCpp_NamespaceSearch = 2 " search namespaces in this and included files
let OmniCpp_ShowPrototypeInAbbr = 1 " show function prototype (i.e. parameters) in popup window

let g:tagbar_left = 1
let g:tagbar_width = 30

au BufNewFile,BufRead,BufEnter *.frag,*.vert,*.fp,*.vp,*.glsl setf glsl
au BufNewFile,BufRead,BufEnter SCons* setf scons
au BufNewFile,BufRead,BufEnter *.scons setf scons
au BufNewFile,BufRead,BufEnter *.hlsl,*.fx,*.fxh setf fx

let g:YATE_max_matches_to_show=50

let g:syntastic_mode_map = { 'mode': 'active', 'active_filetypes': [], 'passive_filetypes': ['c', 'cpp'] }

" Needed for Hexman
if has('win32') || has('win64')
	let g:xxdprogram = 'C:\\Program Files (x86)\\vim\\vim73\\xxd.exe'

func! ExpandFolds()
	if &foldlevel==10
		set foldlevel=0
		set foldlevel=10
func! ShowMenu()
	if &guioptions=='aAm'
		set guioptions-=m
		set guioptions+=m

"Encoding menu
set wildmenu
set wcm=<Tab>
menu Encoding.koi8-r   :e ++enc=koi8-r<CR>
menu Encoding.windows-1251 :e ++enc=cp1251<CR>
menu Encoding.ibm-866      :e ++enc=ibm866<CR>
menu Encoding.utf-8                :e ++enc=utf-8 <CR>
map <F5> :emenu Encoding.<TAB>