Skip to content

Instantly share code, notes, and snippets.

@unnamed777
Last active January 4, 2016 18:29
Show Gist options
  • Save unnamed777/8661482 to your computer and use it in GitHub Desktop.
Save unnamed777/8661482 to your computer and use it in GitHub Desktop.
Vim configs
colorscheme default
" set guioptions=grLte
set guioptions=grte
set guifont=Consolas:h9::cDEFAULT
" language en
syn on
" au GUIEnter * simalt ~x
set lines=80 columns=130
set mouse=a
set encoding=utf-8
set termencoding=utf-8
set lazyredraw
set linespace=0
"{{{ Indents and wraps
" Convert Tab to Space
set expandtab
" Количество отображаемых символов в одном табе
set tabstop=4
" Сколько символов в одном табе
set softtabstop=4
" Смешение, в пробелах
set shiftwidth=4
set autoindent
set smartindent
"set cindent
"set cinkeys-=0#
"set indentkeys-=0#
set wrap
set linebreak
vmap < <gv
vmap > >gv
nmap <Tab> >>
nmap <S-Tab> <<
vnoremap <Tab> >
vnoremap <S-Tab> <
"}}}
set showcmd
set statusline=%1*%m%0*%<%f%h%r\ \ \ %=%{&filetype}\ %{&fileencoding}/%{&fileformat}\ %003.8l;%003.8c\ %P
" set statusline=%<%f%h%m%r\ %{WhatFunction()}%=%{&filetype}\ %{&fileencoding}/%{&fileformat}\ %{&encoding}\ %004.8l;%004.8c\ %P
set fileformats=unix,dos
set fileformat=unix
set laststatus=2
" List of codepages for autodefinition
set fileencodings=utf-8,cp1251,koi8-r,cp866
" Visual alert instead sound
set novisualbell
set t_vb=
set ruler
" Line numbers
set nu
" Не подсвечивать результаты поиска
" set nohlsearch
" Искать по мере набора текста
set incsearch
set hlsearch
" Поиск без учета регистра
set ignorecase
" set cursorline
set scrolljump=1
set scrolloff=1
" Disable reload buffer when switch to other
set hidden
" set guioptions=-t
" Height of command line
set ch=1
" allow to use backspace instead of "x"
set backspace=indent,eol,start whichwrap+=<,>,[,]
" Fix <Enter> for comment
set fo+=cr
" Session options
set sessionoptions=curdir,buffers,tabpages
set dir=c:\temp,c:\tmp
" Автоматически изменять текущую директорию при открытии файла
""""""set autochdir
" Filetype plugin
filetype plugin on
set noswapfile
set list
set listchars=eol:$,tab:>-
set splitright
" let Tlist_Show_One_File = 1
vmap <C-C> "+y
vmap <C-Ins> "+y
"imap <C-V> <esc>"+gpi
imap <S-Ins> <esc>"+gpi
" Редко когда надо [ без пары =)
" imap [ []<LEFT>
" imap ( ()<LEFT>
" Аналогично и для {
" imap {<cr> {<cr>}<esc>o
" автодополнение по Control+Space
imap <C-Space> <C-N>
" 'умный' Home
nmap <Home> ^
imap <Home> <Esc>^i
" Сохранение по ctr+s
imap <C-S> <esc>:w!<CR>a
" vmap <C-S> :w<CR>
nmap <c-s> :w!<cr>
nmap <C-F4> <C-W>q
" nmap <C-Tab> gt
" imap <C-Tab> <esc>gt
" nmap <C-S-Tab> gT
" imap <C-S-Tab> <esc>gT
map \\ <C-]>
imap <S-Enter> <Esc>
vmap <S-Enter> <Esc>
map <S-Enter> <Esc>
map <2-LeftMouse> *N
map <MiddleMouse> <Nop>
imap <MiddleMouse> <Nop>
nnoremap j gj
nnoremap k gk
vnoremap j gj
vnoremap k gk
nnoremap <Down> gj
nnoremap <Up> gk
vnoremap <Down> gj
vnoremap <Up> gk
inoremap <Down> <C-o>gj
inoremap <Up> <C-o>gk
function CaseChanged()
echohl ErrorMsg
echo "Case changed!"
let tempVar = input('')
echohl None
endfunction
vnoremap u u:call CaseChanged()<CR>
vnoremap U U:call CaseChanged()<CR>
" Автозавершение слов по tab
function InsertTabWrapper()
let col = col('.') - 1
if !col || getline('.')[col - 1] !~ '\k'
return "\<tab>"
else
return "\<c-p>"
endif
endfunction
" imap <tab> <c-r>=InsertTabWrapper()<cr>
" Слова откуда будем завершать
set complete=""
" Из текущего буфера
set complete+=.
" Из словаря
set complete+=k
" Из других открытых буферов
set complete+=b
" из тегов
set complete+=t
set wildmenu
set wcm=<Tab>
menu 10.351 &File.-sep351- <Nop>
menu 10.352 &File.Encoding.Open.UTF-8 :e ++enc=utf-8<CR>
menu 10.352 &File.Encoding.Open.CP1251 :e ++enc=cp1251<CR>
menu 10.352 &File.Encoding.Open.ANSI :e ++enc=ansi<CR>
menu 10.352 &File.Encoding.Open.KOI8-R :e ++enc=koi8-r<CR>
menu 10.352 &File.Encoding.Open.CP866 :e ++enc=cp866<CR>
menu 10.352 &File.Encoding.Open.UTF-16 :e ++enc=utf-16<CR>
menu 10.352 &File.Encoding.Save.UTF-8 :set fileencoding=utf-8<CR>
menu 10.352 &File.Encoding.Save.CP1251 :set fileencoding=cp1251<CR>
menu 10.352 &File.Encoding.Save.ANSI :set fileencoding=ansi<CR>
menu 10.352 &File.Encoding.Save.KOI8-R :set fileencoding=koi8-r<CR>
menu 10.352 &File.Encoding.Save.CP866 :set fileencoding=cp866<CR>
menu 10.352 &File.Encoding.Save.UTF-16 :set fileencoding=utf-16<CR>
map <Leader>m :emenu <Tab>
"
" предыдущий буфер
imap <F5> <Esc>:bp!<CR>a
nmap <F5> :bp!<CR>
" следующий буфер
imap <F6> <Esc>:bn!<CR>a
nmap <F6> :bn!<CR>
" F5 - просмотр списка буферов
nmap <F7> <Esc>:BufExplorer<cr>
"vmap <F7> <esc>:BufExplorer<cr>
"imap <F7> <esc><esc>:BufExplorer<cr>
" F11 - показать окно Taglist
map <F11> :TlistToggle<cr>
vmap <F11> <esc>:TlistToggle<cr>
imap <F11> <esc>:TlistToggle<cr>
" F12 - обозреватель файлов
map <F12> :Vexplore<cr>
let g:NERDMenuMode = 2
map <S-F12> :NERDTree<cr>
let g:NERDTreeChDirMode = 1
let g:NERDTreeHighlightCursorline = 1
let g:NERDTreeQuitOnOpen = 0
let g:NERDTreeShowHidden = 1
"map <F12> :Vexplore<cr>
"vmap <F12> <esc>:Vexplore<cr>i
"imap <F12> <esc>:Vexplore<cr>i
" let Tlist_File_Fold_Auto_Close = 1
let Tlist_Show_One_File = 1
let Tlist_Sort_Type = 'name'
" command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis | wincmd p | diffthis
command Cbs confirm browse saveas
" Приравниваем регистр "") регистру "*(виндовый буфер обмена)
"set clipboard=unnamed
"{{{ Customize tab text
" Задаем собственные функции для назначения имен заголовкам табов -->
function MyTabLine()
if match(&guioptions, 'e') == -1
" return
endif
let tabline = ''
" Формируем tabline для каждой вкладки -->
for i in range(tabpagenr('$'))
" Подсвечиваем заголовок выбранной в данный момент вкладки.
if i + 1 == tabpagenr()
let tabline .= '%#TabLineSel#'
else
let tabline .= '%#TabLine#'
endif
" Устанавливаем номер вкладки
let tabline .= '%' . (i + 1) . 'T'
" Получаем имя вкладки
let tabline .= ' %{MyTabLabel(' . (i + 1) . ')} |'
endfor
" Формируем tabline для каждой вкладки <--
" Заполняем лишнее пространство
let tabline .= '%#TabLineFill#%T'
" Выровненная по правому краю кнопка закрытия вкладки
if tabpagenr('$') > 1
let tabline .= '%=%#TabLine#%999XX'
endif
return tabline
endfunction
function MyTabLabel(n)
let label = ''
let buflist = tabpagebuflist(a:n)
" Имя файла и номер вкладки -->
" let label = substitute(bufname(buflist[tabpagewinnr(a:n) - 1]), '.*/', '', '')
if exists("b:tabname")
let label = b:tabname
else
let label = substitute(bufname(buflist[tabpagewinnr(a:n) - 1]), '^.*[\/]', '', '')
endif
if label == ''
let label = '[No Name]'
endif
let label = '' . a:n . '. ' . label
" Имя файла и номер вкладки <--
" Определяем, есть ли во вкладке хотя бы один
" модифицированный буфер.
" -->
for i in range(len(buflist))
if getbufvar(buflist[i], "&modified")
let label = '[+] ' . label
break
endif
endfor
" <--
return label
endfunction
function MyGuiTabLabel()
return '%{MyTabLabel(' . tabpagenr() . ')}'
endfunction
set tabline=%!MyTabLine()
set guitablabel=%!MyGuiTabLabel()
"}}}
command! -nargs=? Rt call RenameTab(<f-args>)
function! RenameTab(...)
let b:tabname = a:{1}
" let g:tabname[bufnr('%')] = a:{1}
set tabline=%!MyTabLine()
set guitablabel=%!MyGuiTabLabel()
endfunction
" set foldenable
" Отключение автоматического фолдинга(simpleFold)
set foldmethod=manual
" Включение фолдинга от simpleFold
"map <F4> :set foldmethod=indent<cr>zR
"syn region myFold start="{" end="}" transparent fold
"syn sync fromstart
"set foldmethod=syntax
"{{{ s:GetOption
" grab a user-specified option to override the default provided. options are
" searched in the window, buffer, then global spaces.
function GetOption(name, ...)
if exists("w:{&filetype}_" . a:name)
execute "return w:{&filetype}_".a:name
elseif exists("w:" . a:name)
execute "return w:".a:name
elseif exists("b:{&filetype}_" . a:name)
execute "return b:{&filetype}_".a:name
elseif exists("b:" . a:name)
execute "return b:".a:name
elseif exists("g:{&filetype}_" . a:name)
execute "return g:{&filetype}_".a:name
elseif exists("g:" . a:name)
execute "return g:".a:name
else
return a:1
endif
endfunction
function IsOptionSet(name)
let bogus_val = "df hdsoi3y98 hjsdfhdkj"
return s:GetOption(a:name, bogus_val) == bogus_val ? 0 : 1
endfunction
"}}}
"{{{ FoldText
function Num2S(num, len)
let filler = " "
let text = '' . a:num
return strpart(filler, 1, a:len - strlen(text)) . text
endfunction
"}}}
"{{{ MyFoldText function
set foldtext=MyFoldText()
function MyFoldText()
let linenum = v:foldstart
if match(getline(linenum), GetOption("simplefold_marker_start")) != -1
let line = getline(linenum)
else
while linenum <= v:foldend
let line = getline(linenum)
if IsOptionSet("simplefold_prefix") ||
\ match(line, GetOption("simplefold_prefix")) == -1
break
else
let linenum = linenum + 1
endif
endwhile
"if IsOptionSet("simplefold_prefix") &&
" \ match(line, GetOption("simplefold_prefix")) != -1
" " all lines matched the prefix regexp
" let line = getline(v:foldstart)
"endif
endif
let markerLine = substitute(getline(v:foldstart), '/\*\|\*/\|<!--\|-->\|{' . '{{\d\=', '', 'g')
let markerLine = substitute(markerLine, '^\s*', '', '')
let markerLine = substitute(markerLine, '\s*$', '', '')
let markerLine = substitute(markerLine, '\s\{2,}', ' ', 'g')
let codeLine = getline(linenum)
let codeLine = substitute(codeLine, '^\s*', '', '')
let codeLine = substitute(codeLine, '\s*$', '', '')
let line = codeLine
let sub1 = substitute(line, '^\s*', '', '')
let sub1 = substitute(sub1, '\s*$', '', '')
" old let firstSymbPos = match(line, '\S')
" old let line = getline(v:foldstart)
let line = getline(linenum)
let firstSymbPos = match(line, '\S')
let sub2 = strpart(line, 0, firstSymbPos)
"echo linenum
"echo strlen(sub2)
"echo strlen(line)
"let tempVar = input(linenum)
"let tempVar = input(line)
"let tempVar = input(match(line, '\S'))
let strOffset = 0
let countSpaces = 0
while strOffset < strlen(sub2)
let currChar = char2nr(strpart(sub2, strOffset, 1))
if currChar == 32
let countSpaces = countSpaces + 1
else
let countSpaces = countSpaces + 4
endif
let strOffset = strOffset + 1
endwhile
" echo "123"
"echo countSpaces
let startFoldOffset = repeat(' ', countSpaces) " strOffset
"let sub2 = substitute(sub2, '\t', ' ', 'g')
let diff = v:foldend - v:foldstart + 1
let foldText = startFoldOffset . '+ ' . '[' . diff . ' lines'
if strlen(markerLine) > 0 && markerLine != sub1
let foldText .= '. ' . markerLine
endif
let foldText .= '] ' . sub1 . ' '
return foldText
"return startFoldOffset . '+ ' . '[' . diff . ' lines. ' . markerLine . '] ' . sub1
endfunction
"}}}
function ToggleMainMenu()
if match(&guioptions, 'm') > -1
execute "set guioptions-=m"
execute "set guioptions-=T"
"execute "set guioptions-=e"
" execute "set guioptions+=c"
else
execute "set guioptions+=m"
execute "set guioptions+=T"
"execute "set guioptions+=e"
" execute "set guioptions-=c"
endif
endfunction
map <F10> :call ToggleMainMenu()<cr>
function! GetProtoLine()
let ret = ""
let line_save = line(".")
let col_save = col(".")
let top = line_save - winline() + 1
let so_save = &so
let &so = 0
let istypedef = 0
" find closing brace
let closing_lnum = search('^}','cW')
if closing_lnum > 0
if getline(line(".")) =~ '\w\s*;\s*$'
let istypedef = 1
let closingline = getline(".")
endif
" go to the opening brace
normal! %
" if the start position is between the two braces
if line(".") <= line_save
if istypedef
let ret = matchstr(closingline, '\w\+\s*;')
else
" find a line contains function name
let lnum = search('^\w','bcnW')
if lnum > 0
let ret = getline(lnum)
endif
endif
endif
endif
" restore position and screen line
exe "normal! " . top . "Gz\<CR>"
call cursor(line_save, col_save)
let &so = so_save
return ret
endfunction
function! WhatFunction()
"if !exists("g:WhatFunction")
" return""
"endif
if &ft != "c" && &ft != "cpp" && &ft != "py" && &ft != "php"
return ""
endif
let proto = GetProtoLine()
if proto == ""
return "?"
endif
if stridx(proto, '(') > 0
let ret = matchstr(proto, '\w\+(\@=')
elseif proto =~# '\<struct\>'
let ret = matchstr(proto, 'struct\s\+\w\+')
elseif proto =~# '\<class\>'
let ret = matchstr(proto, 'class\s\+\w\+')
else
let ret = strpart(proto, 0, 15) . "..."
endif
return ret
endfunction
function! WhatFunctionPrint()
echo WhatFunction()
endfunction
map ,fn :call WhatFunctionPrint()<cr>
syntax match Comment "//.*" contains=Todo
syntax match Comment "/*.*" contains=Todo
let g:did_minibufexplorer_syntax_inits = 1
let g:miniBufExplTabWrap = 1
let g:miniBufExplorerMoreThanOne=1
let g:miniBufExplMapCTabSwitchBufs = 1
" Disable plugin
let loaded_minibufexplorer = 1
nnoremap <silent> sj :FufBuffer<CR>
nnoremap <silent> sk :FufFile<CR>
nnoremap <silent> sK :FufFileWithFullCwd<CR>
nnoremap <silent> sy :FufLine<CR>
let g:fuf_splitPathMatching = 0
let g:fuf_maxMenuWidth = 120
autocmd BufEnter * if &filetype == "" | setlocal ft=txt | endif
let g:fuf_modesDisable = [ 'mrufile', 'mrucmd', ]
nmap sj :FufBuffer!<CR>
" ga - info about symbol
" vim: set foldmethod=marker :
" local syntax file - set colors on a per-machine basis:
" vim: tw=0 ts=4 sw=4
" Vim color file
" Maintainer: Ron Aaron <ron@ronware.org>
" Last Change: 2003 May 02
set background=light
hi clear
if exists("syntax_on")
syntax reset
endif
let g:colors_name = "default"
hi cursorline guibg=grey93
hi Comment term=bold ctermfg=Red guifg=grey60
hi Normal guifg=black guibg=white
hi NonText guibg=white guifg=gray90
hi SpecialKey guibg=white guifg=gray90
hi Constant guifg=black
hi Special term=bold guifg=black guibg=White
hi Identifier guifg=black
hi Delimiter guibg=#AAFFAA
hi Statement term=bold gui=bold guifg=Blue
hi PreProc gui=bold guifg=blue
hi Type term=underline ctermfg=Blue gui=NONE guifg=#2233FF
hi Visual term=reverse ctermfg=Yellow ctermbg=Red gui=NONE guifg=Black guibg=Yellow
hi Search term=reverse ctermfg=Black ctermbg=Cyan gui=NONE guifg=Black guibg=#ffff55
hi Tag term=bold ctermfg=DarkGreen guifg=DarkGreen
hi Error term=reverse ctermfg=15 ctermbg=9 guibg=Red guifg=White
hi Todo term=standout ctermbg=Yellow ctermfg=Black guifg=Blue guibg=Yellow
hi StatusLine term=bold,reverse cterm=NONE ctermfg=white ctermbg=black gui=NONE guifg=white guibg=black
hi Ignore guifg=blue
hi lineNr guibg=grey50 guifg=white
hi Error guibg=#FF5555 guifg=black
hi Pmenu guibg=Grey80
hi PmenuSel guibg=Grey40 guifg=white
hi MoreMsg guifg=black guibg=grey80
hi Question guifg=black guibg=grey80
hi! link MoreMsg Comment
hi! link ErrorMsg Visual
hi! link WarningMsg ErrorMsg
hi! link Question Comment
hi String guifg=#CC0000
hi link Character Constant
hi Number guifg=#00C09C
hi link Boolean Number
hi link Float Number
"hi link Function Identifier
hi Function gui=none guibg=white guifg=blue
hi link Conditional Statement
hi link Repeat Statement
hi link Label Statement
hi link Operator Statement
hi link Keyword Statement
hi link Exception Statement
hi link Include PreProc
hi link Define PreProc
hi link Macro PreProc
hi link PreCondit PreProc
hi link StorageClass Type
hi link Structure Type
hi link Typedef Type
hi link SpecialChar Special
" hi link Delimiter Special
hi link SpecialComment Special
hi link Debug Special
hi phpSemicolon guifg=Black
hi phpDoubleColon guifg=Black
"" PHP
" Strings and numbers
hi link phpBracketInString String
hi link phpStringSingle String
hi link phpQuoteSingle String
hi link phpQuoteDouble String
hi link phpNumber Number
hi link phpFloat Number
" Keywords and statement
hi link phpStatement Statement
" hi link phpRegion Statement
hi link phpCase Statement
hi link phpCoreConstant Statement
hi link phpEcho Statement
hi link phpPrint Statement
hi link phpInclude Statement
hi link phpVarSelectorDeref Statement
hi link phpDefine Statement
hi link phpConditional Statement
hi link phpSpecialFunction Normal
" For, while
hi link phpRepeat Statement
hi link phpException Statement
hi link phpStorageClass Statement
hi link phpStorageClass2 Statement
hi phpSpecialFunction guifg=blue
hi phpIntVar guifg=blue
hi link phpFunctions Function
hi link phpBoolean Statement
" Braces, ==, > and etc
hi link phpBraceFunc Normal
hi phpBracketInString guifg=Black
hi link phpParent Normal
hi link phpSpecialChar Normal
hi link phpOperator Normal
" ==, >, <, etc
hi link phpRelation Normal
hi link phpPropertySelector Normal
hi phpVarSelector gui=none guibg=white guifg=black
hi link phpSuperglobal Normal
hi link phpMagicConstant Normal
"" HTML
hi htmlLink gui=NONE guifg=black
hi link htmlEvent htmlArg
hi Javascript guifg=black
hi htmlSpecialTagName guibg=#ddff55 guifg=blue
hi htmlTag guifg=blue gui=none
hi link htmlEndTag htmlTag
hi link htmlTagN htmlTag
hi htmlArg guifg=#009900 gui=none
hi htmlTitle guifg=black
hi DiffAdd guifg=black guibg=#B4FFB4
hi DiffChange guifg=black guibg=#A0C8FF
hi DiffDelete guifg=black guibg=#FFA0B4
hi DiffText guifg=black guibg=#E57FFF
hi link JavascriptNumber Number
hi link JavascriptIdentifier Statement
hi phpRegionDelimiter guibg=#AAFFAA
hi link xmlEndTag xmlTag
hi link yamlKey Type
hi MBEVisibleNormal gui=bold guifg=white guibg=black
hi MBEVisibleChanged gui=bold guifg=#FF7777 guibg=black
hi MBEChanged gui=bold guifg=#DD0000 guibg=white
hi link sqlKeyword Keyword
hi User1 guibg=#FF0000 guifg=#FFFFFF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment