" vim: spell foldmethod=marker : " Setup {{{ set nocompatible filetype off " Do so to reload filetype plugins after pathogen runtime bundle/vim-pathogen/autoload/pathogen.vim call pathogen#infect() if &t_Co > 2 || has('gui_running') syntax on endif filetype plugin indent on let g:template_dir=$HOME . "/.vim/templates" " }}} " Options {{{ " Locale {{{ language C set encoding=utf-8 " Encodings try list if has("multi_byte") set fileencodings=ucs-bom,utf-8,cp1251,koi8-r,cp866 endif set keymap=russian-jcukenwin set spelllang=ru,en set iminsert=0 set imsearch=0 " }}} set autoread set visualbell t_vb= set title " Скрывать буфер редактировании другого set hidden " Отображать текущую команду set showcmd " По умолчанию пользоваться :help справкой set keywordprg= set omnifunc=syntaxcomplete#Complete runtime! macros/matchit.vim set virtualedit+=block set backspace=indent,eol,start " Показывать столбец с номерами строк set number set nostartofline " many jump commands move the cursor to the first non-blank character of a line " Символ показывающий перенос текста set showbreak=↵ " Сколько строк оставлять при прокрутке с низу и с боку set scrolljump=4 set scrolloff=4 " Число столбцов отведенное на фолдинг " set foldcolumn=3 " Позволить перемещать курсор после начала и конца строки на предыдущую и " следующую соответственно. set whichwrap+=<>[] " Показывать позицию курсора (номер строки, номер позиции в строке) set ruler " Всегда показывать строку статуса set laststatus=2 " Задать формат статусной строки set statusline=%<%f\ %h%m%r%y%=%k\ fenc=%{&fileencoding}\ enc=%{&encoding}\ %l,%c%V\ %P " Начальная директория для просмотра файлов также откуда буфер set browsedir=buffer " Размер истории команд set history=1000 " Изменить действие на в режиме команд set wildmenu " command-line completion shows a list of matches " Дополнять по до максимально схожей строки, по второму выбирать из " вариантов set wildmode=list:longest,full " Не перерисовывать экран пока не выполнится макрос set lazyredraw " Не создавать swap файл в текущей директории set directory-=. " Язык проверки орфографии по умолчанию set wildignore=*.swp,*.bak,*.pyc,*.class set pastetoggle= set cursorline set ttyfast set autoindent set smartindent set splitright set splitbelow " List chars {{{ set list set listchars=tab:»\ ,trail:·,extends:#,nbsp:· augroup trailing au! au InsertEnter * :set listchars-=trail:· au InsertLeave * :set listchars+=trail:· augroup END " }}} " Tabs and formatting {{{ set tabstop=4 set shiftwidth=4 set softtabstop=4 set smarttab set shiftround set expandtab set wrap set linebreak set textwidth=80 set formatoptions=rqnl1j set cpoptions+=J " }}} let mapleader="," let maplocalleader="\\" " Color scheme {{{ let g:solarized_termcolors=256 let g:solarized_termtrans=1 set background=light colorscheme solarized " }}} " }}} " Backup {{{ set backup set noswapfile set undofile set undodir=$HOME/tmp/vim/undo// set backupdir=$HOME/tmp/vim/backup// set directory=$HOME/tmp/vim/swap// " Make directories if !isdirectory(expand(&undodir)) call mkdir(expand(&undodir), "p") endif if !isdirectory(expand(&backupdir)) call mkdir(expand(&backupdir), "p") endif if !isdirectory(expand(&directory)) call mkdir(expand(&directory), "p") endif " }}} " Search {{{ set gdefault set hlsearch set ignorecase set incsearch set showmatch set smartcase nnoremap / /\v vnoremap / /\v nnoremap * :let stay_star_view = winsaveview()*:call winrestview(stay_star_view) noremap :silent nohlsearch " Visual mode search {{{ function! s:VSetSearch() let temp = @@ norm! gvy let @/ = '\V' . substitute(escape(@@, '\'), '\n', '\\n', 'g') let @@ = temp endfunction vnoremap * :call VSetSearch()// vnoremap # :call VSetSearch()?? " }}} " }}} " Autocommands {{{ if has('autocmd') " TODO перенести в ftplugin autocmd FileType tex setlocal spell textwidth=79 autocmd FileType java setlocal omnifunc=javacomplete#Complete autocmd FileType python set expandtab autocmd FileType html,xml,ant set nolist au BufReadPost * if line("'\.") > 0 && line("'\.") <= line("$") | exe 'normal g`.zvzz' | endif au BufRead,BufNewFile /etc/nginx/* if &ft == "" | setfiletype nginx | endif au BufReadPost *.ledger norm G endif " }}} " Mappings {{{ " Vim rocks! nnoremap ; : inoremap kk nnoremap % vnoremap % nnoremap H ^ nnoremap L g_ inoremap l nnoremap J mzJ`z nnoremap n :setlocal number! nnoremap s :setlocal spell! nnoremap w :setlocal wrap! nnoremap p :silent! set paste"*p:set nopaste vnoremap y "*y " Disable keys {{{ inoremap nnoremap vnoremap noremap noremap noremap noremap " }}} nnoremap za vnoremap za nnoremap d "_d vnoremap d "_d " Увеличить шаг прокрутки буфера nnoremap 3 nnoremap 3 " Передвигаться держа курсор в центре по вертикале "map j jzz "map k kzz " Двигать блоки vnoremap < >gv nnoremap V V`] " Wrapped lines navigation {{{ nnoremap j gj nnoremap k gk nnoremap g$ $ nnoremap $ g$ nnoremap g0 0 nnoremap 0 g0 vnoremap g$ $ vnoremap $ g$ vnoremap g0 0 vnoremap 0 g0 " }}} " Speedup moving over windows map h map j map k map l " Write file with sudo cmap w!! w !sudo tee % >/dev/null map gf :e inoremap u inoremap u inoremap inoremap nnoremap :cnextz. nnoremap :cpreviousz. " Quick editing {{{ nnoremap ev :vsplit $MYVIMRC " }}} " }}} " Filetype {{{ " XML {{{ augroup ft_xml au! au FileType xml nnoremap z Vatzf au FileType xml vnoremap z zf augroup END " }}} " Javascript {{{ augroup ft_javascript au! au FileType javascript setlocal foldmethod=marker foldmarker={,} augroup END " }}} " }}} " Plugins {{{ " Surround {{{ " Surrounds double angle quotes «» let g:surround_171="« \r »" let g:surround_187="«\r»" " }}} " Syntastic {{{ let g:syntastic_check_on_open = 0 let g:syntastic_check_on_wq = 0 let g:syntastic_auto_jump = 0 let g:syntastic_java_checker = 'javac' let g:syntastic_mode_map = { \ 'mode': 'passive', \ 'active_filetypes': [], \ 'passive_filetypes': ['java'] \ } nnoremap C :SyntasticCheck " }}} " Taglist {{{ nnoremap :Tlist " }}} " Fuzzy Finder {{{ nnoremap '. :FufFileWithCurrentBufferDir nnoremap 'f :FufFile nnoremap 'h :FufFile $HOME/ nnoremap 'k :FufBuffer " }}} " NERD Tree {{{ noremap :NERDTreeToggle noremap :NERDTreeToggle let NERDTreeMinimalUI = 1 let NERDTreeDirArrows = 1 let NERDChristmasTree = 1 let NERDTreeChDirMode = 2 let NERDTreeIgnore = [ '\.pyc$' ] " }}} " Sparkup {{{ let g:sparkupNextMapping = '' " }}} " Scratch {{{ function! ScratchToggle() if exists("w:is_scratch_window") unlet w:is_scratch_window exec "q" else exec "norm! :Sscratch\\l" let w:is_scratch_window = 1 endif endfunction command! ScratchToggle call ScratchToggle() nnoremap :ScratchToggle " }}} " Tabular {{{ function! TabularizeUnderCursos() let ch = getline(".")[col(".") - 1] call Tabularize('/\V' . ch) endfunction nnoremap T :call TabularizeUnderCursos() " }}} " }}} " Load custom local config {{{ let s:local_vimrc=$MYVIMRC . ".local" if filereadable(s:local_vimrc) silent! execute ':source ' . s:local_vimrc endif " }}}