" rename this file as .vimrc and place in your home
" vim conf by Dylan
""" - ON opcje ustawione
set ru " wlacza status z pozycja kursora
set sm " pokazuje dopasowanie nawiasow
set sc " pokazuje komende w wierszu statusu
set ic " wlacza ignorowanie wielkosci liter przy szukaniu
set is " wlacza inkrementalne szukanie
set ai " wlacza autowcinanie kolejnego wiersza
set si " wlacza inteligentne wcinanie
set lz " lazyredraw - nie rysuje ekranu przy wykonywaniu makra
""" - OFF opcje wylaczone
set nocp " tryb zaawansowany vima (niekompatybilny z vi)
set nori " tryb pisania od lewej do prawej
set norl " tryb wyswietlania od lewej do prawej
set nobk " nie robi backupu pliku przed zapisem
set novb " wylacza miganie (zamiast dzwonka)
set noet " wylacza rozwijanie tabulatorow do spacji
set scs " wylacza ignorowanie wielkosci liter wyszukiwania jezeli sa we wzorcu wielkie litery
set tf " ustawia szybki terminal
set nohls " wylacza wyroznienia znalezionych tekst
""" - opcje parametryczne
set bs=2 " backspace jest rowny przesunieciu o 2 spacje
set wm=0 " margines po ktorym tekst jest zawijany
set tw=0 " szerokosc tekstu nieograniczona
set ts=2 " dlugosc tabulatora w znakach
set st=2 " dlugosc inteligentnego tabulatora
set sw=2 " dlugosc przesuniecia po tab
set so=2 " dwie linie przed i po ekranie powoduja juz przewijanie
set ss=25 " wielkosc przewiniecia poziomego przy wyjsciu poza ekran
set go=fc " wylacza wszystkie dodatki gui
set hh=10 " wysokosc okna pomocy
"set fo=tcq " opcje formatowania kodu
set fo=tcrqn2
set bg=dark " standardowy model kolorow
"set wh=25 " minimalna wysokosc aktywnego okna (dobre!)
set hh=10 " wysokosc okna z helpem
set mat=2 " dlugosc w n*0.1s pokazywania dopasowania nawiasow
set mls=10 " ilosc linii od koncow ktora jest sprawdzana na #vim ...
""" - polecenia
set modeline " pokazuj wiersz stanu
set nowrap " nie zawijaj wierszy
set diffopt+=iwhite " ignorowanie bialych znakow podczas vimdiff
set viminfo='20,\"50 " read/write a .viminfo file, don't store more than
set history=1000 " pamietaj 100 linii historii polecen po : / ? itp.
set suffixes=.bak,~,.swp,.o,.info,.aux,.log,.dvi,.bbl,.blg,.brf,.cb,.ind,.idx,.ilg,.inx,.out,.toc
set statusline=%<%f%=\ [%1*%M%*%n%R%H]\ %-19(%3l,%02c%03V%)\ \b\:%-04O\ \c\:%03b\ %P
set hf=$VIMRUNTIME/doc/help.txt " albo help.txt.gz jezeli jest spakowany
set pastetoggle=<F6> " wlaczenie/wylaczenie trybu 'paste'
set wildmode=longest,list " ustawienie podpowiedzi polecenia po <tab> w trybie komend
set wildmenu
set enc=iso-8859-2 " ustawia enkoding
set nohls " wylacza wyroznienia znalezionych tekst
set magic " zmiana sposob traktowania backslashy w wyrazenia regularnych
set display=lastline " pokazuje ostatnia linie, nawet jak sie ona nie miesci
set nolist " nie pokazuje znakow tab, koncow linii
set cinoptions={.5s,+.5s,t0,n-2,p2s,(03s,=.5s,>1s,=1s,:1s
set complete=.,w,b,u,t,i " dopelnianie
" nie wiem co to robi, ale poczytam w helpie :)
"set infercase
"set nosft
"set lines=999 " ustawienie rozmiarow w pionie na maksa (zmienia wymiar okna)
"set columns=999 " ustawienie rozmiarow w poziomie na maksa
" niestety, czasami jak okono zostalo zmaksymalizowane, vim dziwnie sie
" zachowywal, wiec to wylaczylem
""" konfiguracja pod katem pracy w perlu (!!!GREAT!!!)
let perl_fold=1 " zawijanie wierszy w perlu po zc, za, itp.
"let perl_fold_blocks = 1 " zwijanie blokow, troszke wkurzajace
let perl_include_pod = 1 " podswietlanie segmentow POD'a
let perl_want_scope_in_variables = 0 " rozpoznawanie dlugich nazw pakietowych ($PkgName::Var)
let perl_extended_vars = 1 " zmienne wielokrotnie interpolowane @{${'foo'}}
let perl_sync_dist = 15000 " synchronizacja kolorowania zaczyna sie X linii wczesniej niz widac
syn sync minlines=10000 maxlines=10000 " syncowanie wierszy wzgl. biezacej pozycji
let perl_sql_query = 1 " experimental
""" konfiguracja pod katem pracy w PHP (co za beka, heh)
let php_sql_query = 1 " kolorowanie skladni SQL w zapytaniach
let php_htmlInString = 1 " kolorowanie HTMLa w napisach
let php_folding = 1 " zwijanie wierszy
let php_parent_error_close = 1 " podswietlanie blednie zamknietego nawiasu
let html_use_css = 1
""" polecenia, aliasy, makra i mapowane sekwencje
syn on " wlacz kolorowanie skladni
"ino # # " sprytne pisanie #
let &ro = &ro " odswiezenie wiersza statusu
if has("gui_running")
" set guifont=fixed
set nohls
cab q :echo "Moliwowyjcia jest wyczona. Uyj Shift+ZZ"
cab Q :quit!
cab W w
else
cab Q q " alias na Q
cab W w " alias na W (teraz dziala tez :WQ)
endif
if has("autocmd")
augroup cprog
au!
autocmd BufRead * set formatoptions=tcql nocindent comments&
autocmd BufRead *.c,*.h set formatoptions=croql cindent comments=sr:/*,mb:*,el:*/,://
augroup END
au BufEnter *.pl if getline(1) == "" | :call setline(1, "#!/usr/bin/perl -w") | endif
au BufEnter *.pl set makeprg=perl\ -wc\ %
endif " has ("autocmd")
augroup filetype
au BufRead reportbug.* set ft=mail
augroup END
""" makra do VIMA :)
map Q gqap " formatowanie tekstu po Shift-q
map <F2> :so ~/.vimrc<CR> " po F2 przeladowanie konfiguracji - pomocne - gdy ja zmieniasz
map <S-F2> <Esc>:so ~/.vim-colors-bold<CR> " wylacza pogrubione czcionki w ustawieniach kolorow
map <C-F2> :so ~/.vim-colors+bold<CR> " wlacza pogrubione czcionki
map <F3> :set guifont=*<CR> " po F3 w tybie gui pokazuje okno wyboru czcionki
map <F4> :if exists("syntax_on")<Bar>syntax off<Bar>else<Bar>syntax enable<Bar>endif<CR>
map <S-F4> :syntax on<CR>
"map <F5> Yp:s/./-/g<CR>:let @/=""<CR>:<CR> " wstawia kreske z minusow POD wiersz w ktorym jestes
map <F5> YpVr- " to makro jest odpowiednikiem powyzszego ale ktorsze :>
map <F9> :make<CR> " kompilacja po F9, jezeli ustawiono kompilator (dla perla - perl -wc)
map <F10> :!make<CR> " zewnetrzna kompilacja przez make (np. moze robic dokumentacje
map <A-Down> <C-W><Down>
map <A-Up> <C-W><Up>
map <A-Right> <C-W><Right>
map <A-Left> <C-W><Left>
fu! ChangeFont()
if has("gui_running")
if g:fontnr < 1
" set guifont=fixed
let g:fontnr = 1
elseif g:fontnr == 1
" set guifont=courier
let g:fontnr = 0
endif
map <S-F3> :call ChangeFont()<CR>
endif
endf
fu! Compile()
perl<<EOP
$mrn = "Compilation";
$cmd = "bo 5new";
VIM::DoCommand('w!/tmp/file.pl');
if($main::curbuf->Name() ne $mrn) {
&VIM::DoCommand("$cmd");
&VIM::DoCommand("e $mrn");
};
if($main::curbuf->Name() ne $mrn) {
&VIM::DoCommand("e $mrn");
}
$main::curbuf->Delete(1, $main::curbuf->Count);
&VIM::DoCommand("0r!perl -wc /tmp/file.pl");
&VIM::DoCommand('!rm -f /tmp/file.pl');
EOP
set nomodified
endf
map ;m <C-W>99k:call Compile()<C-M><C-M><C-W>j
map <C-U> <C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y>
map <C-D> <C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E>
map ' `
function! ShowFunc()
let gf_s = &grepformat
let gp_s = &grepprg
let &grepformat = '%*\k%*\sfunction%*\s%l%*\s%f %*\s%m'
let &grepprg = 'ctags -x --c-types=f --sort=no -o -'
write
silent! grep %
cwindow
let &grepformat = gf_s
let &grepprg = gp_s
endfunction
function! OpenCurrentDir()
let g:explVertical=1
" let g:explSplitRight=1
let g:explWinSize=""
let g:explHideFiles='^\.,\.gz$,\.exe$,\.zip$,\.gz$,\.t?gz$'
20vs
"Explore .
e .
set nomodified
endfunction
map <F1> :call OpenCurrentDir()<cr>
function! InsertTabWrapper(direction)
let col = col('.') - 1
if !col || getline('.')[col - 1] !~ '\k'
return "\<tab>"
elseif "backward" == a:direction
return "\<c-p>"
else
return "\<c-n>"
endif
endfunction
inoremap <tab> <C-R>=InsertTabWrapper("backward")<cr>
inoremap <s-tab> <C-R>=InsertTabWrapper("forward")<cr>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""''
""" konfiguracja gui
set guifont=courier
""" konfiguracja kolor
let &bg = &bg " pseudodefinicja koloru tla
if &term =~ "xterm" || &term =~ "xterm-debian" || &term =~ "xterm-xfree86"
set t_Co=16
set t_Sf=<Esc>[3%dm
set t_Sb=<Esc>[4%dm
endif
hi clear Normal " ustaw explicite kolor background'a
set bg& " ustaw kolor bg
hi clear " usun definicje kolorow
if exists("syntax_on")
syntax reset " zaladuj standardowe definicje kolorow, jezeli sa wlaczone
endif
" konfiguracja kolorow jest od teraz wciagana z pliku
" inna konfiguracja bez pogrubienia (dla grubych czcionek) jest w
" pliku .vim-colors+bold
" source ~/.vim-colors-bold
set guicursor=n-v-c:block-Cursor
set guicursor+=i:ver200-iCursor
set guicursor+=n-v-c:blinkon0-Cursor
set guicursor+=i:blinkwait90-iCursor
set guicursor=n-v-c:block-Cursor/lCursor,ve:ver25-Cursor,o:hor50-Cursor,i-ci:ver25-iCursor/lCursor,r-cr:hor20-rCursor/lCursor,sm:block-Cursor-blinkwait175-blinkoff15-blinkon15
" mat Todo / \?TODO|FIXME|UOO \?/
" mat Uoo /#UOO/
" mat Uoo /# UOO/
" mat Uoo /" UOO/
"syn on
" vim: nowrap:ts=2:st=2:sw=2:tw=0:fo=tcql:noic:noet
" Vim syntax file
" Language: Lex
" Maintainer: Dr. Charles E. Campbell, Jr. <NdrOchipS@PcampbellAfamily.Mbiz>
" Last Change: Sep 06, 2005
" Version: 7
" URL: http://mysite.verizon.net/astronaut/vim/index.html#vimlinks_syntax
"
" Option:
" lex_uses_cpp : if this variable exists, then C++ is loaded rather than C
" For version 5.x: Clear all syntax items
" For version 6.x: Quit when a syntax file was already loaded
if version < 600
syntax clear
elseif exists("b:current_syntax")
finish
endif
" Read the C syntax to start with
if version >= 600
if exists("lex_uses_cpp")
runtime! syntax/cpp.vim
else
runtime! syntax/c.vim
endif
unlet b:current_syntax
else
if exists("lex_uses_cpp")
so <sfile>:p:h/cpp.vim
else
so <sfile>:p:h/c.vim
endif
endif
" --- ========= ---
" --- Lex stuff ---
" --- ========= ---
"I'd prefer to use lex.* , but it doesn't handle forward definitions yet
syn cluster lexListGroup contains=lexAbbrvBlock,lexAbbrv,lexAbbrv,lexAbbrvRegExp,lexInclude,lexPatBlock,lexPat,lexBrace,lexPatString,lexPatTag,lexPatTag,lexPatComment,lexPatCodeLine,lexMorePat,lexPatSep,lexSlashQuote,lexPatCode,cInParen,cUserLabel,cOctalZero,cCppSkip,cErrInBracket,cErrInParen,cOctalError,cCppOut2,cCommentStartError,cParenError
syn cluster lexListPatCodeGroup contains=lexAbbrvBlock,lexAbbrv,lexAbbrv,lexAbbrvRegExp,lexInclude,lexPatBlock,lexPat,lexBrace,lexPatTag,lexPatTag,lexPatComment,lexPatCodeLine,lexMorePat,lexPatSep,lexSlashQuote,cInParen,cUserLabel,cOctalZero,cCppSkip,cErrInBracket,cErrInParen,cOctalError,cCppOut2,cCommentStartError,cParenError
" Abbreviations Section
syn region lexAbbrvBlock start="^\(\h\+\s\|%{\)" end="^\ze%%$" skipnl nextgroup=lexPatBlock contains=lexAbbrv,lexInclude,lexAbbrvComment,lexStartState
syn match lexAbbrv "^\I\i*\s"me=e-1 skipwhite contained nextgroup=lexAbbrvRegExp
syn match lexAbbrv "^%[sx]" contained
syn match lexAbbrvRegExp "\s\S.*$"lc=1 contained nextgroup=lexAbbrv,lexInclude
syn region lexInclude matchgroup=lexSep start="^%{" end="%}" contained contains=ALLBUT,@lexListGroup
syn region lexAbbrvComment start="^\s\+/\*" end="\*/" contains=@Spell
syn region lexStartState matchgroup=lexAbbrv start="^%\a\+" end="$" contained
"%% : Patterns {Actions}
syn region lexPatBlock matchgroup=Todo start="^%%$" matchgroup=Todo end="^%%$" skipnl skipwhite contains=lexPat,lexPatTag,lexPatComment
syn region lexPat start=+\S+ skip="\\\\\|\\." end="\s"me=e-1 contained nextgroup=lexMorePat,lexPatSep contains=lexPatString,lexSlashQuote,lexBrace
syn region lexBrace start="\[" skip=+\\\\\|\\+ end="]" contained
syn region lexPatString matchgroup=String start=+"+ skip=+\\\\\|\\"+ matchgroup=String end=+"+ contained
syn match lexPatTag "^<\I\i*\(,\I\i*\)*>*" contained nextgroup=lexPat,lexPatTag,lexMorePat,lexPatSep
syn match lexPatTag +^<\I\i*\(,\I\i*\)*>*\(\\\\\)*\\"+ contained nextgroup=lexPat,lexPatTag,lexMorePat,lexPatSep
syn region lexPatComment start="^\s*/\*" end="\*/" skipnl contained contains=cTodo skipwhite nextgroup=lexPatComment,lexPat,@Spell
syn match lexPatCodeLine ".*$" contained contains=ALLBUT,@lexListGroup
syn match lexMorePat "\s*|\s*$" skipnl contained nextgroup=lexPat,lexPatTag,lexPatComment
syn match lexPatSep "\s\+" contained nextgroup=lexMorePat,lexPatCode,lexPatCodeLine
syn match lexSlashQuote +\(\\\\\)*\\"+ contained
syn region lexPatCode matchgroup=Delimiter start="{" matchgroup=Delimiter end="}" skipnl contained contains=ALLBUT,@lexListPatCodeGroup
syn keyword lexCFunctions BEGIN input unput woutput yyleng yylook yytext
syn keyword lexCFunctions ECHO output winput wunput yyless yymore yywrap
" <c.vim> includes several ALLBUTs; these have to be treated so as to exclude lex* groups
syn cluster cParenGroup add=lex.*
syn cluster cDefineGroup add=lex.*
syn cluster cPreProcGroup add=lex.*
syn cluster cMultiGroup add=lex.*
" Synchronization
syn sync clear
syn sync minlines=300
syn sync match lexSyncPat grouphere lexPatBlock "^%[a-zA-Z]"
syn sync match lexSyncPat groupthere lexPatBlock "^<$"
syn sync match lexSyncPat groupthere lexPatBlock "^%%$"
" The default highlighting.
hi def link lexSlashQuote lexPat
hi def link lexBrace lexPat
hi def link lexAbbrvComment lexPatComment
hi def link lexAbbrvRegExp Macro
hi def link lexAbbrv SpecialChar
hi def link lexCFunctions Function
hi def link lexMorePat SpecialChar
hi def link lexPatComment Comment
hi def link lexPat Function
hi def link lexPatString Function
hi def link lexPatTag Special
hi def link lexSep Delimiter
hi def link lexStartState Statement
let b:current_syntax = "lex"
" vim:ts=10
let g:miniBufExplMapWindowNavVim = 1
let g:miniBufExplMapWindowNavArrows = 1
let g:miniBufExplMapCTabSwitchBufs = 1
let g:miniBufExplModSelTarget = 1
" Zhang Le's personal vimrc file.
" vim600:fdm=marker
" Last Change : 30-Jan-2005.
"
" To use it, copy it to
" for Unix and OS/2: ~/.vimrc
" for MS-DOS and Win32: $VIM\.vimrc
"
" [Key binding summary] {{{
" normal mode:
" Q quit vim without saving
" W quit vim after saving all buffers
" C call Compile() to compile current file
" H scroll screen up like pageup
" L scroll screen down like pagedown
" S call aspell to do spell correction
" ,, jump to tag under cursor, same as <C-]>
" .. jump back to last position, same as <C-T>
" ,b open buffer explorer
" ,h update tag list window
" ,t open tag list window
" ,w open winmanager file explorer window
" _Y yank text to a temp file
" _P paste text from a temp file
" ,u reload vimrc file
" ,v view vimrc file
" ;b reduce a sequence of empty lines into a single line
" ;n reduce a sequence of blank lines into a single line
" \z fold matched lines after a search
" gf open filename under cursor
"
" <F3> quickfix next error
" <F4> quickfix previous error
" <F8> equal split windows
" <F9> Grep word under cursor
"
" <C-S> save current buffer
" <C-j>, <C-k>, <C-h>, <C-l> quickly move between split windows
"
" insert mode:
" <C-j> ???
" <C-A> <Home>
" <C-B> <Left>
" <C-E> <End>
" <C-F> <Right>
" <C-D> <Delete>
"
" visiual mode:
" <C-m> call EnhancedCommentify to comment/uncomment current selection
" _Y yank text to a temp file
"
" Abbreviations:
" Ydate insert current date eg:2005-01-06
" Ytime insert current time eg:20:16
" Ydt insert both date and time eg:2005-01-06 20:17
" }}}
" Platform dependent options {{{
if has("win32")
let $VIMDIR="$VIM\\.vim"
set runtimepath=$VIMRUNTIME,$VIMDIR
set backupdir=$TEMP
set directory=$TEMP
else
let $VIMDIR="$HOME/.vim"
set backupdir=./.backup,~/tmp/vim-backup,/tmp
set directory=./.backup,~/tmp/vim-backup,/tmp
endif
" }}}
" General Option {{{
"
" Use Vim settings, rather then Vi settings (much better!).
" This must be first, because it changes other options as a side effect.
set nocompatible
set makeprg=jam "TODO: automatically detect jam in path before setting this
set encoding=Chinese
" allow backspacing over everything in insert mode
set backspace=indent,eol,start
" always want clipboard selection
set clipboard=unnamed
set autoindent " always set autoindenting on
set backup " keep a backup file
"set keywordprg=screen\ man
" Set your grep program to alway generate a file-name.
set grepprg=grep\ -nH\ $*
set fdm=marker
set formatoptions=tcqor " start new comments when hitting o or O or <enter>
set dictionary=/usr/share/dict/words
set winminheight=0
set shortmess=a
set helpheight=100
set history=100 " keep 100 lines of command line history
set ruler " show the cursor position all the time
set showcmd " display incomplete commands
set showmatch " Show the matching bracket for the last ')'?
set incsearch " do incremental searching
set nostartofline
" set noerrorbells
set visualbell
set suffixes=~,.aux,.bak,.dvi,.gz,.idx,.log,.ps,.swp,.tar,.o " those files are ignored on completion
set textwidth=78
set tabstop=4
set backspace=2
set expandtab
set shiftwidth=4
set ignorecase
set smartcase
set wrapmargin=2
set nowrap
" Add the dash ('-'), the dot ('.'), and the '@' as "letters" to "words".
" This makes it possible to expand email and html addresses,
" eg guckes-www@vim.org and http://www.vim.org/
"set iskeyword=@,48-57,_,192-255,-,.,:,/,@-@
set iskeyword=@,48-57,_,128-167,224-235
"set list
"set listchars=tab:>-,extends:>,precedes:<,trail:
set comments=b:#,:%,n:>
set viminfo=%,'50,\"100,:500,n~/.viminfo
set whichwrap=<,>,h,l,[,]
" display current time on statusline
set laststatus=2 "always want status line
set statusline=%<%f\ %y%h%m%r%=%l,%c\ \ \ \ %P\ %{strftime('%H:%M')}
"set statusline=%<%f%h%m%r%=%l,%c\ \ \ \ %P\ %{strftime('%b\ %d\ %H:%M')}
"set statusline=[%n]\ %f\ %(\ %M%R%H)%)\=Pos=<%l\,%c%V>\ %P
" end of general options}}}
" Gui (gvim) options {{{
if &t_Co > 2 || has("gui_running")
syntax on
" for unix only
"set guifont=-adobe-courier-medium-r-normal-*-*-180-*-*-m-*-iso8859-9
set hlsearch
set nohls
" colorscheme console
endif
"}}}
" Plugin Option {{{
" bufexplorer.vim
nmap ,b <LEADER>be
" winmanager.vim
nmap ,w :WMToggle<cr>
let g:winManagerWidth = 20
let g:winManagerWindowLayout = "FileExplorer"
" vimspell.vim
let spell_executable = "aspell"
let spell_root_menu = '-'
let spell_insert_mode = 0
let spell_auto_type = "mail,text,html,sgml"
"let spell_update_time = 2000
let spell_update_time = 0
" xml.vim
let xml_tag_completion_map=0
" EnhCommentify.vim
" now Ctrl-M is used to toggle comment
vmap <C-m> <Plug>Traditional
" autodate.vim
let autodate_keyword_pre='\cLast Change *:'
let autodate_lines=30
" taglist.vim
noremap ,t :Tlist<CR><C-W>w
noremap ,h :TlistSync<CR>
let Tlist_Sort_Type = "name"
let Tlist_WinWidth=28
let Tlist_Inc_Winwidth = 0
let Tlist_Use_Right_Window = 1
" tex.vim
let g:TeX_do_init = 1
" mail.vim
let mail_erase_quoted_sig = 1
" for grep.vim plugin
let Grep_Path = 'grep'
let Grep_Key = '<F9>'
" end of setting plugin options}}}
" Auto Command {{{
" Only do this part when compiled with support for autocommands.
if has("autocmd")
" Enable file type detection.
" Use the default filetype settings, so that mail gets 'tw' set to 72,
" 'cindent' is on in C files, etc.
" Also load indent files, to automatically do language-dependent indenting.
filetype plugin indent on
au BufNewFile, BufRead *.txt setfiletype text
" For all text files set 'textwidth' to 78 characters.
autocmd FileType text setlocal textwidth=78
autocmd FileType html setlocal textwidth=78
autocmd FileType tex setlocal textwidth=78
" When editing a file, always jump to the last known cursor position.
" Don't do it when the position is invalid or when inside an event handler
" (happens when dropping a file on gvim).
autocmd BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal g`\"" |
\ endif
" create source template on new file
au BufNewFile *.h call CreateHeaderFromTemplate()
au BufNewFile *.hpp call CreateHeaderFromTemplate()
au BufNewFile *.cpp call CreateCppFromTemplate('cpp')
au BufNewFile *.c call CreateCppFromTemplate('c')
" options for plugins
au Filetype html,xml,xsl source $VIMDIR/scripts/closetag.vim
au FileType python source $VIMDIR/scripts/python.vim
" au FileType tex set noesckeys
" au FileType cpp let b:usemarks = 0
"au FileType cpp syn keyword cppAccess slots
"au FileType cpp syn keyword cStatement emit
"au FileType cpp nmap <buffer> gg :1<CR>/^$<CR><C-D>
endif " has("autocmd")
" end Auto Command }}}
" Color Setting {{{
"hi Keyword ctermfg=green
hi String ctermfg=2
hi Folded cterm=bold ctermfg=6 ctermbg=black
hi FoldColumn cterm=bold ctermfg=6 ctermbg=black
hi Comment ctermfg=yellow
hi NonText term=NONE cterm=NONE ctermfg=blue ctermbg=black
hi search ctermfg=white ctermbg=red guifg=white guibg=red
hi StatusLineNC ctermfg=grey ctermbg=black
hi StatusLine ctermfg=lightblue ctermbg=white
hi infoLink ctermfg=yellow
hi Directory ctermfg=darkgreen
" end of color setting }}}
" Functions {{{
" ===================================================================
" Functions
" ===================================================================
"
" smarttab in insert mode
"au BufNewFile,BufRead *.c,*.cc,*.C,*.h imap } <ESC>:call CurlyBracket()<CR>a
function! CreateCppFromTemplate(type)
"bob_cvs.vim opens new buffer with name like '*cvsstatus* xxx.cpp'
"checks for this kind name
if stridx(bufname('%'),'*') != -1
return
endif
let rc = confirm("Create new C/C++ source file from template?", "&Yes\n&No\n&M(with main())")
if rc == 2
return
endif
if a:type == 'cpp'
0r $VIMDIR/templates/cpp_template
else
0r $VIMDIR/templates/c_template
endif
call ChooseLicense()
" strip leading / directive
let filename = strpart(bufname('%'),strridx(bufname('%'),'/') + 1)
exec '%s/|FILENAME|/' . filename . '/g'
exec '%s/|YEAR|/' . strftime('%Y') . '/g'
exec '%s/|AUTHOR|/Zhang Le/g'
exec '%s/|EMAIL|/ejoy@users.sourceforge.net/g'
let month = MonthString(strftime("%m"),3)
exec '%s/|DATE|/' . strftime('%d-' . month . '-%Y') . '/g'
if rc == 3
exec 'normal G'
if a:type == 'cpp'
r $VIMDIR/templates/cpp_main_template
else
r $VIMDIR/templates/c_main_template
endif
exec 'normal 5G'
endif
let &modified = 1
endfunction
function! CreateHeaderFromTemplate()
"bob_cvs.vim opens new buffer with name like '*cvsstatus* xxx.cpp'
"checks for this kind name
if stridx(bufname('%'),'*') != -1
return
endif
let rc = confirm("Create new C/C++ head file from template?", "&Yes\n&No")
if rc == 2
return
endif
0r $VIMDIR/templates/header_template
call ChooseLicense()
" strip leading / directive
let filename = strpart(bufname('%'),strridx(bufname('%'),'/') + 1)
exec '%s/|FILENAME|/' . filename . '/g'
exec '%s/|YEAR|/' . strftime('%Y') . '/g'
exec '%s/|AUTHOR|/Zhang Le/g'
exec '%s/|EMAIL|/ejoy@users.sourceforge.net/g'
let month = MonthString(strftime("%m"),3)
exec '%s/|DATE|/' . strftime('%d-' . month . '-%Y') . '/g'
let basename = strpart(filename, 0, strridx(filename,'.'))
let suffix = strpart(filename, strridx(filename,'.') + 1, strlen(filename) - strridx(filename,'.') -1)
let include_gurad = toupper('_' . basename . '_' . suffix)
exec '%s/|INCLUDE_GUARD|/' . include_gurad . '/g'
exec 'normal 5G'
let &modified = 1
endfunction
function! ChooseLicense()
let license = confirm("Please choose license:", "&GPL\n&LGPL\n&MIT", 1)
if license == 1
/LICENSE/r $VIMDIR/templates/gpl.txt
exec "normal k"
exec "normal dd"
elseif license == 2
/LICENSE/r $VIMDIR/templates/lgpl.txt
exec "normal k"
exec "normal dd"
elseif license == 3
/LICENSE/r $VIMDIR/templates/mit.txt
exec "normal k"
exec "normal dd"
endif
endfunction
" taken from AutoDate script
" MonthString([{month} [, {length} [, {time}]]])
" Get month name string in English with first specified letters.
"
" :echo MonthString(8) . " 2001"
" August 2001
" :echo MonthString(8,3) . " 2001"
" Aug 2001
"
function! MonthString(...)
" Get {time} argument.
if a:0 > 2
let time = a:3
else
let time = localtime()
endif
" Verify {month}.
if a:0 > 0 && (a:1 >= 1 && a:1 <= 12)
let month = a:1
else
let month = substitute(strftime('%m', time), '^0\+', '', '')
endif
" Verify {length}.
if a:0 > 1 && (a:2 >= 1 && a:2 <= 9)
let length = a:2
else
let length = strpart('785534469788', month - 1, 1)
endif
" Generate string of month name.
return strpart('January February March April May June July August SeptemberOctober November December ', month * 9 - 9, length)
endfunction
function! Compile()
let old_autowrite = &autowrite
set autowrite
if filereadable('Jamfile')
set makeprg=jam\ -q
elseif filereadable('SConstruct') || filereadable('SConscript')
set makeprg=scons
else
set makeprg=gmake
endif
:mak
let &autowrite = old_autowrite
endfunction
" Toggle fold state between closed and opened.
" "
" " If there is no fold at current line, just moves forward.
" " If it is present, reverse it's state.
fun! ToggleFold()
if foldlevel('.') == 0
normal! l
else
if foldclosed('.') < 0
. foldclose
else
. foldopen
endif
endif
" Clear status line
echo
endfun
" Map this function to Space key.
noremap <space> :call ToggleFold()<CR>
" from ddldbl.vim
if !exists(":DBL")
" Delete Blank Lines
command -range=% DBL :<line1>,<line2>g/^\s*$/:delete
endif
func! HContext()
let moved = MoveCursor("H")
if !moved && line('.') != 1
exe "normal! " . "\<pageup>H"
endif
endfunc
func! LContext()
let moved = MoveCursor("L")
if !moved && line('.') != line('$')
exe "normal! " . "\<pagedown>L"
endif
endfunc
func! MoveCursor(key)
let cnum = col('.')
let lnum = line('.')
let wline = winline()
exe "normal! " . v:count . a:key
let moved = cnum != col('.') || lnum != line('.') || wline != winline()
return moved
endfunc
" end of Functions }}}
" Abbreviations {{{
" ===================================================================
"
"
" Correcting those typos. [I almost never get these right. :-(]
" See also: http://www.igd.fhg.de/~zach/programs/acl/
iab Thsi This
iab thsi this
iab alos also
iab aslo also
iab becuase because
iab bianry binary
iab bianries binaries
iab charcter character
iab charcters characters
iab exmaple example
iab exmaples examples
iab shoudl should
iab seperate separate
iab teh the
iab nto not
iab fo of
iab ot to
iab fro for
iab chinese Chinese
iab english English
" Email Addresses
"
" Mailing Lists (MLs)
"
"iab MLzhcon zhcon-devel@lists.sourceforge.net <zhcon-devel>
"
" WWW Pages base URLs
"
"ab HPzhcon http://zhcon.sourceforge.net
"
" ===================================================================
" Abbreviations - General Editing - Inserting Dates and Times
" ===================================================================
"
" First, some command to add date stamps (with and without time).
" I use these manually after a substantial change to a webpage.
" [These abbreviations are used with the mapping for ",L".]
"
iab Ydate <C-R>=strftime("%Y-%m-%d")<CR>
" Example: 2002-04-06
"
iab Ytime <C-R>=strftime("%H:%M")<CR>
" Example: 14:28
"
iab YDT <C-R>=strftime("%Y-%m-%d %H:%M")<CR>
" Example: 2002-06-24 20:44
" end of Abbreviations}}}
" Key Mapping {{{
"
" ===================================================================
"
" Don't use Ex mode, use Q for formatting
" map Q gq
" I want fast quitting
nmap Q :qa!<CR>
nmap W :wqa<CR>
" Press C to compile
nmap C :call Compile()<CR>
" I also like a space after ,
imap , ,
" use H/L to scroll screen up and down like pageup/down
" HContext and LContext are defined above
map <silent> H :<C-U>call HContext()<CR>
map <silent> L :<C-U>call LContext()<CR>
" [[ ]] works with main() { style
nmap [[ ?{<CR>w99[{
nmap ][ /}<CR>b99]}
nmap ]] j0[[%/{<CR>
nmap [] k$][%?}<CR>
" for smart brakets
" inoremap ( ()<ESC>:let leavechar=")"<CR>i
" inoremap [ []<ESC>:let leavechar="]"<CR>i
imap <C-j> <ESC>:exec "normal f" . leavechar<CR>a
" Make p in Visual mode replace the selected text with the "" register.
"vnoremap p <Esc>:let current_reg = @"<CR>gvs<C-R>=current_reg<CR><Esc>
" This is an alternative that also works in block mode, but the deleted
" text is lost and it only works for putting the current register.
"vnoremap p "_dp
" map for global cut&paste
nmap _Y :.w! ~/.vi_tmp<CR>
vmap _Y :w! ~/.vi_tmp<CR>
nmap _P :r ~/.vi_tmp<CR>
" ===================================================================
" Customizing the command line
" ===================================================================
" Valid names for keys are: <Up> <Down> <Left> <Right> <Home> <End>
" <S-Left> <S-Right> <S-Up> <PageUp> <S-Down> <PageDown> <LeftMouse>
"
" Many shells allow editing in "Emacs Style".
" Although I love Vi, I am quite used to this kind of editing now.
" So here it is - command line editing commands in emacs style:
cnoremap <C-A> <Home>
cnoremap <C-B> <Left>
" cnoremap <C-B> <Del>
cnoremap <C-E> <End>
cnoremap <C-F> <Right>
cnoremap <C-N> <End>
cnoremap <C-P> <Up>
cnoremap <C-G> <C-C>
cnoremap <ESC>b <S-Left>
cnoremap <ESC><C-B> <S-Left>
cnoremap <ESC>f <S-Right>
cnoremap <ESC><C-F> <S-Right>
cnoremap <ESC><C-H> <C-W>
" And in insert mode too
imap <C-A> <Home>
imap <C-B> <Left>
imap <C-E> <End>
imap <C-F> <Right>
imap <C-D> <Del>
" Note: More info about this is in the helptexts: :help emacs-keys
"
" ===================================================================
" VIM - Editing and updating the vimrc:
" As I often make changes to this file I use these commands
" to start editing it and also update it:
if has("unix")
let vimrc='~/.vimrc'
else
" ie: if has("dos16") || has("dos32") || has("win32")
let vimrc='$VIM\.vimrc'
endif
nn ,u :source <C-R>=vimrc<CR><CR>
nn ,v :edit <C-R>=vimrc<CR><CR>
" ,v = vimrc editing (edit this file)
" map ,v :e ~/.vimrc<CR>
" ,u = "update" by reading this file
" map ,u :source ~/.vimrc<CR>
" ===================================================================
"
"These two mappings reduce a sequence of empty (;b) or blank (;n) lines into a single line >
map ;b GoZ<Esc>:g/^$/.,/./-j<CR>Gdd
map ;n GoZ<Esc>:g/^[ <Tab>]*$/.,/[^ <Tab>]/-j<CR>Gdd
"map for quickfix
map <F3> <ESC>:cn<CR>
map <F4> <ESC>:cp<CR>
"map for ide
nmap gf <ESC>:hide edit <cfile><CR>
"map for call vimspell's correction function
nmap S :w!<CR>:!aspell -d en_US -H -t -c %<CR>:e! %<CR>
"nmap S :w!<CR>:!LC_ALL=en_US aspell -t -c %<CR>:e! %<CR>
"nmap S \s?
"map for tagging
map ,, <C-]>
" or: map ,, g<C-]>
map .. <C-T>
"
" When I let Vim write the current buffer I frequently mistype the
" command ":q!" as ":q1" - so I have to remap it to correct this typo:
map :q1 :q!
"toggle hlsearch mode
"nmap <F4> :set nohls!<CR>:set nohls?<CR>
"nmap <F4> <ESC>:%s/^ *\/\*\* No descriptions \*\/ *$/<CR>do
"map <F5> <ESC>ggO// vi:ts=4:shiftwidth=4:expandtab<ESC>
"map <F12> <ESC>I//<ESC>j
"map ,a <ESC>7GoLast Change : .<ESC>:wnext<CR>,a
"map ,a :%s/^main/int main/g<CR>:wnext<CR>,a
nmap <C-S> :w<CR>
"fold matched lines after searching
set foldexpr=(getline(v:lnum)=~@/)?0:(getline(v:lnum-1)=~@/)\|\|(getline(v:lnum+1)=~@/)?1:2
"set foldexpr=(getline(v:lnum-2)=~@/)\|\|(getline(v:lnum+2)=~@/)?2:3
nmap \z :set foldmethod=expr foldlevel=0 foldcolumn=2<CR>
"quickly move between split windows
nmap <C-j> <C-W>j<C-W>_
nmap <C-k> <C-W>k<C-W>_
nmap <c-h> <c-w>h<c-w><bar>
nmap <c-l> <c-w>l<c-w><bar>
nmap <F8> <c-w>=
"nmap ,a <ESC>:%s/<config.h>/"config.h"<CR>:wnext<CR>,a
"nmap ,a :%s/\^\$/ /g<CR>:wnext<CR>,a
" end of Key Mapping }}}