Created
April 20, 2016 04:27
-
-
Save zoxon/1f473d1184a2d07c62439fe4cd59968b 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
execute pathogen#infect() | |
filetype on | |
filetype plugin indent on | |
filetype plugin on | |
set nocompatible | |
source $VIMRUNTIME/vimrc_example.vim | |
source $VIMRUNTIME/mswin.vim | |
behave mswin | |
"Разблокирование всех 256 цветов | |
set t_Co=256 | |
set t_AB=^[[48;5;%dm | |
set t_AF=^[[38;5;%dm | |
set guifont=Consolas:h13 | |
colorscheme railscasts | |
set number | |
" Табы с плагина vim airline | |
let g:airline#extensions#tabline#enabled = 1 | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" => VIM user interface | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" Set 7 lines to the cursor - when moving vertically using j/k | |
set so=7 | |
" Turn on the WiLd menu | |
set wildmenu | |
"Always show current position | |
set ruler | |
" Height of the command bar | |
set cmdheight=1 | |
" A buffer becomes hidden when it is abandoned | |
set hid | |
" Highlight search results | |
set hlsearch | |
" Makes search act like search in modern browsers | |
set incsearch | |
" Don't redraw while executing macros (good performance config) | |
set lazyredraw | |
" For regular expressions turn magic on | |
set magic | |
" Show matching brackets when text indicator is over them | |
set showmatch | |
" How many tenths of a second to blink when matching brackets | |
set mat=2 | |
" No annoying sound on errors | |
set noerrorbells | |
set novisualbell | |
set t_vb= | |
set tm=500 | |
"""""""""""""""""""""""""""""" | |
" => Visual mode related | |
"""""""""""""""""""""""""""""" | |
" Visual mode pressing * or # searches for the current selection | |
" Super useful! From an idea by Michael Naumann | |
vnoremap <silent> * :call VisualSelection('f')<CR> | |
vnoremap <silent> # :call VisualSelection('b')<CR> | |
" Подсветка строки | |
set cursorline | |
" Попытка запустить проверка синтаксиса | |
let g:syntastic_check_on_open = 1 | |
let g:syntastic_enable_signs = 1 " Put errors on left side | |
"let g:syntastic_quiet_warnings = 1 " Only errors, not warnings please | |
"let g:syntastic_auto_loc_list = 2 " Only show errors when I ask | |
let g:syntastic_javascript_checkers = ['jshint'] | |
if has('unix') | |
let g:syntastic_error_symbol = '★' | |
let g:syntastic_style_error_symbol = '>' | |
let g:syntastic_warning_symbol = '!' | |
let g:syntastic_style_warning_symbol = '>' | |
else | |
let g:syntastic_error_symbol = '!' | |
let g:syntastic_style_error_symbol = '>' | |
let g:syntastic_warning_symbol = '.' | |
let g:syntastic_style_warning_symbol = '>' | |
endif | |
"Умное выделение | |
"nmap <C-S-Left> vb | |
"nmap <C-S-Right> ve | |
"Навигация в insert моде | |
imap <C-h> <left> | |
imap <C-j> <down> | |
imap <C-k> <up> | |
imap <C-l> <right> | |
" Включение и выключение отображения tagbar | |
nmap <F8> :TagbarToggle<CR> | |
" Включение и выключение отображения дерева NERDTree | |
nmap <F2> :NERDTreeToggle<CR> | |
" Ширина NERDTree по умолчанию | |
let g:NERDTreeWinSize = 30 | |
" Замена клавиши enter в NERDTree | |
"let NERDTreeMapOpenInTab='<ENTER>' | |
"" Проверяем открыт ли NERDTree | |
"function! rc:isNERDTreeOpen() | |
"return exists("t:NERDTreeBufName") && (bufwinnr(t:NERDTreeBufName) != -1) | |
"endfunction | |
"" Поиск активного файла в дереве NERDTree | |
"function! rc:syncTree() | |
"if &modifiable && rc:isNERDTreeOpen() && strlen(expand('%')) > 0 && !&diff | |
"NERDTreeFind | |
"wincmd p | |
"endif | |
"endfunction | |
"" Подсветка активного файла в NERDTree | |
"autocmd BufEnter * call rc:syncTree() | |
"Настройка скрития кода в блоки | |
set foldmethod=indent "fold based on indent | |
set foldnestmax=10 "deepest fold is 10 levels | |
set nofoldenable "dont fold by default | |
set foldlevel=1 "this is just what i use | |
" Открыть тег в новой вкладке | |
map <C-\> :tab split<CR>:exec("tag ".expand("<cword>"))<CR> | |
map <A-]> :vsp <CR>:exec("tag ".expand("<cword>"))<CR> | |
" Следующий тег | |
map <C-n> :tn<CR> | |
" Список тегов | |
map <C-[> :ts<CR> | |
" Копировать и вставить строку следующей Ctrl-d в notepad++ | |
nmap <C-d> :t.<CR> | |
" Следующий Таб | |
nnoremap <C-Right> :tabnext<CR> | |
nnoremap <C-l> :tabnext<CR> | |
" Предыдущий Таб | |
nnoremap <C-Left> :tabprevious<CR> | |
nnoremap <C-h> :tabprevious<CR> | |
lang mes en | |
"set langmenu=en_US.UTF-8 | |
set fileencoding=utf-8 | |
set tabstop=4 | |
set shiftwidth=4 | |
set smarttab | |
"set expandtab | |
set smartindent | |
" Влючить подстветку синтаксиса | |
syntax on | |
" Поиск по набору текста (очень полезная функция) | |
set incsearch | |
" Выключаем перенос строк | |
set nowrap | |
" Перенос строк по словам, а не по буквам | |
set linebreak | |
" Игнорировать регистр букв при поиске | |
set ignorecase | |
" Отключаем создание бэкапов | |
set nobackup | |
" Отключаем создание swap файлов | |
set noswapfile | |
"" Все swap файлы будут помещаться в эту папку | |
"set backupdir=~/temp | |
"" Размер истории для отмены | |
"set undolevels=1000 | |
set history=700 | |
"Убираем менюшки и скролы | |
set guioptions-=m | |
set guioptions-=T | |
set guioptions-=r | |
set guioptions-=L | |
"Сочетания клафиш для обратного таба | |
vmap <S-Tab> < | |
vmap <Tab> > | |
imap <S-Tab> < | |
"Очистка подсветки искомого слова | |
nnoremap <C-e> :nohlsearch<CR> | |
"Попытка настроить копирования для NERDTree | |
let g:NERDTreeCopyCmd= 'copy ' | |
"Изменение клавиши для Emmet | |
imap <C-Space> <C-y>, | |
vmap <C-Space> <C-y>, | |
" Alt-Left и Alt-Right для перемещения текущего таба влево и вправо | |
nnoremap <silent> <A-Left> :execute 'silent! tabmove ' . (tabpagenr()-2)<CR> | |
nnoremap <silent> <A-h> :execute 'silent! tabmove ' . (tabpagenr()-2)<CR> | |
nnoremap <silent> <A-Right> :execute 'silent! tabmove ' . tabpagenr()<CR> | |
nnoremap <silent> <A-l> :execute 'silent! tabmove ' . tabpagenr()<CR> | |
if has("multi_byte") | |
if &termencoding == "" | |
let &termencoding = &encoding | |
endif | |
set encoding=utf-8 " better default than latin1 | |
setglobal fileencoding=utf-8 " change default file encoding when writing new files | |
endif | |
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 | |
else | |
let cmd = $VIMRUNTIME . '\diff' | |
endif | |
silent execute '!' . cmd . ' ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3 . eq | |
endfunction | |
" Синтаксис jQuery | |
au BufRead,BufNewFile *.js set ft=javascript syntax=jquery | |
" Синтаксис html | |
au BufRead,BufNewFile *.twig set ft=html syntax=html | |
" Идти к закрывающему/открывающему тегу HTML/XHTML | |
autocmd FileType html let b:match_words = '<\(\w\w*\):</\1,{:}' | |
autocmd FileType phtml let b:match_words = '<\(\w\w*\):</\1,{:}' | |
autocmd FileType xhtml let b:match_words = '<\(\w\w*\):</\1,{:}' | |
autocmd FileType xml let b:match_words = '<\(\w\w*\):</\1,{:}' | |
" Изменение размеров окон | |
nmap <C-Up> <C-W>> | |
nmap <C-k> <C-W>> | |
nmap <C-Down> <C-W>< | |
nmap <C-j> <C-W>< | |
" Клавиши для мультикурсора | |
let g:multi_cursor_use_default_mapping=0 | |
" Default mapping | |
let g:multi_cursor_next_key='<M-n>' | |
let g:multi_cursor_prev_key='<M-p>' | |
let g:multi_cursor_skip_key='<M-x>' | |
let g:multi_cursor_quit_key='<Esc>' | |
" Клавиши для выделения слова под курсором | |
nmap <C-q> viw | |
imap <C-q> <Esc>viw | |
vmap <C-q> iv | |
" Клавиша для открытия списка сессий | |
nnoremap <F3> :OpenSession<cr> | |
" Хоткей для плагина отката undotree | |
nnoremap <F4> :UndotreeToggle<cr> | |
" Настройка хранения файлов изменения | |
"if has("persistent_undo") | |
" set undodir = '~/.temp/' | |
" set undofile | |
"endif | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" => vimgrep searching and cope displaying | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" When you press gv you vimgrep after the selected text | |
vnoremap <silent> gv :call VisualSelection('gv')<CR> | |
" Open vimgrep and put the cursor in the right position | |
map <leader>g :noautocmd vimgrep // **/*.<left><left><left><left><left><left><left> | |
" When you press <leader>r you can search and replace the selected text | |
vnoremap <silent> <leader>r :call VisualSelection('replace')<CR> | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" => Helper functions | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
function! CmdLine(str) | |
exe "menu Foo.Bar :" . a:str | |
emenu Foo.Bar | |
unmenu Foo | |
endfunction | |
function! VisualSelection(direction) range | |
let l:saved_reg = @" | |
execute "normal! vgvy" | |
let l:pattern = escape(@", '\\/.*$^~[]') | |
let l:pattern = substitute(l:pattern, "\n$", "", "") | |
if a:direction == 'b' | |
execute "normal ?" . l:pattern . "^M" | |
elseif a:direction == 'gv' | |
call CmdLine("noautocmd vimgrep " . '/'. l:pattern . '/' . ' **/*') | |
elseif a:direction == 'replace' | |
call CmdLine("%s" . '/'. l:pattern . '/') | |
elseif a:direction == 'f' | |
execute "normal /" . l:pattern . "^M" | |
endif | |
let @/ = l:pattern | |
let @" = l:saved_reg | |
endfunction | |
" Returns true if paste mode is enabled | |
function! HasPaste() | |
if &paste | |
return 'PASTE MODE ' | |
en | |
return '' | |
endfunction | |
" Don't close window, when deleting a buffer | |
command! Bclose call <SID>BufcloseCloseIt() | |
function! <SID>BufcloseCloseIt() | |
let l:currentBufNum = bufnr("%") | |
let l:alternateBufNum = bufnr("#") | |
if buflisted(l:alternateBufNum) | |
buffer # | |
else | |
bnext | |
endif | |
if bufnr("%") == l:currentBufNum | |
new | |
endif | |
if buflisted(l:currentBufNum) | |
execute("bdelete! ".l:currentBufNum) | |
endif | |
endfunction |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment