"Vim settings file
"Author: Branislav Sobotka
"Last update: 24.11.2006
"makes vim behave in a more useful way (the default) than the vi-compatible manner.
"Remove the “no” to keep the old vi behavior
set nocompatible
"vim work directory
if has('win32') || has('win32unix') "windows/cygwin
let g:work_dir="e:/brano/vim"
else
let g:work_dir="/home/brano/vim"
endif
"assign name of the edited file to s:fname variable
let s:fname = expand("%")
"assign size of the edited file to s:fsize variable
let s:fsize = getfsize(s:fname)
" Reload settings file everytime its written
function! New_vimrc()
autocmd! bufwritepost * source $VIM/_vimrc
endfunction
"call New_vimrc()
"source $VIMRUNTIME/vimrc_example.vim
"show completion menu Vim 7.0
"set completeopt = menu
"scan only current buffer next options ,w,b,u,t,i
"set complete = ".,t"
"makro starter
let maplocalleader = "?"
"behave mswin
source $VIMRUNTIME/mswin.vim
behave mswin
"Settings for version > 6.0
"Enables vim's syntax highlighting for files smaller than 5MB.
if s:fsize < 5000000
syntax enable
endif
"vmap sp "zdiz
"vmap sp `>a`
filetype on
filetype plugin on
filetype indent on
"fileformat dos or unix
if has('win32') || has('win32unix') "windows/cygwin
set fileformat=dos
else
set fileformat=unix
endif
"timeout for map
set timeout timeoutlen=800
"Basic appearance and behavior
colorscheme darkerdesert
set nowrap
set noexpandtab "This makes vim insert tabs as tab characters instead of as a set of spaces.
set ruler "This makes vim show the current row and column at the bottom right of the screen.
set number
set ignorecase
set incsearch "postupne vyhledavani zapnuto
"set showmatch "When a bracket is inserted, briefly jump to the matching one.
"set matchtime "Tenths of a second to show the matching paren, when 'showmatch' is set.
if has('win32') || has('win32unix') "windows/cygwin
set guifont=Courier_new:h12:w6.5:b:cEASTEUROPE
else
set guifont=-adobe-courier-bold-r-normal-*-*-180-*-*-m-*-iso8859-2
endif
"set guifont=-adobe-courier-bold-r-normal-*-*-180-*-*-m-*-iso8859-2
"file name file path
":echo expand("%")
":echo expand("%:t")
":echo expand("%:e")
"set backUp functions and vim's work directory
"Enables vim's backup functions for files smaller than 5MB.
if s:fsize < 5000000
set backup
let backup = g:work_dir . "/backup"
let tmp = backup . "/" . expand("%:e")
"echo "syntax is" . expand("%:e")
"echo "tabstop is " . &tabstop
"echo backup
if exists("*mkdir")
if !isdirectory(backup)
call mkdir(backup)
endif
if !isdirectory(tmp)
call mkdir(tmp)
endif
endif
let myvar = "set backupdir=" . tmp
silent execute myvar
let myvar = strftime("_%y%m%d_%Hh")
let myvar = "set backupext=_". myvar
execute myvar
unlet backup
endif
let myvar = "set directory=" . g:work_dir "set swap directory
execute myvar
unlet myvar
"backup command
"cabbrev ba call WriteBackup()
" A mapping to make a backup of the current file.
" %:p - return name of script with path
"fun! WriteBackup()
" let mybackupdir = "backup/"
" let loc_fname = s:fname . "__" . strftime("(%y%m%d)[%Hh]")
" execute ":w " . g:work_dir . "/" . mybackupdir . loc_fname
" echo "Wrote " g:work_dir mybackupdir loc_fname
"endfun
if has('title')
"set titlestring=%t%(\ %M%)%(\ (%{expand(\"%:~:.:h\")})%)%(\ %a%)
set titlestring=%t%(\ [%R%M]%)\ %y\ (%F)%=buffer\ %n
set titlelen=120
endif
"buffer switching
nmap > :bn
nmap < :bp
"with the following code you can hightlight (using cursorline) the current line in insert mode
"autocmd InsertLeave * se nocul
"autocmd InsertEnter * se cul
"vimgrep next previous
map :cn
map :cn
imap :cp
imap :cp
"Compare files
set diffexpr=MyDiff()
function! MyDiff()
let opt = ''
if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif
if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif
silent execute '!"F:\Program Files\vim\vim63\diff" -a ' . opt . '"' . v:fname_in . '" "' . v:fname_new . '" > "' . v:fname_out . '"'
endfunction
"TAB config Do not change or read help tabstop
set shiftwidth=4
set tabstop=4
set softtabstop=4
set noexpandtab
"search selected text by * and #
vnoremap * y/"
vnoremap # y?"
"GUI
"my start
set guioptions=mrh
"maximalized window
:au GUIEnter * simalt ~x
"normal start
"set go=gmrLtT
"highlight Normal guibg=#015076 guifg=yellow
"highlight Comment guifg=#5889dd
"TIPS
"To count the words in a file: g
"# Retrieving last command line command for copy & pasting into text
":
"# Retrieving last Search Command for copy & pasting into text
"/
"'gv' reselect the previous visual area
"'gf' stands for "goto file" it opens the file under cursor. it is very useful for opening include files.
":v/^\d/d will delete all lines that don't start with a digit.
"Eliminate empty lines: v/\S/d
"Eliminate spaces at the beginning of each line: %s/^\s\+//
"Eliminate spaces at the end of the each line:%s/\s\+$//
"HELP
":Calendar - details: plugin/calendar.vim
":ColorSel - color selector details: plugin/colorsel.vim
":Asctable - asci table details: plugin/asciitable.vim
":windo - To do repeat a command in all the windows
":bufdo - Similarly to do repeat a command in all the buffers
"Example :bufdo %s/katka//g
":reg : display contents of all registers
"command line abbreviations ****
"save options
cabbrev fi set foldmethod=indent
cabbrev aw set autowrite
cabbrev +b set guioptions +=b
cabbrev -b set guioptions -=b
cabbrev N tabnew
cabbrev sxml set syntax=xml
cabbrev svb set syntax=vb
cabbrev vxml ! cscript D:\bat\vim\xmlvalidate.vbs %
cabbrev vhtml ! D:\bat\vim\tidy.exe %
"Regular expressions for Code Correction
"type=text ---> type="text"
cabbrev reg1 %s/=\([^"][^> ]\{0,40\}\)/="\1"/gc
" --->
cabbrev reg2 :%s///gc
" --->
"cabbrev reg3 :%s///gc
"pos=1 ---> pos = 1
cabbrev reg3 :%s/\([^ ]\)=\([^ ]\)/\1 = \2/gc
"fun(a,b) ---> fun(a, b)
cabbrev reg4 :%s/\([^ ]\),\([^ ]\)/\1, \2/gc
"delete empty end of lines
cabbrev del1 :%s/\s*$//g
"delte empty lines
cabbrev del2 :g!/^dd/d
"reverse line in file
cabbrev rev1 :g/^/m0
"let g:miniBufExplMapWindowNavVim = 1
"let g:miniBufExplMapWindowNavArrows = 1
"let g:miniBufExplMapCTabSwitchBufs = 1
"let g:miniBufExplModSelTarget = 1
"GIU
if has("gui")
nnoremenu My_tools.Set\ language\ to\ "en"\ and\ Spelllen :set spl=en spell
inoremenu My_tools.Set\ language\ to\ "en"\ and\ Spelllen :set spl=en spell
nnoremenu My_tools.Set\ language\ to\ "cs"\ and\ Spelllcs :set spl=cs spell
inoremenu My_tools.Set\ language\ to\ "cs"\ and\ Spelllcs :set spl=cs spell
nnoremenu My_tools.Set\ language\ to\ "sk"\ and\ Spelllsk :set spl=sk spell
inoremenu My_tools.Set\ language\ to\ "sk"\ and\ Spelllsk :set spl=sk spell
nnoremenu My_tools.Set\ nospelloffspl :set nospell
nnoremenu My_tools.Set\ nospelloffspl :set nospell
:amenu My_tools.-Sep0- :
nnoremenu My_tools.Delete\ empty\ end\ of\ linesdel1 :%s/\s*$//g
inoremenu My_tools.Delete\ empty\ end\ of\ linesdel1 :%s/\s*$//g
:amenu My_tools.-Sep0- :
nnoremenu My_tools.RegExp:\ type=text\ --->\ type="text"reg1 :%s/=\([^"][^> ]\{0,40\}\)/="\1"/gc
inoremenu My_tools.RegExp:\ type=text\ --->\ type="text"reg1 :%s/=\([^"][^> ]\{0,40\}\)/="\1"/gc
nnoremenu My_tools.RegExp:\ img\ >\ --->\ img\ />reg2 :%s///gc
inoremenu My_tools.RegExp:\ img\ >\ --->\ img\ />reg2 :%s///gc
nnoremenu My_tools.RegExp:\ pos=1\ --->\ pos\ =\ 1reg3 :%s/\([^ ]\)=\([^ ]\)/\1 = \2/gc
inoremenu My_tools.RegExp:\ pos=1\ --->\ pos\ =\ 1reg3 :%s/\([^ ]\)=\([^ ]\)/\1 = \2/gc
nnoremenu My_tools.RegExp:\ fun(a,b)\ --->\ fun(a,\ b)reg4 :%s/\([^ ]\),\([^ ]\)/\1, \2/gc
inoremenu My_tools.RegExp:\ fun(a,b)\ --->\ fun(a,\ b)reg4 :%s/\([^ ]\),\([^ ]\)/\1, \2/gc
endif
"Whenever you type in a ) in insert mode, the cursor will jump to the corresponding (, then jump back 300 milliseconds later.
"imap ) )%:300sleep m%a
" change directory to that of current file
nmap cd :cd%:p:h
" change local directory to that of current file
nmap lcd :lcd%:p:h
" justify source code
"nmap ggVG=
"moving lines up down
map dd-P
map ddp
"my WEB DLL abbreviations ****
map xxh iSWlib.RunXmlXsl2Html(CStr(xml),"*.xsl",,pole)i
map sx iSWlib.SQLQuer2XMLStr(sql,"data")i
map msx iSWlib.MultiSQLQuer2XMLStr(sql_pole,0)i
"the most useable XSL abbreviations, other are available from xGen menu, xGen.vim ****
map ch ii
map for ii
map if ii
map se ii
map co ii
map ss ii
map ou ii
map te ii
map ap ii
map at ii
map ca ii
map st ii
map va iki
map wi i^f"a
"the most useable HTML abbreviations , other are available from xGen menu or xhtml menu xhtml.vim****
imap input 21hi
imap html
imap iframe
imap tab
imap img 20hi
imap a 5hi
imap A yiWi3hP4la
imap c 4hi
vmap c "zdi
vmap sb "zdiz : wrap around VISUALLY selected Text
imap <>>5hdiwp3lpT>i
imap >3hdiwpa 3la
"Javascript abbreviations ****
map fn ifunction () { var }i
map bn idocument.getElementsByName("")[0].i
map bid idocument.getElementById("").i
"SQL abbreviations ****
map se iSELECT FROM WHEREi
map up iUPDATE SET WHEREi
"LINE NUMBERS mapping for F11
"function! NumberNo()
" set nonumber
" map :call NumberYes()
" imap :call NumberYes()
"endfunction
"function! NumberYes()
" set number
" map :call NumberNo()
" imap :call NumberNo()
"endfunction
"Default
"map :call NumberNo()
"imap :call NumberNo()
cabbrev pytab call Pytab()
function! Pytab()
set ts=8
set expandtab
retab
set ts=4
set noexpandtab
retab!
echo "python tab tabstop=4 ok"
endfunction
function! HtmlInit()
set filetype=html
set autoindent
set shiftwidth=2
set softtabstop=2
"set nowrap
colorscheme torte
hi LineNr guifg=#006666 guibg=black
endfunction
function! XSLInit()
set filetype=xsl
set syntax=xsl
set autoindent
set shiftwidth=2
set softtabstop=2
"set nowrap
"map :call NumberYes()
"imap :call NumberYes()
colorscheme torte
endfunction
function! ASPInit()
set syntax=aspvbs
"set autoindent
"abbreviations
ab iif iif(,,)3ha
ab hrep html = Replace(html, "", "")6ha
ab ++ 1hdiw1hpa = pa + 1
"ab -- 1hdiw1hpa = pa - 1
let myvar = "set dictionary=" . g:work_dir . "/dictionaries/asp.dict"
silent execute myvar
unlet myvar
"inoremap =Quotereturn("asp")
"set nowrap
"map :call NumberYes()
"imap :call NumberYes()
"syntax keyword Type byval
"colorscheme af
"colorscheme rootwater
colorscheme darkerdesert
"colorscheme murphy
"hi LineNr guifg=#006666 guibg=black
endfunction
function! VBInit()
set autoindent
set syntax=vb
"set nowrap
"inoremap =Quotereturn("asp")
"map :call NumberYes()
"imap :call NumberYes()
colorscheme murphy
hi LineNr guifg=#006666 guibg=black
endfunction
function! JSInit()
set cindent
set expandtab
"set nowrap
"map :call NumberYes()
"imap :call NumberYes()
colorscheme murphy
hi LineNr guifg=#006666 guibg=black
endfunction
function! PHPInit()
set syntax=php
set cindent
set expandtab
"set nowrap
"map :call NumberYes()
"imap :call NumberYes()
colorscheme oceandeep
endfunction
function! LogInit()
"set nowrap
colorscheme elflord
syntax keyword Type INFO
syntax keyword String WARN
syntax keyword String WARNING
syntax keyword Error ERR
syntax keyword Error ERROR
"syn keyword cMyItem contained INFO
"syn cluster cCommentGroup add=cMyItem
"hi link cMyItem Error
endfunction
function! PyInit()
set smartindent
"set cinwords
set foldmethod=indent
set foldnestmax=1
"set nowrap
"inoremap =Quotereturn("python")
map :call ShowPyDoc('', 1)
"map :call NumberYes()
"imap :call NumberYes()
colorscheme murphy
hi LineNr guifg=#006666 guibg=black
endfunction
function! CSSInit()
set shiftwidth=2
set softtabstop=2
"set nowrap
"map :call NumberYes()
"imap :call NumberYes()
set nonumber
"colorscheme oceandeep
endfunction
function! WMLInit()
set autoindent
set shiftwidth=2
set softtabstop=2
set nonumber
colorscheme torte
endfunction
function! RewriteInit()
syn clear
syn keyword rewrite_modStatement RewriteCond RewriteRule RewriteHeader RewriteProxy
syn keyword rewrite_modStatement RepeatLimit CacheClockRate EnableConfig DisableConfig EnableRewrite DisableRewrite RFStyle
syn keyword rewrite_modType URL METHOD VERSION
syn keyword rewrite_modType Accept Accept-Charset Accept-Encoding Accept-Language Authorization Cookie From Host If-Modified-Since If-Match If-None-Match If-Range If-Unmodified-Since Max-Forwards Proxy-Authorization Range Referer User-Agent
syn match rewrite_modComment "#.*$" contains=rewrite_modTodo
syn keyword rewrite_modTodo TODO FIXME XXX contained
syn match String "\$\d\+"
syn match String "([^()]*)"
syn match PreProc "\[[,IURPLFONSC]*\]"
if version >= 508 || !exists("did_rewrite_mod_syn_inits")
if version <= 508
let did_rewrite_mod_syn_inits = 1
command -nargs=+ HiLink hi link
else
command -nargs=+ HiLink hi def link
endif
HiLink rewrite_modStatement Statement
HiLink rewrite_modComment Comment
HiLink rewrite_modTodo Todo
HiLink rewrite_modString String
HiLink rewrite_modType Type
delcommand HiLink
endif
endfunction
"autocommands
au BufNewFile,BufRead httpd.ini call RewriteInit()
au BufNewFile,BufRead *.html,*.htm call HtmlInit()
au BufNewFile,BufRead *.wml call WMLInit()
au BufNewFile,BufRead *.xsl call XSLInit()
au BufNewFile,BufRead *.vbs,*.vb call VBInit()
au BufNewFile,BufRead *.asp,*.obr,*.dat,*.aspx call ASPInit()
au BufNewFile,BufRead *.js call JSInit()
au BufNewFile,BufRead *.log call LogInit()
au BufNewFile,BufRead *.py call PyInit()
au BufNewFile,BufRead *.txt set nonumber
au BufNewFile,BufRead *.php call PHPInit()
au BufNewFile,BufRead *.css call CSSInit()
" If the cursor is in the middle of a quote block when is pressed
" a quote is added to the end of the line followed by a plus, a
" and another quote.
function! Quotereturn(lang)
let before=strpart(getline(line(".")), 0, col(".")-1)
"let after=strpart(getline(line(".")), col("."))
if(before =~ '^\([^"]*"\([^"\\]\|\\.\)*"\)*[^"]*"\([^"\\]\|\\.\)*$')
if a:lang == "asp"
return "\" & _\"\