diff options
| author | Anton Bobov <abobov@gmail.com> | 2011-10-13 18:57:49 +0600 |
|---|---|---|
| committer | Anton Bobov <abobov@gmail.com> | 2011-10-13 18:57:49 +0600 |
| commit | afb69b98047d51a578b6d9d7bb482c6c4c0e8482 (patch) | |
| tree | aff149a738b2c2e1316a09538288106d26295590 /files/.vim | |
| parent | c36f3f430d4b56476750a8e338f7071fb11af2fb (diff) | |
f
Diffstat (limited to 'files/.vim')
| -rwxr-xr-x | files/.vim/after/ftplugin/gitcommit.vim | 5 | ||||
| -rwxr-xr-x | files/.vim/after/ftplugin/mail.vim | 1 | ||||
| -rwxr-xr-x | files/.vim/after/ftplugin/sh.vim | 1 | ||||
| -rw-r--r-- | files/.vim/colors/inkpot.vim | 216 | ||||
| -rw-r--r-- | files/.vim/colors/pyte.vim | 92 | ||||
| -rw-r--r-- | files/.vim/colors/rdark.vim | 159 | ||||
| -rw-r--r-- | files/.vim/colors/twilight.vim | 74 | ||||
| -rw-r--r-- | files/.vim/colors/wombat.vim | 51 | ||||
| -rw-r--r-- | files/.vim/colors/xoria256.vim | 152 | ||||
| l---------[-rwxr-xr-x] | files/.vim/ftplugin/dockbk.vim | 1861 | ||||
| -rwxr-xr-x | files/.vim/ftplugin/python.vim | 4 | ||||
| -rw-r--r--[-rwxr-xr-x] | files/.vim/ftplugin/xml.vim | 0 | ||||
| l---------[-rwxr-xr-x] | files/.vim/ftplugin/xsl.vim | 1861 | ||||
| -rwxr-xr-x | files/.vim/snippets/xml.snippets | 2 | ||||
| -rw-r--r-- | files/.vim/snippets/xslt.snippets | 6 |
15 files changed, 758 insertions, 3727 deletions
diff --git a/files/.vim/after/ftplugin/gitcommit.vim b/files/.vim/after/ftplugin/gitcommit.vim index b984b96..13609e5 100755 --- a/files/.vim/after/ftplugin/gitcommit.vim +++ b/files/.vim/after/ftplugin/gitcommit.vim @@ -1,4 +1,3 @@ +set nonumber set spell -set textwidth=72 - -hi link gitcommitSummary Special +set textwidth=72
\ No newline at end of file diff --git a/files/.vim/after/ftplugin/mail.vim b/files/.vim/after/ftplugin/mail.vim index ee2bde9..d5f021b 100755 --- a/files/.vim/after/ftplugin/mail.vim +++ b/files/.vim/after/ftplugin/mail.vim @@ -3,6 +3,7 @@ set expandtab set nonumber set imsearch=1 set iminsert=1 +nohlsearch set colorcolumn=+1 " par options diff --git a/files/.vim/after/ftplugin/sh.vim b/files/.vim/after/ftplugin/sh.vim deleted file mode 100755 index 445ad6a..0000000 --- a/files/.vim/after/ftplugin/sh.vim +++ /dev/null @@ -1 +0,0 @@ -set fileformat=unix diff --git a/files/.vim/colors/inkpot.vim b/files/.vim/colors/inkpot.vim new file mode 100644 index 0000000..c6ecb46 --- /dev/null +++ b/files/.vim/colors/inkpot.vim @@ -0,0 +1,216 @@ +" Vim color file +" Name: inkpot.vim +" Maintainer: Ciaran McCreesh <ciaran.mccreesh@googlemail.com> +" Homepage: http://github.com/ciaranm/inkpot/ +" +" This should work in the GUI, rxvt-unicode (88 colour mode) and xterm (256 +" colour mode). It won't work in 8/16 colour terminals. +" +" To use a black background, :let g:inkpot_black_background = 1 + +set background=dark +hi clear +if exists("syntax_on") + syntax reset +endif + +let colors_name = "inkpot" + +" map a urxvt cube number to an xterm-256 cube number +fun! <SID>M(a) + return strpart("0135", a:a, 1) + 0 +endfun + +" map a urxvt colour to an xterm-256 colour +fun! <SID>X(a) + if &t_Co == 88 + return a:a + else + if a:a == 8 + return 237 + elseif a:a < 16 + return a:a + elseif a:a > 79 + return 232 + (3 * (a:a - 80)) + else + let l:b = a:a - 16 + let l:x = l:b % 4 + let l:y = (l:b / 4) % 4 + let l:z = (l:b / 16) + return 16 + <SID>M(l:x) + (6 * <SID>M(l:y)) + (36 * <SID>M(l:z)) + endif + endif +endfun + +if ! exists("g:inkpot_black_background") + let g:inkpot_black_background = 0 +endif + +if has("gui_running") + if ! g:inkpot_black_background + hi Normal gui=NONE guifg=#cfbfad guibg=#1e1e27 + else + hi Normal gui=NONE guifg=#cfbfad guibg=#000000 + endif + + hi CursorLine guibg=#2e2e37 + + hi IncSearch gui=BOLD guifg=#303030 guibg=#cd8b60 + hi Search gui=NONE guifg=#303030 guibg=#ad7b57 + hi ErrorMsg gui=BOLD guifg=#ffffff guibg=#ce4e4e + hi WarningMsg gui=BOLD guifg=#ffffff guibg=#ce8e4e + hi ModeMsg gui=BOLD guifg=#7e7eae guibg=NONE + hi MoreMsg gui=BOLD guifg=#7e7eae guibg=NONE + hi Question gui=BOLD guifg=#ffcd00 guibg=NONE + + hi StatusLine gui=BOLD guifg=#b9b9b9 guibg=#3e3e5e + hi User1 gui=BOLD guifg=#00ff8b guibg=#3e3e5e + hi User2 gui=BOLD guifg=#7070a0 guibg=#3e3e5e + hi StatusLineNC gui=NONE guifg=#b9b9b9 guibg=#3e3e5e + hi VertSplit gui=NONE guifg=#b9b9b9 guibg=#3e3e5e + + hi WildMenu gui=BOLD guifg=#eeeeee guibg=#6e6eaf + + hi MBENormal guifg=#cfbfad guibg=#2e2e3f + hi MBEChanged guifg=#eeeeee guibg=#2e2e3f + hi MBEVisibleNormal guifg=#cfcfcd guibg=#4e4e8f + hi MBEVisibleChanged guifg=#eeeeee guibg=#4e4e8f + + hi DiffText gui=NONE guifg=#ffffcd guibg=#4a2a4a + hi DiffChange gui=NONE guifg=#ffffcd guibg=#306b8f + hi DiffDelete gui=NONE guifg=#ffffcd guibg=#6d3030 + hi DiffAdd gui=NONE guifg=#ffffcd guibg=#306d30 + + hi Cursor gui=NONE guifg=#404040 guibg=#8b8bff + hi lCursor gui=NONE guifg=#404040 guibg=#8fff8b + hi CursorIM gui=NONE guifg=#404040 guibg=#8b8bff + + hi Folded gui=NONE guifg=#cfcfcd guibg=#4b208f + hi FoldColumn gui=NONE guifg=#8b8bcd guibg=#2e2e2e + + hi Directory gui=NONE guifg=#00ff8b guibg=NONE + hi LineNr gui=NONE guifg=#8b8bcd guibg=#2e2e2e + hi NonText gui=BOLD guifg=#8b8bcd guibg=NONE + hi SpecialKey gui=BOLD guifg=#ab60ed guibg=NONE + hi Title gui=BOLD guifg=#af4f4b guibg=NONE + hi Visual gui=NONE guifg=#eeeeee guibg=#4e4e8f + + hi Comment gui=NONE guifg=#cd8b00 guibg=NONE + hi Constant gui=NONE guifg=#ffcd8b guibg=NONE + hi String gui=NONE guifg=#ffcd8b guibg=#404040 + hi Error gui=NONE guifg=#ffffff guibg=#6e2e2e + hi Identifier gui=NONE guifg=#ff8bff guibg=NONE + hi Ignore gui=NONE + hi Number gui=NONE guifg=#f0ad6d guibg=NONE + hi PreProc gui=NONE guifg=#409090 guibg=NONE + hi Special gui=NONE guifg=#c080d0 guibg=NONE + hi SpecialChar gui=NONE guifg=#c080d0 guibg=#404040 + hi Statement gui=NONE guifg=#808bed guibg=NONE + hi Todo gui=BOLD guifg=#303030 guibg=#d0a060 + hi Type gui=NONE guifg=#ff8bff guibg=NONE + hi Underlined gui=BOLD guifg=#df9f2d guibg=NONE + hi TaglistTagName gui=BOLD guifg=#808bed guibg=NONE + + hi perlSpecialMatch gui=NONE guifg=#c080d0 guibg=#404040 + hi perlSpecialString gui=NONE guifg=#c080d0 guibg=#404040 + + hi cSpecialCharacter gui=NONE guifg=#c080d0 guibg=#404040 + hi cFormat gui=NONE guifg=#c080d0 guibg=#404040 + + hi doxygenBrief gui=NONE guifg=#fdab60 guibg=NONE + hi doxygenParam gui=NONE guifg=#fdd090 guibg=NONE + hi doxygenPrev gui=NONE guifg=#fdd090 guibg=NONE + hi doxygenSmallSpecial gui=NONE guifg=#fdd090 guibg=NONE + hi doxygenSpecial gui=NONE guifg=#fdd090 guibg=NONE + hi doxygenComment gui=NONE guifg=#ad7b20 guibg=NONE + hi doxygenSpecial gui=NONE guifg=#fdab60 guibg=NONE + hi doxygenSpecialMultilineDesc gui=NONE guifg=#ad600b guibg=NONE + hi doxygenSpecialOnelineDesc gui=NONE guifg=#ad600b guibg=NONE + + if v:version >= 700 + hi Pmenu gui=NONE guifg=#eeeeee guibg=#4e4e8f + hi PmenuSel gui=BOLD guifg=#eeeeee guibg=#2e2e3f + hi PmenuSbar gui=BOLD guifg=#eeeeee guibg=#6e6eaf + hi PmenuThumb gui=BOLD guifg=#eeeeee guibg=#6e6eaf + + hi SpellBad gui=undercurl guisp=#cc6666 + hi SpellRare gui=undercurl guisp=#cc66cc + hi SpellLocal gui=undercurl guisp=#cccc66 + hi SpellCap gui=undercurl guisp=#66cccc + + hi MatchParen gui=NONE guifg=#cfbfad guibg=#4e4e8f + endif +else + if ! g:inkpot_black_background + exec "hi Normal cterm=NONE ctermfg=" . <SID>X(79) . " ctermbg=" . <SID>X(80) + else + exec "hi Normal cterm=NONE ctermfg=" . <SID>X(79) . " ctermbg=" . <SID>X(16) + endif + + exec "hi IncSearch cterm=BOLD ctermfg=" . <SID>X(80) . " ctermbg=" . <SID>X(73) + exec "hi Search cterm=NONE ctermfg=" . <SID>X(80) . " ctermbg=" . <SID>X(52) + exec "hi ErrorMsg cterm=BOLD ctermfg=" . <SID>X(16) . " ctermbg=" . <SID>X(48) + exec "hi WarningMsg cterm=BOLD ctermfg=" . <SID>X(16) . " ctermbg=" . <SID>X(68) + exec "hi ModeMsg cterm=BOLD ctermfg=" . <SID>X(38) . " ctermbg=" . "NONE" + exec "hi MoreMsg cterm=BOLD ctermfg=" . <SID>X(38) . " ctermbg=" . "NONE" + exec "hi Question cterm=BOLD ctermfg=" . <SID>X(52) . " ctermbg=" . "NONE" + + exec "hi StatusLine cterm=BOLD ctermfg=" . <SID>X(85) . " ctermbg=" . <SID>X(81) + exec "hi User1 cterm=BOLD ctermfg=" . <SID>X(28) . " ctermbg=" . <SID>X(81) + exec "hi User2 cterm=BOLD ctermfg=" . <SID>X(39) . " ctermbg=" . <SID>X(81) + exec "hi StatusLineNC cterm=NONE ctermfg=" . <SID>X(84) . " ctermbg=" . <SID>X(81) + exec "hi VertSplit cterm=NONE ctermfg=" . <SID>X(84) . " ctermbg=" . <SID>X(81) + + exec "hi WildMenu cterm=BOLD ctermfg=" . <SID>X(87) . " ctermbg=" . <SID>X(38) + + exec "hi MBENormal ctermfg=" . <SID>X(85) . " ctermbg=" . <SID>X(81) + exec "hi MBEChanged ctermfg=" . <SID>X(87) . " ctermbg=" . <SID>X(81) + exec "hi MBEVisibleNormal ctermfg=" . <SID>X(85) . " ctermbg=" . <SID>X(82) + exec "hi MBEVisibleChanged ctermfg=" . <SID>X(87) . " ctermbg=" . <SID>X(82) + + exec "hi DiffText cterm=NONE ctermfg=" . <SID>X(79) . " ctermbg=" . <SID>X(34) + exec "hi DiffChange cterm=NONE ctermfg=" . <SID>X(79) . " ctermbg=" . <SID>X(17) + exec "hi DiffDelete cterm=NONE ctermfg=" . <SID>X(79) . " ctermbg=" . <SID>X(32) + exec "hi DiffAdd cterm=NONE ctermfg=" . <SID>X(79) . " ctermbg=" . <SID>X(20) + + exec "hi Folded cterm=NONE ctermfg=" . <SID>X(79) . " ctermbg=" . <SID>X(35) + exec "hi FoldColumn cterm=NONE ctermfg=" . <SID>X(39) . " ctermbg=" . <SID>X(80) + + exec "hi Directory cterm=NONE ctermfg=" . <SID>X(28) . " ctermbg=" . "NONE" + exec "hi LineNr cterm=NONE ctermfg=" . <SID>X(39) . " ctermbg=" . <SID>X(80) + exec "hi NonText cterm=BOLD ctermfg=" . <SID>X(39) . " ctermbg=" . "NONE" + exec "hi SpecialKey cterm=BOLD ctermfg=" . <SID>X(55) . " ctermbg=" . "NONE" + exec "hi Title cterm=BOLD ctermfg=" . <SID>X(48) . " ctermbg=" . "NONE" + exec "hi Visual cterm=NONE ctermfg=" . <SID>X(79) . " ctermbg=" . <SID>X(38) + + exec "hi Comment cterm=NONE ctermfg=" . <SID>X(52) . " ctermbg=" . "NONE" + exec "hi Constant cterm=NONE ctermfg=" . <SID>X(73) . " ctermbg=" . "NONE" + exec "hi String cterm=NONE ctermfg=" . <SID>X(73) . " ctermbg=" . <SID>X(81) + exec "hi Error cterm=NONE ctermfg=" . <SID>X(79) . " ctermbg=" . <SID>X(32) + exec "hi Identifier cterm=NONE ctermfg=" . <SID>X(53) . " ctermbg=" . "NONE" + exec "hi Ignore cterm=NONE" + exec "hi Number cterm=NONE ctermfg=" . <SID>X(69) . " ctermbg=" . "NONE" + exec "hi PreProc cterm=NONE ctermfg=" . <SID>X(25) . " ctermbg=" . "NONE" + exec "hi Special cterm=NONE ctermfg=" . <SID>X(55) . " ctermbg=" . "NONE" + exec "hi SpecialChar cterm=NONE ctermfg=" . <SID>X(55) . " ctermbg=" . <SID>X(81) + exec "hi Statement cterm=NONE ctermfg=" . <SID>X(27) . " ctermbg=" . "NONE" + exec "hi Todo cterm=BOLD ctermfg=" . <SID>X(16) . " ctermbg=" . <SID>X(57) + exec "hi Type cterm=NONE ctermfg=" . <SID>X(71) . " ctermbg=" . "NONE" + exec "hi Underlined cterm=BOLD ctermfg=" . <SID>X(77) . " ctermbg=" . "NONE" + exec "hi TaglistTagName cterm=BOLD ctermfg=" . <SID>X(39) . " ctermbg=" . "NONE" + + if v:version >= 700 + exec "hi Pmenu cterm=NONE ctermfg=" . <SID>X(87) . " ctermbg=" . <SID>X(82) + exec "hi PmenuSel cterm=BOLD ctermfg=" . <SID>X(87) . " ctermbg=" . <SID>X(38) + exec "hi PmenuSbar cterm=BOLD ctermfg=" . <SID>X(87) . " ctermbg=" . <SID>X(39) + exec "hi PmenuThumb cterm=BOLD ctermfg=" . <SID>X(87) . " ctermbg=" . <SID>X(39) + + exec "hi SpellBad cterm=NONE ctermbg=" . <SID>X(32) + exec "hi SpellRare cterm=NONE ctermbg=" . <SID>X(33) + exec "hi SpellLocal cterm=NONE ctermbg=" . <SID>X(36) + exec "hi SpellCap cterm=NONE ctermbg=" . <SID>X(21) + exec "hi MatchParen cterm=NONE ctermbg=" . <SID>X(14) . "ctermfg=" . <SID>X(25) + endif +endif + +" vim: set et : diff --git a/files/.vim/colors/pyte.vim b/files/.vim/colors/pyte.vim new file mode 100644 index 0000000..76b53e7 --- /dev/null +++ b/files/.vim/colors/pyte.vim @@ -0,0 +1,92 @@ + +set background=light + +hi clear +if exists("syntax_on") + syntax reset +endif + +let colors_name = "pyte" + +if version >= 700 + hi CursorLine guibg=#f6f6f6 + hi CursorColumn guibg=#eaeaea + hi MatchParen guifg=white guibg=#80a090 gui=bold + + "Tabpages + hi TabLine guifg=black guibg=#b0b8c0 gui=italic + hi TabLineFill guifg=#9098a0 + hi TabLineSel guifg=black guibg=#f0f0f0 gui=italic,bold + + "P-Menu (auto-completion) + hi Pmenu guifg=white guibg=#808080 + "PmenuSel + "PmenuSbar + "PmenuThumb +endif +" +" Html-Titles +hi Title guifg=#202020 gui=bold +hi Underlined guifg=#202020 gui=underline + + +hi Cursor guifg=black guibg=#b0b4b8 +hi lCursor guifg=black guibg=white +hi LineNr guifg=#ffffff guibg=#c0d0e0 + +hi Normal guifg=#202020 guibg=#f0f0f0 + +hi StatusLine guifg=white guibg=#8090a0 gui=bold,italic +hi StatusLineNC guifg=#506070 guibg=#a0b0c0 gui=italic +hi VertSplit guifg=#a0b0c0 guibg=#a0b0c0 gui=NONE + +hi Folded guifg=#708090 guibg=#c0d0e0 + +hi NonText guifg=#c0c0c0 guibg=#e0e0e0 +" Kommentare +hi Comment guifg=#a0b0c0 gui=italic + +" Konstanten +hi Constant guifg=#a07040 +hi String guifg=#4070a0 +hi Number guifg=#40a070 +hi Float guifg=#70a040 +"hi Statement guifg=#0070e0 gui=NONE +" Python: def and so on, html: tag-names +hi Statement guifg=#007020 gui=bold + + +" HTML: arguments +hi Type guifg=#e5a00d gui=italic +" Python: Standard exceptions, True&False +hi Structure guifg=#007020 gui=italic +hi Function guifg=#06287e gui=italic + +hi Identifier guifg=#5b3674 gui=italic + +hi Repeat guifg=#7fbf58 gui=bold +hi Conditional guifg=#4c8f2f gui=bold + +" Cheetah: #-Symbol, function-names +hi PreProc guifg=#1060a0 gui=NONE +" Cheetah: def, for and so on, Python: Decorators +hi Define guifg=#1060a0 gui=bold + +hi Error guifg=red guibg=white gui=bold,underline +hi Todo guifg=#a0b0c0 guibg=NONE gui=italic,bold,underline + +" Python: %(...)s - constructs, encoding +hi Special guifg=#70a0d0 gui=italic + +hi Operator guifg=#408010 + +" color of <TAB>s etc... +hi SpecialKey guifg=#d8a080 guibg=#e8e8e8 gui=italic + +" Diff +hi DiffChange guifg=NONE guibg=#e0e0e0 gui=italic,bold +hi DiffText guifg=NONE guibg=#f0c8c8 gui=italic,bold +hi DiffAdd guifg=NONE guibg=#c0e0d0 gui=italic,bold +hi DiffDelete guifg=NONE guibg=#f0e0b0 gui=italic,bold + + diff --git a/files/.vim/colors/rdark.vim b/files/.vim/colors/rdark.vim new file mode 100644 index 0000000..62c7cdd --- /dev/null +++ b/files/.vim/colors/rdark.vim @@ -0,0 +1,159 @@ +" Vim color file +" Maintaner: Radu Dineiu <radu.dineiu@gmail.com> +" URL: http://ld.yi.org/vim/rdark/ +" Last Change: 2007 Jun 23 +" Version: 0.6 +" +" Features: +" - let rdark_current_line = 1 if you want to highlight the current line +" +" Changelog: +" 0.5 - fixed the Pmenu colors +" 0.6 - added SignColumn colors + +set background=dark + +hi clear +if exists("syntax_on") + syntax reset +endif + +let colors_name = "rdark" + +" Current Line +if exists('rdark_current_line') && rdark_current_line == 1 + set cursorline + hi CursorLine guibg=#191f21 +endif + +" Default Colors +hi Normal guifg=#babdb6 guibg=#1e2426 +hi NonText guifg=#2c3032 guibg=#2c3032 gui=none +hi Cursor guibg=#babdb6 +hi ICursor guibg=#babdb6 + +" Search +hi Search guifg=#2e3436 guibg=#fcaf3e +hi IncSearch guibg=#2e3436 guifg=#fcaf3e + +" Window Elements +hi StatusLine guifg=#2e3436 guibg=#babdb6 gui=none +hi StatusLineNC guifg=#2e3436 guibg=#888a85 gui=none +hi VertSplit guifg=#555753 guibg=#888a85 gui=none +hi Visual guibg=#000000 +hi MoreMsg guifg=#729fcf +hi Question guifg=#8ae234 gui=none +hi WildMenu guifg=#eeeeec guibg=#0e1416 +hi LineNr guifg=#3f4b4d guibg=#000000 +hi SignColumn guibg=#1e2426 + +" Pmenu +hi Pmenu guibg=#2e3436 guifg=#eeeeec +hi PmenuSel guibg=#ffffff guifg=#1e2426 +hi PmenuSbar guibg=#555753 +hi PmenuThumb guifg=#ffffff + +" Diff +hi DiffDelete guifg=#2e3436 guibg=#0e1416 +hi DiffAdd guibg=#1f2b2d +hi DiffChange guibg=#2e3436 +hi DiffText guibg=#000000 gui=none + +" Folds +hi Folded guifg=#d3d7cf guibg=#204a87 +hi FoldColumn guifg=#3465a4 guibg=#000000 + +" Specials +hi Title guifg=#fcaf3e +hi Todo guifg=#fcaf3e guibg=bg +hi SpecialKey guifg=#ef2929 + +" Tabs +hi TabLine guibg=#0a1012 guifg=#888a85 +hi TabLineFill guifg=#0a1012 +hi TabLineSel guibg=#555753 guifg=#eeeeec gui=none + +" Matches +hi MatchParen guifg=#2e3436 guibg=#fcaf3e + +" Tree +hi Directory guifg=#ffffff + +" Syntax +hi Comment guifg=#656763 +hi Constant guifg=#8ae234 +hi Number guifg=#8ae234 +hi Statement guifg=#729fcf gui=none +hi Identifier guifg=#ffffff +hi PreProc guifg=#fcaf3e +hi Function guifg=#fcaf3e +hi Type guifg=#e3e7df gui=none +hi Keyword guifg=#eeeeec +hi Special guifg=#888a85 +hi Error guifg=#eeeeec guibg=#cc0000 + +" PHP +hi phpRegionDelimiter guifg=#ad7fa8 +hi phpPropertySelector guifg=#888a85 +hi phpPropertySelectorInString guifg=#888a85 +hi phpOperator guifg=#888a85 +hi phpArrayPair guifg=#888a85 +hi phpAssignByRef guifg=#888a85 +hi phpRelation guifg=#888a85 +hi phpMemberSelector guifg=#888a85 +hi phpUnknownSelector guifg=#888a85 +hi phpVarSelector guifg=#babdb6 +hi phpSemicolon guifg=#888a85 gui=none +hi phpFunctions guifg=#d3d7cf +hi phpParent guifg=#888a85 + +" JavaScript +hi javaScriptBraces guifg=#888a85 +hi javaScriptOperator guifg=#888a85 + +" HTML +hi htmlTag guifg=#888a85 +hi htmlEndTag guifg=#888a85 +hi htmlTagName guifg=#babdb6 +hi htmlSpecialTagName guifg=#babdb6 +hi htmlArg guifg=#d3d7cf +hi htmlTitle guifg=#8ae234 gui=none +hi link htmlH1 htmlTitle +hi link htmlH2 htmlH1 +hi link htmlH3 htmlH1 +hi link htmlH4 htmlH1 +hi link htmlH5 htmlH1 +hi link htmlH6 htmlH1 + +" XML +hi link xmlTag htmlTag +hi link xmlEndTag htmlEndTag +hi link xmlAttrib htmlArg + +" CSS +hi cssSelectorOp guifg=#eeeeec +hi link cssSelectorOp2 cssSelectorOp +hi cssUIProp guifg=#d3d7cf +hi link cssPagingProp cssUIProp +hi link cssGeneratedContentProp cssUIProp +hi link cssRenderProp cssUIProp +hi link cssBoxProp cssUIProp +hi link cssTextProp cssUIProp +hi link cssColorProp cssUIProp +hi link cssFontProp cssUIProp +hi cssPseudoClassId guifg=#eeeeec +hi cssBraces guifg=#888a85 +hi cssIdentifier guifg=#fcaf3e +hi cssTagName guifg=#fcaf3e +hi link cssInclude Function +hi link cssCommonAttr Constant +hi link cssUIAttr Constant +hi link cssTableAttr Constant +hi link cssPagingAttr Constant +hi link cssGeneratedContentAttr Constant +hi link cssAuralAttr Constant +hi link cssRenderAttr Constant +hi link cssBoxAttr Constant +hi link cssTextAttr Constant +hi link cssColorAttr Constant +hi link cssFontAttr Constant diff --git a/files/.vim/colors/twilight.vim b/files/.vim/colors/twilight.vim new file mode 100644 index 0000000..91e69d5 --- /dev/null +++ b/files/.vim/colors/twilight.vim @@ -0,0 +1,74 @@ +" Maintainer: Yoshimasa NIWA<niw@disense.com> +" Last Change: 14 Jun 2006 + +set background=dark +hi clear +if exists("syntax_on") + syntax reset +endif + +let g:colors_name="twilight" + +hi Normal guifg=#F8F8F8 guibg=#141414 +hi Cursor guifg=#F8F8F8 guibg=#A7A7A7 +hi CursorIM guifg=#F8F8F8 guibg=#5F5A60 +hi Directory guifg=#8F9D6A guibg=#141414 +hi ErrorMsg guifg=#CF6A4C guibg=#420E09 +hi VertSplit guifg=#AC885B guibg=#FFFFFF +hi Folded guifg=#F9EE98 guibg=#494949 +hi IncSearch guifg=#000000 guibg=#CF6A4C +hi LineNr guifg=#7587A6 guibg=#000000 +hi ModeMsg guifg=#CF7D34 guibg=#E9C062 +hi MoreMsg guifg=#CF7D34 guibg=#E9C062 +hi NonText guifg=#D2A8A1 guibg=#141414 +hi Question guifg=#7587A6 guibg=#0E2231 +hi Search guifg=#420E09 guibg=#CF6A4C +hi SpecialKey guifg=#CF7D34 guibg=#141414 +hi StatusLine guifg=#0E2231 guibg=#8693A5 +hi StatusLineNC guifg=#7587A6 guibg=#F8F8F8 +hi Title guifg=#8B98AB guibg=#0E2231 +hi Visual guifg=#0E2231 guibg=#AFC4DB +hi WarningMsg guifg=#CF6A4C guibg=#420E09 +hi WildMenu guifg=#AFC4DB guibg=#0E2231 + +"Syntax hilight groups + +hi Comment guifg=#8F9D6A +hi Constant guifg=#CF6A4C +hi String guifg=#8F9D6A +hi Character guifg=#E9C062 +hi Number guifg=#9B859D +hi Boolean guifg=#CF6A4C +hi Float guifg=#562D56 +hi Identifier guifg=#9B703F +hi Function guifg=#9B5C2E +hi Statement guifg=#CF7D34 +hi Conditional guifg=#9B703F +hi Repeat guifg=khaki +hi Label guifg=#E9C062 +hi Operator guifg=#CF6A4C +hi Keyword guifg=#E9C062 +hi Exception guifg=khaki +hi PreProc guifg=khaki4 +hi Include guifg=khaki4 +hi Define guifg=khaki1 +hi Macro guifg=#9B703F +hi PreCondit guifg=khaki3 +hi Type guifg=khaki3 +hi StorageClass guifg=tan +hi Structure guifg=DarkGoldenrod +hi Typedef guifg=khaki3 +hi Special guifg=IndianRed +hi SpecialChar guifg=DarkGoldenrod +hi Tag guifg=DarkKhaki +hi Delimiter guifg=DarkGoldenrod +hi SpecialComment guifg=cornsilk +hi Debug guifg=brown +hi Underlined guifg=#Cf6A4C +hi Ignore guifg=#494949 +hi Error guifg=#CF6A4C guibg=#420E09 +hi Todo guifg=#7587A6 guibg=#0E2231 +hi Pmenu guifg=#141414 guibg=#CDA869 +hi PmenuSel guifg=#F8F8F8 guibg=#9B703F +hi PmenuSbar guibg=#DAEFA3 +hi PmenuThumb guifg=#8F9D6A diff --git a/files/.vim/colors/wombat.vim b/files/.vim/colors/wombat.vim new file mode 100644 index 0000000..9ad1e56 --- /dev/null +++ b/files/.vim/colors/wombat.vim @@ -0,0 +1,51 @@ +" Maintainer: Lars H. Nielsen (dengmao@gmail.com) +" Last Change: January 22 2007 + +set background=dark + +hi clear + +if exists("syntax_on") + syntax reset +endif + +let colors_name = "wombat" + + +" Vim >= 7.0 specific colors +if version >= 700 + hi CursorLine guibg=#2d2d2d + hi CursorColumn guibg=#2d2d2d + hi MatchParen guifg=#f6f3e8 guibg=#857b6f gui=bold + hi Pmenu guifg=#f6f3e8 guibg=#444444 + hi PmenuSel guifg=#000000 guibg=#cae682 +endif + +" General colors +hi Cursor guifg=NONE guibg=#656565 gui=none +hi Normal guifg=#f6f3e8 guibg=#242424 gui=none +hi NonText guifg=#808080 guibg=#303030 gui=none +hi LineNr guifg=#857b6f guibg=#000000 gui=none +hi StatusLine guifg=#f6f3e8 guibg=#444444 gui=italic +hi StatusLineNC guifg=#857b6f guibg=#444444 gui=none +hi VertSplit guifg=#444444 guibg=#444444 gui=none +hi Folded guibg=#384048 guifg=#a0a8b0 gui=none +hi Title guifg=#f6f3e8 guibg=NONE gui=bold +hi Visual guifg=#f6f3e8 guibg=#444444 gui=none +hi SpecialKey guifg=#808080 guibg=#343434 gui=none + +" Syntax highlighting +hi Comment guifg=#99968b gui=italic +hi Todo guifg=#8f8f8f gui=italic +hi Constant guifg=#e5786d gui=none +hi String guifg=#95e454 gui=italic +hi Identifier guifg=#cae682 gui=none +hi Function guifg=#cae682 gui=none +hi Type guifg=#cae682 gui=none +hi Statement guifg=#8ac6f2 gui=none +hi Keyword guifg=#8ac6f2 gui=none +hi PreProc guifg=#e5786d gui=none +hi Number guifg=#e5786d gui=none +hi Special guifg=#e7f6da gui=none + + diff --git a/files/.vim/colors/xoria256.vim b/files/.vim/colors/xoria256.vim new file mode 100644 index 0000000..2e56de5 --- /dev/null +++ b/files/.vim/colors/xoria256.vim @@ -0,0 +1,152 @@ +" Vim color file +" Name: xoria256.vim +" Version: 0.1 +" License: Public Domain +" Maintainer: Dmitriy Y. Zotikov (xio) <io-public@mail.ru> +" +" Heavily based on 'moria' color scheme. +" +" Sould work in a 256 color terminal (like latest versions of xterm, konsole, +" etc). Will not, however, work in 88 color terminals like urxvt. +" +" Color numbers (0-255) see: +" http://www.calmar.ws/vim/256-xterm-24bit-rgb-color-chart.html +" TODO: +" - Diff +" - Html + + + +if &t_Co != 256 && ! has("gui_running") + echomsg "" + echomsg "err: please use GUI or a 256-color terminal (so that t_Co=256 could be set)" + echomsg "" + finish +endif + +set background=dark +hi clear +if exists("syntax_on") + syntax reset +endif + +" Which one is right? +"let colors_name = "xoria256" +let g:colors_name = "xoria256" + + + +hi Normal cterm=none ctermfg=252 ctermbg=234 gui=none guifg=#d0d0d0 guibg=#202020 + +hi Cursor cterm=none ctermfg=bg ctermbg=214 gui=none guifg=bg guibg=#ffaf00 +hi CursorColumn cterm=none ctermbg=238 gui=none guibg=#444444 +hi CursorLine cterm=none ctermbg=238 gui=none guibg=#444444 +hi lCursor cterm=none ctermfg=0 ctermbg=40 gui=none guifg=#000000 guibg=#00df00 +"hi CursorIM cterm= ctermfg= ctermbg= gui= guifg= guibg= +hi IncSearch cterm=none ctermfg=0 ctermbg=223 gui=none guifg=#000000 guibg=#ffdfaf +hi Search cterm=none ctermfg=0 ctermbg=149 gui=none guifg=#000000 guibg=#afdf5f +hi ErrorMsg cterm=none ctermfg=15 ctermbg=160 gui=bold guifg=#ffffff guibg=#df0000 +hi WarningMsg cterm=bold ctermfg=196 ctermbg=bg gui=bold guifg=#ff0000 guibg=bg +hi ModeMsg cterm=bold ctermfg=fg ctermbg=bg gui=bold guifg=fg guibg=bg +hi MoreMsg cterm=bold ctermfg=250 ctermbg=bg gui=bold guifg=#bcbcbc guibg=bg +hi Question cterm=bold ctermfg=113 ctermbg=bg gui=bold guifg=#87df7f guibg=bg + +hi StatusLine cterm=bold ctermfg=fg ctermbg=239 gui=bold guifg=fg guibg=#4e4e4e +hi StatusLineNC cterm=none ctermfg=fg ctermbg=237 gui=none guifg=fg guibg=#3a3a3a +hi User1 cterm=none ctermfg=15 ctermbg=20 gui=none guifg=#ffffff guibg=#0000df +hi User2 cterm=none ctermfg=46 ctermbg=20 gui=none guifg=#00ff00 guibg=#0000df +hi User3 cterm=none ctermfg=46 ctermbg=20 gui=none guifg=#00ff00 guibg=#0000df +hi User4 cterm=none ctermfg=50 ctermbg=20 gui=none guifg=#00ffdf guibg=#0000df +hi User5 cterm=none ctermfg=46 ctermbg=20 gui=none guifg=#00ff00 guibg=#0000df +hi VertSplit cterm=reverse ctermfg=fg ctermbg=237 gui=reverse guifg=fg guibg=#3a3a3a + +hi WildMenu cterm=bold ctermfg=0 ctermbg=184 gui=bold guifg=#000000 guibg=#dfdf00 +"hi Menu cterm= ctermfg= ctermbg= gui= guifg= guibg= +"hi Scrollbar cterm= ctermfg= ctermbg= gui= guifg= guibg= +"hi Tooltip cterm= ctermfg= ctermbg= gui= guifg= guibg= + +"hi MBENormal cterm= ctermfg= ctermbg= gui= guifg= guibg= +"hi MBEChanged cterm= ctermfg= ctermbg= gui= guifg= guibg= +"hi MBEVisibleNormal cterm= ctermfg= ctermbg= gui= guifg= guibg= +"hi MBEVisibleChanged cterm= ctermfg= ctermbg= gui= guifg= guibg= + +hi DiffText cterm=bold ctermfg=fg ctermbg=20 gui=bold guifg=fg guibg=#0000df +hi DiffDelete cterm=none ctermfg=fg ctermbg=88 gui=none guifg=fg guibg=#870000 +hi DiffChange cterm=none ctermfg=fg ctermbg=18 gui=none guifg=fg guibg=#000087 +hi DiffAdd cterm=none ctermfg=fg ctermbg=28 gui=none guifg=fg guibg=#008700 + +hi Folded cterm=none ctermfg=247 ctermbg=251 gui=bold guifg=#c6c6c6 guibg=#585858 +hi FoldColumn cterm=none ctermfg=248 ctermbg=58 gui=none guifg=#a8a8a8 guibg=bg +hi SignColumn cterm=none ctermfg=248 ctermbg=bg gui=none guifg=#a8a8a8 guibg=bg + +hi Directory cterm=none ctermfg=39 ctermbg=bg gui=none guifg=#00afff guibg=bg +hi LineNr cterm=none ctermfg=248 gui=none guifg=#a8a8a8 +hi NonText cterm=bold ctermfg=248 ctermbg=bg gui=bold guifg=#a8a8a8 guibg=bg +hi SpecialKey cterm=none ctermfg=77 ctermbg=bg gui=none guifg=#5fdf5f guibg=bg +hi Title cterm=none ctermfg=0 ctermbg=184 gui=none guifg=#000000 guibg=#dfdf00 +hi Visual cterm=none ctermfg=24 ctermbg=153 gui=none guifg=#005f87 guibg=#afdfff +"hi Visual cterm=none ctermfg=18 ctermbg=153 gui=none guifg=#005f87 guibg=#afdfff +hi VisualNOS cterm=bold,underline ctermfg=247 ctermbg=bg gui=bold,underline guifg=#9e9e9e guibg=bg + +hi Comment cterm=none ctermfg=244 ctermbg=bg gui=none guifg=#808080 guibg=bg +"hi Constant cterm=none ctermfg=222 ctermbg=bg gui=none guifg=#ffdf87 guibg=bg +"hi Constant cterm=none ctermfg=221 ctermbg=bg gui=none guifg=#ffdf57 guibg=bg +hi Constant cterm=none ctermfg=180 ctermbg=bg gui=none guifg=#dfaf87 guibg=bg +"hi String cterm= ctermfg= ctermbg= gui= guifg= guibg= +hi Error cterm=none ctermfg=196 ctermbg=bg gui=none guifg=#df5faf guibg=bg +hi Identifier cterm=none ctermfg=229 ctermbg=bg gui=none guifg=#ffffaf guibg=bg +hi Ignore cterm=none ctermfg=bg ctermbg=bg gui=none guifg=bg guibg=bg +"hi Number cterm=none ctermfg=209 ctermbg=0 gui=none guifg=#ff875f guibg=#000000 +"hi Number cterm=none ctermfg=210 ctermbg=0 gui=none guifg=#ff8787 guibg=#000000 +hi Number cterm=none ctermfg=174 ctermbg=0 gui=none guifg=#df8787 guibg=#000000 +hi PreProc cterm=none ctermfg=182 ctermbg=bg gui=none guifg=#dfafdf guibg=bg +"hi PreProc cterm=none ctermfg=218 ctermbg=bg gui=none guifg=#ffafdf guibg=bg +"hi Special cterm=none ctermfg=77 ctermbg=bg gui=none guifg=#5fdf5f guibg=bg +hi Special cterm=none ctermfg=114 ctermbg=bg gui=none guifg=#5fdf5f guibg=bg +"hi SpecialChar cterm= ctermfg= ctermbg= gui= guifg= guibg= +hi Statement cterm=none ctermfg=74 ctermbg=bg gui=none guifg=#5fafdf guibg=bg +"hi Statement cterm=none ctermfg=75 ctermbg=bg gui=none guifg=#5fafff guibg=bg +hi Todo cterm=none ctermfg=0 ctermbg=184 gui=none guifg=#000000 guibg=#dfdf00 +"hi Type cterm=none ctermfg=153 ctermbg=bg gui=none guifg=#afdfff guibg=bg +hi Type cterm=none ctermfg=146 ctermbg=bg gui=none guifg=#afafdf guibg=bg +hi Underlined cterm=underline ctermfg=39 ctermbg=bg gui=underline guifg=#00afff guibg=bg + +"hi htmlBold cterm= ctermbg=0 ctermfg=15 guibg=bg guifg=fg gui=bold +"hi htmlBoldItalic cterm= ctermbg=0 ctermfg=15 guibg=bg guifg=fg gui=bold,italic +"hi htmlBoldUnderline cterm= ctermbg=0 ctermfg=15 guibg=bg guifg=fg gui=bold,underline +"hi htmlBoldUnderlineItalic cterm= ctermbg=0 ctermfg=15 guibg=bg guifg=fg gui=bold,underline,italic +"hi htmlItalic cterm= ctermbg=0 ctermfg=15 guibg=bg guifg=fg gui=italic +"hi htmlUnderline cterm= ctermbg=0 ctermfg=15 guibg=bg guifg=fg gui=underline +"hi htmlUnderlineItalici cterm= ctermbg=0 ctermfg=15 guibg=bg guifg=fg gui=underline,italic + + +" For taglist plugin +if exists('loaded_taglist') + hi TagListTagName cterm=none ctermfg=16 ctermbg=28 gui=none guifg=#000000 guibg=#008700 + hi TagListTagScope cterm=none ctermfg=16 ctermbg=28 gui=none guifg=#000000 guibg=#008700 + hi TagListTitle cterm=none ctermfg=199 ctermbg=16 gui=none guifg=#ff00af guibg=#000000 + hi TagListComment cterm=none ctermfg=16 ctermbg=28 gui=none guifg=#000000 guibg=#008700 + hi TagListFileName cterm=none ctermfg=15 ctermbg=90 gui=none guifg=#ffffff guibg=#870087 +endif + + +" For features in vim v.7.0 and higher +if v:version >= 700 + hi Pmenu cterm=none ctermfg=0 ctermbg=246 gui=none guifg=#000000 guibg=#949494 + hi PmenuSel cterm=none ctermfg=0 ctermbg=243 gui=none guifg=#000000 guibg=#767676 + hi PmenuSbar cterm=none ctermfg=fg ctermbg=243 gui=none guifg=fg guibg=#767676 + hi PmenuThumb cterm=none ctermfg=bg ctermbg=252 gui=none guifg=bg guibg=#d0d0d0 + + " if has("spell") + " hi SpellBad guisp=#ee2c2c gui=undercurl + " hi SpellCap guisp=#2c2cee gui=undercurl + " hi SpellLocal guisp=#2ceeee gui=undercurl + " hi SpellRare guisp=#ee2cee gui=undercurl + " endif + + hi MatchParen cterm=none ctermfg=24 ctermbg=153 gui=none guifg=#005f87 guibg=#afdfff + + hi TabLineSel cterm=bold ctermfg=fg ctermbg=bg gui=bold guifg=fg guibg=bg + hi TabLine cterm=underline ctermfg=fg ctermbg=242 gui=underline guifg=fg guibg=#666666 + hi TabLineFill cterm=underline ctermfg=fg ctermbg=242 gui=underline guifg=fg guibg=#666666 +endif diff --git a/files/.vim/ftplugin/dockbk.vim b/files/.vim/ftplugin/dockbk.vim index eae609f..65289a9 100755..120000 --- a/files/.vim/ftplugin/dockbk.vim +++ b/files/.vim/ftplugin/dockbk.vim @@ -1,1860 +1 @@ -" Vim script file vim600:fdm=marker: -" FileType: XML -" Author: Rene de Zwart <renez (at) lightcon.xs4all.nl> -" Maintainer: Rene de Zwart <renez (at) lightcon.xs4all.nl> -" Last Change: $Date: 2007/03/17 12:39:40 $ -" Version: $Revision: 1.35 $ -" -" Licence: This program is free software; you can redistribute it -" and/or modify it under the terms of the GNU General Public -" License. See http://www.gnu.org/copyleft/gpl.txt -" Credits: Devin Weaver <vim (at) tritarget.com> et all -" for the original code. Guo-Peng Wen for the self -" install documentation code. -" Bart vam Deenen for makeElement function - - -" Observation - If you want to do something to a match pair most of the time -" you must do first the close tag. Because doing first the open -" tag could change the close tag position. - - - -" Only do this when not done yet for this buffer -if exists("b:did_ftplugin") - finish -endif -let b:did_ftplugin = 1 - -setlocal commentstring=<!--%s--> - -" XML: thanks to Johannes Zellner and Akbar Ibrahim -" - case sensitive -" - don't match empty tags <fred/> -" - match <!--, --> style comments (but not --, --) -" - match <!, > inlined dtd's. This is not perfect, as it -" gets confused for example by -" <!ENTITY gt ">"> -if exists("loaded_matchit") - let b:match_ignorecase=0 - let b:match_words = - \ '<:>,' . - \ '<\@<=!\[CDATA\[:]]>,'. - \ '<\@<=!--:-->,'. - \ '<\@<=?\k\+:?>,'. - \ '<\@<=\([^ \t>/]\+\)\%(\s\+[^>]*\%([^/]>\|$\)\|>\|$\):<\@<=/\1>,'. - \ '<\@<=\%([^ \t>/]\+\)\%(\s\+[^/>]*\|$\):/>' -endif - -" Script rgular expresion used. Documents those nasty criters {{{1 -let s:NoSlashBeforeGt = '\(\/\)\@\<!>' -" Don't check for quotes around attributes!!! -let s:Attrib = '\(\(\s\|\n\)\+\([^>= \t]\+=[^>&]\+\)\(\s\|\n\)*\)' -let s:OptAttrib = s:Attrib . '*'. s:NoSlashBeforeGt -let s:ReqAttrib = s:Attrib . '\+'. s:NoSlashBeforeGt -let s:OpenTag = '<[^!/?][^>]*' . s:OptAttrib -let s:OpenOrCloseTag = '<[^!?][^>]*'. s:OptAttrib -let s:CloseTag = '<\/[^>]*'. s:OptAttrib -let s:SpaceInfront = '^\s*<' -let s:EndofName = '\($\|\s\|>\)' - -" Buffer variables {{{1 -let b:emptyTags='^\(img\|input\|param\|frame\|br\|hr\|meta\|link\|base\|area\)$' -let b:firstWasEndTag = 0 -let b:html_mode =((&filetype =~ 'x\?html') && !exists("g:xml_no_html")) -let b:haveAtt = 0 -let b:lastTag = "" -let b:lastAtt = "" -let b:suffix = (exists('g:makeElementSuf') ? g:makeElementSuf : ';;') -let b:xml_use_xhtml = 0 -if exists('g:xml_use_xhtml') - let b:xml_use_xhtml = g:xml_use_xhtml -elseif &filetype == 'xhtml' - let b:xml_use_xhtml = 1 -en - - - - -" NewFileXML -> Inserts <?xml?> at top of new file. {{{1 -if !exists("*NewFileXML") -function! NewFileXML( ) - " Where is g:did_xhtmlcf_inits defined? - if &filetype == 'xml' || - \ (!exists ("g:did_xhtmlcf_inits") && - \ b:xml_use_xhtml && - \ (&filetype =~ 'x\?html')) - if append (0, '<?xml version="1.0"?>') - normal! G - endif - endif -endfunction -endif - - - -" Callback -> Checks for tag callbacks and executes them. {{{1 -if !exists("*s:Callback") -function! s:Callback( xml_tag, isHtml ) - let text = 0 - if a:isHtml == 1 && exists ("*HtmlAttribCallback") - let text = HtmlAttribCallback (a:xml_tag) - elseif exists ("*XmlAttribCallback") - let text = XmlAttribCallback (a:xml_tag) - endif - if text != '0' - execute "normal! i " . text ."\<Esc>l" - endif -endfunction -endif - -" SavePos() saves position in bufferwide variable {{{1 -if !exists('*s:SavePos') -fun! s:SavePos() - retu 'call cursor('.line('.').','. col('.'). ')' -endf -en - -" findOpenTag() {{{1 -if !exists('*s:findOpenTag') -fun! s:findOpenTag(flag) - call search(s:OpenTag,a:flag) -endf -en - -" findCloseTag() {{{1 -if !exists('*s:findCloseTag') -fun! s:findCloseTag(flag) - call search(s:CloseTag,a:flag) -endf -en - -" GetTagName() Gets the tagname from start position {{{1 -"Now lets go for the name part. The namepart are xmlnamechars which -"is quite a big range. We assume that everything after '<' or '</' -"until the first 'space', 'forward slash' or '>' ends de name part. -if !exists('*s:GetTagName') -fun! s:GetTagName(from) - let l:end = match(getline('.'), s:EndofName,a:from) - return strpart(getline('.'),a:from, l:end - a:from ) -endf -en -" hasAtt() Looks for attribute in open tag {{{1 -" expect cursor to be on < -if !exists('*s:hasAtt') -fun! s:hasAtt() - "Check if this open tag has attributes - let l:line = line('.') | let l:col = col('.') - if search(b:tagName . s:ReqAttrib,'W') > 0 - if l:line == line('.') && l:col == (col('.')-1) - let b:haveAtt = 1 - en - en -endf -en - - -" TagUnderCursor() Is there a tag under the cursor? {{{1 -" Set bufer wide variable -" - b:firstWasEndTag -" - b:tagName -" - b:endcol & b:endline only used by Match() -" - b:gotoCloseTag (if the tag under the cursor is one) -" - b:gotoOpenTag (if the tag under the cursor is one) -" on exit -" - returns 1 (true) or 0 (false) -" - position is at '<' -if !exists('*s:TagUnderCursor') -fun! s:TagUnderCursor() - let b:firstWasEndTag = 0 - let l:haveTag = 0 - let b:haveAtt = 0 - - "Lets find forward a < or a >. If we first find a > we might be in a tag. - "If we find a < first or nothing we are definitly not in a tag - - if getline('.')[col('.') - 1] == '>' - let b:endcol = col('.') - let b:endline = line('.') - if getline('.')[col('.')-2] == '/' - "we don't work with empty tags - retu l:haveTag - en - " begin: gwang customization for JSP development - if getline('.')[col('.')-2] == '%' - "we don't work with jsp %> tags - retu l:haveTag - en - " end: gwang customization for JSP development - " begin: gwang customization for PHP development - if getline('.')[col('.')-2] == '?' - "we don't work with php ?> tags - retu l:haveTag - en - " end: gwang customization for PHP development - elseif search('[<>]','W') >0 - if getline('.')[col('.')-1] == '>' - let b:endcol = col('.') - let b:endline = line('.') - if getline('.')[col('.')-2] == '-' - "we don't work with comment tags - retu l:haveTag - en - if getline('.')[col('.')-2] == '/' - "we don't work with empty tags - retu l:haveTag - en - el - retu l:haveTag - en - el - retu l:haveTag - en - - if search('[<>]','bW' ) >=0 - if getline('.')[col('.')-1] == '<' - if getline('.')[col('.')] == '/' - let b:firstWasEndTag = 1 - let b:gotoCloseTag = s:SavePos() - elseif getline('.')[col('.')] == '?' || getline('.')[col('.')] == '!' - "we don't deal with processing instructions or dtd - "related definitions - retu l:haveTag - el - let b:gotoOpenTag = s:SavePos() - en - el - retu l:haveTag - en - el - retu l:haveTag - en - - "we have established that we are between something like - "'</\?[^>]*>' - - let b:tagName = s:GetTagName(col('.') + b:firstWasEndTag) - "echo 'Tag ' . b:tagName - - "begin: gwang customization, do not work with an empty tag name - if b:tagName == '' - retu l:haveTag - en - "end: gwang customization, do not work with an empty tag name - - let l:haveTag = 1 - if b:firstWasEndTag == 0 - call s:hasAtt() - exe b:gotoOpenTag - en - retu l:haveTag -endf -en - -" Match(tagname) Looks for open or close tag of tagname {{{1 -" Set buffer wide variable -" - b:gotoCloseTag (if the Match tag is one) -" - b:gotoOpenTag (if the Match tag is one) -" on exit -" - returns 1 (true) or 0 (false) -" - position is at '<' -if !exists('*s:Match') -fun! s:Match(name) - let l:pat = '</\=' . a:name . s:OptAttrib - if b:firstWasEndTag - exe b:gotoCloseTag - let l:flags='bW' - let l:level = -1 - el - exe 'normal '.b:endline.'G0'.(b:endcol-1).'l' - let l:flags='W' - let l:level = 1 - en - while l:level && search(l:pat,l:flags) > 0 - let l:level = l:level + (getline('.')[col('.')] == '/' ? -1 : 1) - endwhile - if l:level - echo "no matching tag!!!!!" - retu l:level - en - if b:firstWasEndTag - let b:gotoOpenTag = s:SavePos() - call s:hasAtt() - exe b:gotoOpenTag - el - let b:gotoCloseTag = s:SavePos() - en - retu l:level == 0 -endf -en - -" InComment() Is there a Comment under the cursor? {{{1 -" - returns 1 (true) or 0 (false) - -if !exists('*s:InComment') -fun! s:InComment() -let b:endcom=0 -let b:begcom=0 - - "Lets find forward a < or a >. If we first find a > we might be in a comment. - "If we find a < first or nothing we are definitly not in a Comment - - if getline('.')[col('.') - 1] == '>' - if getline('.')[col('.')-2] == '-' && getline('.')[col('.')-3] == '-' - let b:endcomcol=col('.') - let b:endcomline=line('.') - let b:endcom=1 - retu 1 - en - elseif getline('.')[col('.')-1] == '<' && getline('.')[col('.')] == '!' - \ && getline('.')[col('.')+1] == '-' && getline('.')[col('.')+2] == '-' - let b:begcomcol= col('.') - let b:begcomline=line('.') - let b:begcom=1 - retu 1 - en - "We are not standing on a begin/end comment - "Is the first > an ending comment? - if search('[<>]','W') >0 - if getline('.')[col('.')-1] == '>' - if getline('.')[col('.')-2] == '-' && getline('.')[col('.')-3] == '-' - let b:endcomcol=col('.') - let b:endcomline=line('.') - let b:endcom=1 - retu 1 - en - en - en - "Forward is not a ending comment - "is backward a starting comment - - if search('[<>]','bW' ) >=0 - if getline('.')[col('.')-1] == '<' && getline('.')[col('.')] == '!' - \ && getline('.')[col('.')+1] == '-' && getline('.')[col('.')+2] == '-' - let b:begcomcol=col('.') - let b:begcomline=line('.') - let b:begcom=1 - retu 1 - en - en - retu 0 -endf -en - -" DelComment() Is there a Comment under the cursor? {{{1 -" - returns 1 (true) or 0 (false) - -if !exists('*s:DelComment') -fun! s:DelComment() - - let l:restore = s:SavePos() - if s:InComment() - if b:begcom - if search('-->','W' ) >=0 - normal hh3x - call cursor(b:begcomline,b:begcomcol) - normal 4x - retu 1 - en - el - if search('<!--','bW' ) >=0 - normal 4x - call cursor(b:endcomline,b:endcomcol) - normal hh3x - retu 1 - en - en - en - exe l:restore - retu 0 -endf -en - -" DelCommentSection() Is there a Comment under the cursor? {{{1 -" - returns 1 (true) or 0 (false) - -if !exists('*s:DelCommentSection') -fun! s:DelCommentSection() - - let l:restore = s:SavePos() - if s:InComment() - let l:sentinel = 'XmLSeNtInElXmL' - let l:len = strlen(l:sentinel) - if b:begcom - if search('-->','W' ) >=0 - exe "normal f>a".l:sentinel."\<Esc>" - call cursor(b:begcomline,b:begcomcol) - exe "normal \"xd/".l:sentinel."/e-".l:len."\<Cr>" - exe "normal ".l:len."x" - retu 1 - en - el - if search('<!--','bW' ) >=0 - let l:restore = s:SavePos() - call cursor(b:endcomline,b:endcomcol) - exe "normal a".l:sentinel."\<Esc>" - exe l:restore - exe "normal \"xd/".l:sentinel."/e-".l:len."\<Cr>" - exe "normal ".l:len."x" - retu 1 - en - en - en - exe l:restore - retu 0 -endf -en - -" DelCData() Is there a CData under the cursor? {{{1 -" - returns 1 (true) or 0 (false) - -if !exists('*s:DelCData') -fun! s:DelCData() - - let l:restore = s:SavePos() - if s:InCData() - if b:begdat - if search(']]>','W' ) >=0 - normal hh3x - call cursor(b:begdatline,b:begdatcol) - normal 9x - retu 1 - en - el - if search('<![CDATA[','bW' ) >=0 - normal 9x - call cursor(b:enddatline,b:enddatcol) - normal hh3x - retu 1 - en - en - en - exe l:restore - retu 0 -endf -en - -" InCData() Is there a CData under the cursor? {{{1 -" - returns 1 (true) or 0 (false) - -if !exists('*s:InCData') -fun! s:InCData() -let b:enddat=0 -let b:begdat=0 - - "Lets find forward a < or a >. If we first find a > we might be in a comment. - "If we find a < first or nothing we are definitly not in a Comment - - if getline('.')[col('.') - 1] == '>' - if getline('.')[col('.')-2] == ']' && getline('.')[col('.')-3] == ']' - let b:enddatcol=col('.') - let b:enddatline=line('.') - let b:enddat=1 - retu 1 - en - elseif getline('.')[col('.')-1] == '<' - if match(getline('.'),'<![CDATA[') > 0 - let b:begdatcol= col('.') - let b:begdatline=line('.') - let b:begdat=1 - retu 1 - en - en - "We are not standing on a begin/end comment - "Is the first > aending comment? - if search('[<>]','W') >0 - if getline('.')[col('.')-1] == '>' - if getline('.')[col('.')-2] == ']' && getline('.')[col('.')-3] == ']' - let b:enddatcol=col('.') - let b:enddatline=line('.') - let b:enddat=1 - retu 1 - en - en - en - "Forward is not a ending datment - "is backward a starting comment - - if search('[<>]','bW' ) >=0 - if getline('.')[col('.')-1] == '<' - if match(getline('.'),'<![CDATA[') > 0 - let l:newname = inputdialog('Found CDATA') - let b:begdatcol=col('.') - let b:begdatline=line('.') - let b:begdat=1 - retu 1 - en - en - en - retu 0 -endf -en - - -" DelCDataSection() Is there a CData under the cursor? {{{1 -" - returns 1 (true) or 0 (false) - -if !exists('*s:DelCDataSection') -fun! s:DelCDataSection() - - let l:restore = s:SavePos() - if s:InCData() - let l:sentinel = 'XmLSeNtInElXmL' - let l:len = strlen(l:sentinel) - if b:begdat - if search(']]>','W' ) >=0 - exe "normal f>a".l:sentinel."\<Esc>" - call cursor(b:begdatline,b:begdatcol) - exe "normal \"xd/".l:sentinel."/e-".l:len."\<Cr>" - exe "normal ".l:len."x" - retu 1 - en - el - if search('<![CDATA[','bW' ) >=0 - let l:restore = s:SavePos() - call cursor(b:enddatline,b:enddatcol) - exe "normal a".l:sentinel."\<Esc>" - exe l:restore - exe "normal \"xd/".l:sentinel."/e-".l:len."\<Cr>" - exe "normal ".l:len."x" - retu 1 - en - en - en - exe l:restore - retu 0 -endf -en - - -" Matches() Matches de tagname under de cursor {{{1 -if !exists('*s:Matches') -fun! s:Matches() - let l:restore = s:SavePos() - if s:TagUnderCursor() - if s:Match(b:tagName) - retu - en - en - exe l:restore -endf -en - -" MatchesVisual() Matches de tagname under de cursor {{{1 -if !exists('*s:MatchesVisual') -fun! s:MatchesVisual() - let l:restore = s:SavePos() - if s:TagUnderCursor() - if b:firstWasEndTag - normal f> - en - normal gv - if s:Match(b:tagName) - if b:firstWasEndTag == 0 - normal f> - en - retu - en - normal v - en - exe l:restore -endf -en - -" makeElement() makes the previous woord an tag and close {{{1 -if !exists('*s:makeElement') -function! s:makeElement() - let b:tagName = @@ - let b:haveAtt = 0 - let l:alone = (match(getline('.'),'^\s*>\s*$') >= 0) - let l:endOfLine = ((col('.')+1) == col('$')) - normal i<pf> - if b:html_mode && b:tagName =~? b:emptyTags - if b:haveAtt == 0 - call s:Callback (b:tagName, b:html_mode) - endif - if b:xml_use_xhtml - exe "normal i/\<Esc>l" - en - if l:endOfLine - start! - el - normal l - start - en - el - if b:haveAtt == 0 - call s:Callback (b:tagName, b:html_mode) - end - if l:alone - exe 'normal! o</pa>Ox>>$x' - start! - el - exe 'normal! a</pa>F<' - start - en - en -endfunction -en - -" CloseTagFun() closing the tag which is being typed {{{1 -if !exists('*s:CloseTagFun') -fun! s:CloseTagFun() - let l:restore = s:SavePos() - let l:endOfLine = ((col('.')+1) == col('$')) - if col('.') > 1 && getline('.')[col('.')-2] == '>' - "Multiline request. <t>></t> --> - "<t> - " cursor comes here - "</t> - normal h - if s:TagUnderCursor() - if b:firstWasEndTag == 0 - exe "normal 2f>s\<Cr>\<Esc>Ox\<Esc>>>$x" - start! - retu - en - en - elseif s:TagUnderCursor() - if b:firstWasEndTag == 0 - exe "normal />\<Cr>" - if b:html_mode && b:tagName =~? b:emptyTags - if b:haveAtt == 0 - call s:Callback (b:tagName, b:html_mode) - en - if b:xml_use_xhtml - exe "normal i/\<Esc>l" - en - if l:endOfLine - start! - retu - el - normal l - start - retu - en - el - if b:haveAtt == 0 - call s:Callback (b:tagName, b:html_mode) - en - exe "normal! a</" . b:tagName . ">\<Esc>F<" - start - retu - en - en - en - exe l:restore - if (col('.')+1) == col("$") - startinsert! - else - normal l - startinsert - en -endf -en - -" BlockTag() Surround a visual block with a tag {{{1 -" Be carefull where You place the block -" the top is done with insert! -" the bottem is done with append! -if !exists('*s:BlockTag') -fun! s:BlockTag(multi) - let l:newname = inputdialog('Surround block with : ',b:lastTag) - if strlen( l:newname) == 0 - retu - en - let b:lastTag = l:newname - let l:newatt = inputdialog('Attributes for '.l:newname.' : ',b:lastAtt) - if strlen(l:newatt) - let b:lastAtt = l:newatt - en - - "Get at the end of the block - if col('.') == col("'<") && line('.') == line("'<") - normal gvov - en - if a:multi - exe "normal! a\<Cr></".l:newname.">\<Cr>\<Esc>" - let l:eline = line('.') - normal gvov - if col('.') == col("'>") && line('.') == line("'>") - normal gvov - en - let l:sline = line(".") + 2 - exe "normal! i\<Cr><".l:newname. - \ (strlen(l:newatt) ? ' '.l:newatt : '' ) - \ .">\<Cr>\<Esc>" - let l:rep=&report - let &report=999999 - exe l:sline.','.l:eline.'>' - let &report= l:rep - exe 'normal '.l:sline.'G0mh'.l:eline."G$v'hgq" - el - exe "normal! a</".l:newname.">\<Esc>gvov" - if col('.') == col("'>") && line('.') == line("'>") - normal gvov - en - exe "normal! i<".l:newname. - \ (strlen(l:newatt) ? ' '.l:newatt : '' ) - \ .">\<Esc>" - en -endf -en -" BlockWith() Surround a visual block with a open and a close {{{1 -" Be carefull where You place the block -" the top is done with insert! -" the bottem is done with append! -if !exists('*s:BlockWith') -fun! s:BlockWith(open,close) - if col('.') == col("'<") && line('.') == line("'<") - normal gvov - en - exe "normal! a\<Cr>;x\<Esc>0cfx".a:close."\<Cr>\<Esc>" - normal gvov - exe "normal! i\<Cr>;x\<Esc>0cfx".a:open."\<Cr>\<Esc>" -endf -en -" vlistitem() Surround a visual block with a listitem para tag {{{1 -" Be carefull where You place the block -" the top is done with insert! -" the bottem is done with append! -if !exists('*s:vlistitem') -fun! s:vlistitem() - "Get at the end of the block - if col('.') == col("'<") && line('.') == line("'<") - normal gvov - en - exe "normal! a</para>\<Cr></listitem>\<Esc>mh" - normal gvov - exe "normal! i\<Cr><listitem>\<Cr>\<Tab><para>\<Esc>'h/listitem>/e+1\<Cr>" -endf -en -" Change() Only renames the tag {{{1 -if !exists('*s:Change') -fun! s:Change() - let l:restore = s:SavePos() - if s:TagUnderCursor() - let l:newname = inputdialog('Change tag '.b:tagName.' to : ',b:lastTag) - if strlen( l:newname) == 0 - retu - en - let b:lastTag = l:newname - if s:Match(b:tagName) - exe b:gotoCloseTag - exe 'normal 2lcw' . l:newname . "\<Esc>" - exe b:gotoOpenTag - exe 'normal lcw' . l:newname . "\<Esc>" - en - en -endf -en - -" Join() Joins two the same tag adjacent sections {{{1 -if !exists('*s:Join') -fun! s:Join() - let l:restore = s:SavePos() - if s:TagUnderCursor() - let l:pat = '<[^?!]\S\+\($\| \|\t\|>\)' - let l:flags='W' - if b:firstWasEndTag == 0 - let l:flags='Wb' - en - if search(s:OpenOrCloseTag,l:flags) > 0 - - let l:secondChar = getline('.')[col('.')] - if l:secondChar == '/' && b:firstWasEndTag ||l:secondChar != '/' && !b:firstWasEndTag - exe l:restore - retu - en - let l:end = 0 - if l:secondChar == '/' - let l:end = 1 - en - let l:name = s:GetTagName(col('.') + l:end) - if l:name == b:tagName - if b:firstWasEndTag - let b:gotoOpenTag = s:SavePos() - el - let b:gotoCloseTag = s:SavePos() - en - let l:DeleteTag = "normal d/>/e\<Cr>" - exe b:gotoCloseTag - exe l:DeleteTag - exe b:gotoOpenTag - exe l:DeleteTag - en - en - en - exe l:restore -endf -en - -" ChangeWholeTag() removes attributes and rename tag {{{1 -if !exists('*s:ChangeWholeTag') -fun! s:ChangeWholeTag() - if s:TagUnderCursor() - let l:newname = inputdialog('Change whole tag '.b:tagName.' to : ',b:lastTag) - if strlen(l:newname) == 0 - retu - en - let b:lastTag = l:newname - let l:newatt = inputdialog('Attributes for '.l:newname.' : ',b:lastAtt) - if strlen(l:newatt) - let b:lastAtt = l:newatt - en - if s:Match(b:tagName) - exe b:gotoCloseTag - exe "normal 2lc/>\<Cr>".l:newname."\<Esc>" - exe b:gotoOpenTag - exe "normal lc/>/\<Cr>".l:newname. - \ (strlen(l:newatt) ? ' '.l:newatt : '' ) - \."\<Esc>" - en - en -endf -en - -" Delete() Removes a tag '<a id="a">blah</a>' --> 'blah' {{{1 -if !exists('*s:Delete') -fun! s:Delete() - let l:restore = s:SavePos() - if s:TagUnderCursor() - if s:Match(b:tagName) - let l:DeleteTag = "normal d/>/e\<Cr>" - exe b:gotoCloseTag - exe l:DeleteTag - exe b:gotoOpenTag - exe l:DeleteTag - en - else - exe l:restore - en -endf -en - - -" DeleteSection() Deletes everything between start of open tag and end of {{{1 -" closing tag -if !exists('*s:DeleteSection') -fun! s:DeleteSection() - let l:restore = s:SavePos() - if s:TagUnderCursor() - if s:Match(b:tagName) - let l:sentinel = 'XmLSeNtInElXmL' - let l:len = strlen(l:sentinel) - let l:rep=&report - let &report=999999 - exe b:gotoCloseTag - exe "normal />\<Cr>a".l:sentinel."\<Esc>" - exe b:gotoOpenTag - exe "normal \"xd/".l:sentinel."/e-".l:len."\<Cr>" - exe "normal ".l:len."x" - let &report= l:rep - en - en -endf -en -" -" FoldTag() Fold the tag under the cursor {{{1 -if !exists('*s:FoldTag') -fun! s:FoldTag() - let l:restore = s:SavePos() - if s:TagUnderCursor() - let l:sline = line('.') - if s:Match(b:tagName) - if b:firstWasEndTag - exe '.,'.l:sline.'fold' - el - exe l:sline.',.fold' - en - en - el - exe l:restore - en -endf -en - -" FoldTagAll() Fold all tags of under the cursor {{{1 -" If no tag under the cursor it asks for a tag -if !exists('*s:FoldTagAll') -fun! s:FoldTagAll() - let l:restore = s:SavePos() - if s:TagUnderCursor() - let l:tname = b:tagName - el - let l:tname = inputdialog('Which tag to fold : ',b:lastTag) - if strlen(l:tname) == 0 - exe l:restore - retu - en - let b:lastTag = l:tname - en - normal G$ - let l:flag='w' - while search('<'.l:tname.s:OptAttrib,l:flag) > 0 - let l:flag='W' - let l:sline = line('.') - let l:level = 1 - while l:level && search('</\='.l:tname.s:OptAttrib,'W') > 0 - let l:level = l:level + (getline('.')[col('.')] == '/' ? -1 : 1) - endwhile - if l:level == 0 - exe l:sline.',.fold' - el - let l:tmp = - \ inputdialog("The tag ".l:tname."(".l:sline.") doesn't have a closetag") - break - en - endwhile - exe l:restore -endf -en - - -" StartTag() provide the opening tag {{{1 -if !exists('*s:StartTag') -fun! s:StartTag() - let l:restore = s:SavePos() - let l:level = 1 - if getline('.')[col('.')-1] == '<' - if s:TagUnderCursor() - if b:firstWasEndTag - exe 'normal! i<'. b:tagName.">\<Esc>F<" - retu - el - let l:level = l:level + 1 - en - en - exe l:restore - en - while l:level && search(s:OpenOrCloseTag ,'W') > 0 - let l:level = l:level + (getline('.')[col('.')] == '/' ? -1 : 1) - endwhile - if l:level == 0 - let l:Name = s:GetTagName(col('.') + 1) - exe l:restore - exe 'normal! i<'. l:Name.">\<Esc>" - en - exe l:restore -endf -en - - - -" EndTag() search for open tag and produce endtaf {{{1 -if !exists('*s:EndTag') -fun! s:EndTag() - let l:restore = s:SavePos() - let l:level = -1 - while l:level && search(s:OpenOrCloseTag,'bW') > 0 - let l:level = l:level + (getline('.')[col('.')] == '/' ? -1 : 1) - endwhile - if l:level == 0 - let l:Name = s:GetTagName(col('.')) - exe l:restore - exe 'normal a</'. l:Name.">\e" - el - exe l:restore - en -endf -en - - -" BeforeTag() surrounds the current tag with a new one {{{1 -if !exists('*s:BeforeTag') -fun! s:BeforeTag() - let l:restore = s:SavePos() - if s:TagUnderCursor() - let l:newname = - \ inputdialog('Surround Before Tag '.b:tagName.' with : ',b:lastTag) - if strlen(l:newname) == 0 - retu - en - let b:lastTag = l:newname - let l:newatt = inputdialog('Attributes for '.l:newname.' : ',b:lastAtt) - if strlen(l:newatt) - let b:lastAtt = l:newatt - en - if s:Match(b:tagName) - exe b:gotoCloseTag - exe "normal! />\<Cr>a\<Cr></" . l:newname . ">\<Esc>" - let l:To = line('.') - exe b:gotoOpenTag - exe 'normal! i<' . l:newname . - \ (strlen(l:newatt) ? ' '.l:newatt : '' ) - \.">\<Cr>\<Esc>" - let l:rep=&report - let &report=999999 - exe line('.').','.l:To.'>' - let &report= l:rep - en - exe l:restore - en -endf -en - -" CommentTag() surrounds the current tag with a new one {{{1 -if !exists('*s:CommentTag') -fun! s:CommentTag() - let l:restore = s:SavePos() - if s:TagUnderCursor() - if s:Match(b:tagName) - exe b:gotoCloseTag - exe "normal! />\<Cr>a\<Cr>-->\<Esc>" - let l:To = line('.') - exe b:gotoOpenTag - exe "normal! i<!--\<Cr>\<Esc>" - let l:rep=&report - let &report=999999 - exe line('.').','.l:To.'>' - let &report= l:rep - en - else - exe l:restore - en -endf -en -" AfterTag() surrounds the tags after the current one with new {{{1 -if !exists('*s:AfterTag') -fun! s:AfterTag() - let l:restore = s:SavePos() - if s:TagUnderCursor() - let l:newname = - \ inputdialog('Add Tag After '.b:tagName.' with : ',b:lastTag) - if strlen(l:newname) == 0 - retu - en - let b:lastTag = l:newname - let l:newatt = inputdialog('Attributes for '.l:newname.' : ',b:lastAtt) - if strlen(l:newatt) - let b:lastAtt = l:newatt - en - if s:Match(b:tagName) - exe b:gotoCloseTag - exe 'normal! i</' . l:newname . ">\<Cr>\<Esc>" - let l:To = line('.') - exe b:gotoOpenTag - exe "normal! />\<Cr>a\<Cr><".l:newname. - \ (strlen(l:newatt) ? ' '.l:newatt : '' ) - \.">\<Esc>" - let l:rep=&report - let &report=999999 - exe line('.').','.l:To.'>' - let &report= l:rep - en - en - exe l:restore -endf -en -" ShiftRight() Shift the tag to the right {{{1 -if !exists('*s:ShiftRight') -fun! s:ShiftRight() - let l:restore = s:SavePos() - if s:TagUnderCursor() - let l:sline = line('.') - if s:Match(b:tagName) - let l:eline = line('.') - if b:firstWasEndTag - exe l:eline.','.l:sline.'>' - el - exe l:sline.','.l:eline.'>' - en - en - en -endf -en - -" ShiftLeft() Shift the tag to the left {{{1 -if !exists('*s:ShiftLeft') -fun! s:ShiftLeft() - let l:restore = s:SavePos() - if s:TagUnderCursor() - let l:sline = line('.') - if s:Match(b:tagName) - let l:eline = line('.') - if b:firstWasEndTag - exe l:eline.','.l:sline.'<' - el - exe l:sline.','.l:eline.'<' - en - en - en -endf -en -" FormatTag() visual select the block and use gq {{{1 -if !exists('*s:FormatTag') -fun! s:FormatTag() - if s:TagUnderCursor() - if s:Match(b:tagName) - exe b:gotoCloseTag - normal hhmh - exe b:gotoOpenTag - exe "normal />/e+1\<Cr>v'hgq" - en - en -endf -en - - - - -" FormatTagAll() Format all tags of name under the cursor {{{1 -" If no tag under the cursor it asks for a tag -if !exists('*s:FormatTagAll') -fun! s:FormatTagAll() - let l:restore = s:SavePos() - if s:TagUnderCursor() - let l:tname = b:tagName - el - let l:tname = inputdialog('Format every tag : ') - if strlen(l:tname) == 0 - exe l:restore - retu - en - en - normal G$ - let l:flag = 'w' - while search('<'.l:tname . s:OptAttrib, l:flag) > 0 - let l:flag = 'W' - let l:sline = line('.') - let l:level = 1 - exe "normal />/e+1\<cr>mh" - while l:level && search('</\='.l:tname . s:EndofName,'W') > 0 - let l:level = l:level + (getline('.')[col('.')] == '/' ? -1 : 1) - endwhile - if l:level == 0 - normal hv'hogq - el - let l:tmp = - \ inputdialog("The tag ".l:tname."(".l:sline.") doesn't have a closetag") - break - en - endwhile - exe l:restore -endf -en - - -" IndentAll() indent all tags multiline {{{1 -if !exists('*s:IndentAll') -fun! s:IndentAll() - - let l:restore = s:SavePos() - let l:rep=&report - let &report=999999 - "shift everything left - normal 1G<G<G<G<G<G<GG$ - if search(s:OpenTag,'w') > 0 - let l:level = 1 - normal f> - "if there is something after the tag move that to the next line - if col('.')+1 != col('$') - echo "after tag".line('.') - exe "normal a\<Cr>\<Esc>" - el - normal j - en - normal >Gk$ - while search(s:OpenOrCloseTag,'W') > 0 - "if there is text before the tag then move the tag to the next line - if match(getline('.'),s:SpaceInfront) == -1 - exe "normal i\<Cr>\<Esc>l" - en - if getline('.')[col('.')] == '/' - normal <G0f> - "if there is something after the tag move that to the next line - if col('.')+1 != col('$') - exe "normal a\<Cr>\<Esc>" - en - let l:level = l:level - 1 - el - normal f> - "if there is something after the tag move that to the next line - if col('.')+1 != col('$') - exe "normal a\<Cr>\<Esc>" - el - normal j0 - en - normal >Gk$ - let l:level = l:level + 1 - en - endwhile - if l:level - let l:tmp = - \ inputdialog("The tags opening and closing are unbalanced ".l:level) - en - en - exe l:restore - let &report= l:rep -endf -en - - -" Menu options: {{{1 -augroup XML_menu_autos -au! -autocmd BufLeave,BufWinLeave * - \ if &filetype == "xml" || &filetype == "html" || &filetype == "xhtml" | - \ amenu disable Xml | - \ amenu disable Xml.* | - \ endif -autocmd BufEnter,BufWinEnter * - \ if &filetype == "xml" || &filetype == "html" || &filetype == "xhtml" | - \ amenu enable Xml | - \ amenu enable Xml.* | - \ endif -au BufNewFile * - \ if &filetype == "xml" || &filetype == "html" || &filetype == "xhtml" | - \ call NewFileXML() | - \ endif -augroup END -if !exists("g:did_xml_menu") - let g:did_xml_menu = 1 - :1011 vmenu <script> &Xml.BlockTag\ multi<Tab>V <Esc>:call <SID>BlockTag(1)<Cr> - vmenu <script> Xml.BlockTag\ inline<Tab>v <Esc>:call <SID>BlockTag(0)<CR> - vmenu <script> Xml.Insert\ listitem<Tab>l <Esc>:call <SID>vlistitem()<CR> - vmenu <script> Xml.Comment<Tab>< <Esc>:call <SID>BlockWith('<!--','-->')<Cr> - vmenu <script> Xml.Comment\ With\ CData<Tab>c <Esc>:call <SID>BlockWith('<![CDATA[',']]>')<Cr> - nmenu <script> Xml.Comment\ Tag<Tab>= <Esc>:call <SID>CommentTag()<Cr> - imenu <script> Xml.Comment\ Tag<Tab>= <Esc>:call <SID>CommentTag()<Cr> - nmenu <script> Xml.Change<Tab>c :call <SID>Change()<CR> - imenu <script> Xml.Change<Tab>c <C-C>:call <SID>Change()<CR> - nmenu <script> Xml.Change\ Whole\ Tag<Tab>C :call <SID>ChangeWholeTag()<CR> - imenu <script> Xml.Change\ Whole\ Tag<Tab>C <C-C>:call <SID>ChangeWholeTag()<CR> - nmenu <script> Xml.Delete\ Comment<Tab>] :call <SID>DelComment()<CR> - imenu <script> Xml.Delete\ Comment<Tab>] <C-C>:call <SID>DelComment()<CR> - nmenu <script> Xml.Delete\ Comment\ Section<Tab>} :call <SID>DelCommentSection()<CR> - imenu <script> Xml.Delete\ Comment\ Section<Tab>} <C-C>:call <SID>DelCommentSection()<CR> - nmenu <script> Xml.Delete\ CData<Tab>[ :call <SID>DelCData()<CR> - imenu <script> Xml.Delete\ CData<Tab>[ <C-C>:call <SID>DelCData()<CR> - nmenu <script> Xml.Delete\ CData\ Section<Tab>[ :call <SID>DelCDataSection()<CR> - imenu <script> Xml.Delete\ CData\ Section<Tab>[ <C-C>:call <SID>DelCDataSection()<CR> - nmenu <script> Xml.Delete\ Tag<Tab>d :call <SID>Delete()<CR> - imenu <script> Xml.Delete\ Tag<Tab>d <C-C>:call <SID>Delete()<CR> - nmenu <script> Xml.Delete\ Section<Tab>D :call <SID>DeleteSection()<CR> - imenu <script> Xml.Delete\ Section<Tab>D <C-C>:call <SID>DeleteSection()<CR> - nmenu <script> Xml.End\ Tag<Tab>e :call <SID>EndTag()<CR> - imenu <script> Xml.End\ Tag<Tab>e <C-C>:call <SID>EndTag()<CR> - nmenu <script> Xml.Fold\ Comment :?<!--?,/-->/fo<CR> - nmenu <script> Xml.Fold\ CData :?<!\[CDATA\[?,/\]\]>/fo<CR> - nmenu <script> Xml.Fold\ Processing\ instruc :?<\?[a-zA-Z]*?,/?>/fo<CR> - nmenu <script> Xml.Fold\ Tag<Tab>f :call <SID>FoldTag()<CR> - nmenu <script> Xml.Fold\ All\ Tags<Tab>F :call <SID>FoldTagAll()<CR> - nmenu <script> Xml.Format\ Tags<Tab>g :call <SID>FormatTag()<CR> - nmenu <script> Xml.Format\ All\ Tags<Tab>G :call <SID>FormatTagAll()<CR> - nmenu <script> Xml.Join<Tab>j :call <SID>Join()<CR> - imenu <script> Xml.Join<Tab>j <C-C>:call <SID>Join()<CR> - nmenu <script> Xml.Open\ After\ Tag<Tab>O :call <SID>AfterTag()<CR> - imenu <script> Xml.Open\ After\ Tag<Tab>O <C-C>:call <SID>AfterTag()<CR> - nmenu <script> Xml.open\ Before\ Tag<Tab>o :call <SID>BeforeTag()<CR> - imenu <script> Xml.open\ Before\ Tag<Tab>o <C-C>:call <SID>BeforeTag()<CR> - nmenu <script> Xml.Match<Tab>5 :call <SID>Matches()<CR> - imenu <script> Xml.Match<Tab>5 <C-C>:call <SID>Matches()<CR><C-\><C-G> - nmenu <script> Xml.Shift\ Left<Tab>< :call <SID>ShiftLeft()<CR> - imenu <script> Xml.Shift\ Left<Tab>< <C-C>:call <SID>ShiftLeft()<CR><C-\><C-G> - nmenu <script> Xml.Shift\ Right<Tab>> :call <SID>ShiftRight()<CR> - imenu <script> Xml.Shift\ Right<Tab>> <C-C>:call <SID>ShiftRight()<CR><C-\><C-G> - nmenu <script> Xml.Start\ Tag<Tab>s :call <SID>StartTag()<CR> - imenu <script> Xml.Start\ Tag<Tab>s <C-C>:call <SID>StartTag()<CR><C-\><C-G> -en - -" Section: Doc installation {{{1 -" Function: s:XmlInstallDocumentation(full_name, revision) {{{2 -" Install help documentation. -" Arguments: -" full_name: Full name of this vim plugin script, including path name. -" revision: Revision of the vim script. #version# mark in the document file -" will be replaced with this string with 'v' prefix. -" Return: -" 1 if new document installed, 0 otherwise. -" Note: Cleaned and generalized by guo-peng Wen -"''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - -function! s:XmlInstallDocumentation(full_name, revision) - " Name of the document path based on the system we use: - if (has("unix")) - " On UNIX like system, using forward slash: - let l:slash_char = '/' - let l:mkdir_cmd = ':silent !mkdir -p ' - else - " On M$ system, use backslash. Also mkdir syntax is different. - " This should only work on W2K and up. - let l:slash_char = '\' - let l:mkdir_cmd = ':silent !mkdir ' - endif - - let l:doc_path = l:slash_char . 'doc' - "let l:doc_home = l:slash_char . '.vim' . l:slash_char . 'doc' - - " Figure out document path based on full name of this script: - let l:vim_plugin_path = fnamemodify(a:full_name, ':h') - "let l:vim_doc_path = fnamemodify(a:full_name, ':h:h') . l:doc_path - let l:vim_doc_path = matchstr(l:vim_plugin_path, - \ '.\{-}\ze\%(\%(ft\)\=plugin\|macros\)') . l:doc_path - if (!(filewritable(l:vim_doc_path) == 2)) - echomsg "Doc path: " . l:vim_doc_path - execute l:mkdir_cmd . l:vim_doc_path - if (!(filewritable(l:vim_doc_path) == 2)) - " Try a default configuration in user home: - "let l:vim_doc_path = expand("~") . l:doc_home - let l:vim_doc_path = matchstr(&rtp, - \ escape($HOME, '\') .'[/\\]\%(\.vim\|vimfiles\)') - if (!(filewritable(l:vim_doc_path) == 2)) - execute l:mkdir_cmd . l:vim_doc_path - if (!(filewritable(l:vim_doc_path) == 2)) - " Put a warning: - echomsg "Unable to open documentation directory" - echomsg " type :help add-local-help for more informations." - return 0 - endif - endif - endif - endif - - " Exit if we have problem to access the document directory: - if (!isdirectory(l:vim_plugin_path) - \ || !isdirectory(l:vim_doc_path) - \ || filewritable(l:vim_doc_path) != 2) - return 0 - endif - - " Full name of script and documentation file: - let l:script_name = 'xml.vim' - let l:doc_name = 'xml-plugin.txt' - let l:plugin_file = l:vim_plugin_path . l:slash_char . l:script_name - let l:doc_file = l:vim_doc_path . l:slash_char . l:doc_name - - " Bail out if document file is still up to date: - if (filereadable(l:doc_file) && - \ getftime(l:plugin_file) < getftime(l:doc_file)) - return 0 - endif - - " Prepare window position restoring command: - if (strlen(@%)) - let l:go_back = 'b ' . bufnr("%") - else - let l:go_back = 'enew!' - endif - - " Create a new buffer & read in the plugin file (me): - setl nomodeline - exe 'enew!' - exe 'r ' . l:plugin_file - - setl modeline - let l:buf = bufnr("%") - setl noswapfile modifiable - - norm zR - norm gg - - " Delete from first line to a line starts with - " === START_DOC - 1,/^=\{3,}\s\+START_DOC\C/ d - - " Delete from a line starts with - " === END_DOC - " to the end of the documents: - /^=\{3,}\s\+END_DOC\C/,$ d - - " Remove fold marks: - "% s/{\{3}[1-9]/ / - - " Add modeline for help doc: the modeline string is mangled intentionally - " to avoid it be recognized by VIM: - call append(line('$'), '') - call append(line('$'), ' v' . 'im:tw=78:ts=8:fen:fdm=marker:ft=help:norl:') - - " Replace revision: - exe "normal :1,5s/#version#/ v" . a:revision . "/\<CR>" - - " Save the help document: - exe 'w! ' . l:doc_file - exe l:go_back - exe 'bw ' . l:buf - - " Build help tags: - exe 'helptags ' . l:vim_doc_path - - return 1 -endfunction -" }}}2 - -let s:revision= - \ substitute("$Revision: 1.35 $",'\$\S*: \([.0-9]\+\) \$','\1','') -silent! let s:install_status = - \ s:XmlInstallDocumentation(expand('<sfile>:p'), s:revision) -if (s:install_status == 1) - echom expand("<sfile>:t:r") . '-plugin v' . s:revision . - \ ': Help-documentation installed.' -endif - - -" Mappings of keys to functions {{{1 -nnoremap <silent> <buffer> <LocalLeader>5 :call <SID>Matches()<Cr> -vnoremap <silent> <buffer> <LocalLeader>5 <Esc>:call <SID>MatchesVisual()<Cr> -nnoremap <silent> <buffer> <LocalLeader>% :call <SID>Matches()<Cr> -vnoremap <silent> <buffer> <LocalLeader>% <Esc>:call <SID>MatchesVisual()<Cr> -nnoremap <silent> <buffer> <LocalLeader>c :call <SID>Change()<Cr> -nnoremap <silent> <buffer> <LocalLeader>C :call <SID>ChangeWholeTag()<Cr> -nnoremap <silent> <buffer> <LocalLeader>d :call <SID>Delete()<Cr> -nnoremap <silent> <buffer> <LocalLeader>D :call <SID>DeleteSection()<Cr> -nnoremap <silent> <buffer> <LocalLeader>e :call <SID>EndTag()<Cr> -nnoremap <silent> <buffer> <LocalLeader>] :call <SID>DelComment()<Cr> -nnoremap <silent> <buffer> <LocalLeader>} :call <SID>DelCommentSection()<Cr> -nnoremap <silent> <buffer> <LocalLeader>f :call <SID>FoldTag()<Cr> -nnoremap <silent> <buffer> <LocalLeader>F :call <SID>FoldTagAll()<Cr> -nnoremap <silent> <buffer> <LocalLeader>g :call <SID>FormatTag()<Cr> -nnoremap <silent> <buffer> <LocalLeader>G :call <SID>FormatTagAll()<Cr> -nnoremap <silent> <buffer> <LocalLeader>I :call <SID>IndentAll()<Cr> -nnoremap <silent> <buffer> <LocalLeader>j :call <SID>Join()<Cr> -nnoremap <silent> <buffer> <LocalLeader>O :call <SID>BeforeTag()<Cr> -nnoremap <silent> <buffer> <LocalLeader>= :call <SID>CommentTag()<Cr> -nnoremap <silent> <buffer> <LocalLeader>o :call <SID>AfterTag()<Cr> -nnoremap <silent> <buffer> <LocalLeader>s :call <SID>StartTag()<Cr> -nnoremap <silent> <buffer> <LocalLeader>[ :call <SID>DelCData()<Cr> -nnoremap <silent> <buffer> <LocalLeader>{ :call <SID>DelCDataSection()<Cr> -nnoremap <silent> <buffer> <LocalLeader>> :call <SID>ShiftRight()<Cr> -nnoremap <silent> <buffer> <LocalLeader>< :call <SID>ShiftLeft()<Cr> -vnoremap <silent> <buffer> <LocalLeader>l <Esc>:call <SID>vlistitem()<Cr> -vnoremap <silent> <buffer> <LocalLeader>v <Esc>:call <SID>BlockTag(0)<Cr> -vnoremap <silent> <buffer> <LocalLeader>V <Esc>:call <SID>BlockTag(1)<Cr> -vnoremap <silent> <buffer> <LocalLeader>c <Esc>:call <SID>BlockWith('<![CDATA[',']]>')<Cr> -vnoremap <silent> <buffer> <LocalLeader>< <Esc>:call <SID>BlockWith('<!--','-->')<Cr> - -" Move around functions. -noremap <silent><buffer> [[ m':call <SID>findOpenTag("bW")<CR> -noremap <silent><buffer> ]] m':call <SID>findOpenTag( "W")<CR> -noremap <silent><buffer> [] m':call <SID>findCloseTag( "bW")<CR> -noremap <silent><buffer> ][ m':call <SID>findCloseTag( "W")<CR> - -" Move around comments -noremap <silent><buffer> ]" :call search('^\(\s*<!--.*\n\)\@<!\(\s*-->\)', "W")<CR> -noremap <silent><buffer> [" :call search('\%(^\s*<!--.*\n\)\%(^\s*-->\)\@!', "bW")<CR> - - -setlocal iskeyword=@,48-57,_,192-255,58 -exe 'inoremap <silent> <buffer> '.b:suffix. " ><Esc>db:call <SID>makeElement()<Cr>" -if !exists("g:xml_tag_completion_map") - inoremap <silent> <buffer> > ><Esc>:call <SID>CloseTagFun()<Cr> -else - execute "inoremap <silent> <buffer> " . g:xml_tag_completion_map . " ><Esc>:call <SID>CloseTagFun()<Cr>" -endif - - - -finish - -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""/*}}}*/ -" Section: Documentation content {{{1 -"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -=== START_DOC -*xml-plugin.txt* Help edit XML and SGML documents. #version# - - XML Edit ~ - -A filetype plugin to help edit XML and SGML documents. - -This script provides some convenience when editing XML (and some SGML -including HTML) formated documents. It allows you to jump to the -beginning or end of the tag block your cursor is in. '%' will jump -between '<' and '>' within the tag your cursor is in. When in insert -mode and you finish a tag (pressing '>') the tag will be completed. If -you press '>' twice it will place the cursor in the middle of the tags -on it's own line (helps with nested tags). - -Usage: Place this file into your ftplugin directory. To add html support -Sym-link or copy this file to html.vim in your ftplugin directory. To activte -the script place 'filetype plugin on' in your |.vimrc| file. See |ftplugins| -for more information on this topic. - -If the file edited is of type "html" and "xml_use_html" is defined then -the following tags will not auto complete: <img>, <input>, <param>, -<frame>, <br>, <hr>, <meta>, <link>, <base>, <area> - -If the file edited is of type 'html' and 'xml_use_xhtml' is defined the -above tags will autocomplete the xml closing staying xhtml compatable. -ex. <hr> becomes <hr /> (see |xml-plugin-settings|) - -Known Bugs {{{1 ~ - -- < & > marks inside of a CDATA section are interpreted as actual XML tags - even if unmatched. -- The script can not handle leading spaces such as < tag></ tag> it is - illegal XML syntax and considered very bad form. -- Placing a literal `>' in an attribute value will auto complete despite that - the start tag isn't finished. This is poor XML anyway you should use - > instead. - - ------------------------------------------------------------------------------- - *xml-plugin-settings* -Options {{{1 - -(All options must be placed in your |.vimrc| prior to the |ftplugin| -command.) - -xml_tag_completion_map - Use this setting to change the default mapping to auto complete a - tag. By default typing a literal `>' will cause the tag your editing - to auto complete; pressing twice will auto nest the tag. By using - this setting the `>' will be a literal `>' and you must use the new - mapping to perform auto completion and auto nesting. For example if - you wanted Control-L to perform auto completion inmstead of typing a - `>' place the following into your .vimrc: > - let xml_tag_completion_map = "<C-l>" -< -xml_no_auto_nesting (Not Working!!!!!) - This turns off the auto nesting feature. After a completion is made - and another `>' is typed xml-edit automatically will break the tag - accross multiple lines and indent the curser to make creating nested - tqags easier. This feature turns it off. Enter the following in your - .vimrc: > - let xml_no_auto_nesting = 1 -< -xml_use_xhtml - When editing HTML this will auto close the short tags to make valid - XML like <hr/> and <br/>. Enter the following in your vimrc to - turn this option on: > - let xml_use_xhtml = 1 - if the filetype is xhtml and g:xml_use_xhtml doesn't exists - the script defines it to be 1. (This also assumes that you have linked - xml.vim to xhtml.vim. Otherwise this item is moot) - For a file to be of xhtml type there need to be a doctype declaration!! - just naming a file something.xhtml doesn't make it type xhtml! -< -xml_no_html - This turns of the support for HTML specific tags. Place this in your - .vimrc: > - let xml_no_html = 1 -< ------------------------------------------------------------------------------- - *xml-plugin-mappings* - -Mapings and their functions {{{1 - -Typing '>' will start the tag closing routine. -Typing (Where | means cursor position) - <para>| -results in - <para>|</para> - -Typing - <para>>|</para> -results in - <para> - | - </para> -typing a lone '>' and no '<' in front of it accepts the '>' (But having -lone '>' or '<' in a XML file is frown upon except in <!CDATA> sections, -and that will throw of the plugin!!). - -Typing </tag> or <tag/> also results in na expanding. So when editing -html type <input .... /> - -The closing routing also ignores DTD tags '<!,,>' and processing -instructions '<?....?>'. Thus typing these result in no expansion. - - -<LocalLeader> is a setting in VIM that depicts a prefix for scripts and -plugins to use. By default this is the backslash key `\'. See |mapleader| -for details. - -;; make element out previous word and close it {{{2 - - when typing a word;; wil create <word>|</word> - when word on its own line it will be - <word> - | - </word> - the suffix can be changed by setting - let makeElementSuf = ',,,' in your .vimrc - Thanks to Bart van Deenen - (http://www.vim.org/scripts/script.php?script_id=632) - -[ and ] mappings {{{2 - <LocalLeader>[ Delete <![CDATA[ ]]> delimiters - <LocalLeader>{ Delete <![CDATA[ ]]> section - <LocalLeader>] Delete <!-- --> delimiters - <LocalLeader>} Delete <!-- --> section - [[ Goto to the previous open tag - [[ Goto to the next open tag - [] Goto to the previous close tag - ][ Goto to the next close tag - [" Goto to the next comment - ]" Goto the previous comment -<LocalLeader>5 Jump to the matching tag. {{{2 -<LocalLeader>% Jump to the matching tag. - - -<LocalLeader>c Rename tag {{{2 - -<LocalLeader>C Rename tag and remove attributes {{{2 - Will ask for attributes - -<LocalLeader>d Deletes the surrounding tags from the cursor. {{{2 - <tag1>outter <tag2>inner text</tag2> text</tag1> - | - Turns to: - outter <tag2>inner text</tag2> text - | - -<LocalLeader>D Deletes the tag and it contents {{{2 - - and put it in register x. - <tag1>outter <tag2>inner text</tag2> text</tag1> - | - Turns to: - <tag1>outter text</tag1> - -<LocalLeader>e provide endtag for open tags. {{{2 - - provide endtag for open tags. Watch where de cursor is - <para><listitem>list item content - | - pressing \e twice produces - <para><listitem>list item content</para></listitem> - -<LocalLeader>f fold the tag under the cursor {{{2 - <para> - line 1 - line 2 - line 3 - </para> - \f produces - +-- 5 lines: <para>-------------------------- - - -<LocalLeader>F all tags of name 'tag' will be fold. {{{2 - - If there isn't a tag under - the cursor you will be asked for one. - -<LocalLeader>g Format (Vim's gq function) {{{2 - - will make a visual block of tag under cursor and then format using gq - - -<LocalLeader>G Format all tags under cursor (Vim's gq function) {{{2 - - If there isn't a tag under - the cursor you will be asked for one. - - -<LocalLeader>I Indent all tags {{{2 - - will create a multiline layout every opening tag will be shifted out - and every closing tag will be shifted in. Be aware that the rendering - of the XML through XSLT and/or DSSSL, might be changed by this. - Be aware tha if the file is big, more than 1000 lines, the reformatting - takes a long time because vim has to make a big undo buffer. - For example using \I on the example below: - - <chapter><title>Indent</title><para>The documentation</para></chapter> - - - Becomes - - <chapter> - <title> - Indent - </title> - <para> - The documentation - </para> - </chapter> - - -<LocalLeader>j Joins two the SAME sections together. {{{2 - - The sections must be next to each other. - <para> This is line 1 - of a paragraph. </para> - <para> This is line 2 - | - of a paragraph. </para> - \j produces - <para> This is line 1 - of a paragraph. - This is line 2 - of a paragraph. </para> - -<LocalLeader>l visual surround the block with listitem and para {{{2 - When marking up docbook tekst you have the issue that listitems - consist of 2 item. This key combination inserts them both, - - blaah - | - \l produces - <listitem> - <para>blaah</para> - </listitem> - -<LocalLeader>o Insert a tag inside the current one (like vim o) {{{2 - You are asked for tag and attributes. - - <tag1><tag2><tag3>blaah</tag3></tag2></tag1> - | - \o produces - <tag1> - <aftertag><tag2><tag3>blaah</tag3></tag2></aftertag> - </tag1> - -<LocalLeader>O Insert a tag outside the current one (like vim O) {{{2 - You are asked for tag and attributes. - <tag1><tag2><tag3>blaah</tag3></tag2></tag1> - | - \O produces - <beforetag> - <tag1><tag2><tag3>blaah</tag3></tag2></tag1> - </beforetag> - -<LocalLeader>s Insert an opening tag for an closing tag. {{{2 - list item content</para></listitem> - | - pressing \s twice produces - <para><listitem>list item content</para></listitem> - -<LocalLeader>[ Delete <![CDATA[ ]]> delimiters {{{2 - Removes Only <CDATA[ and ]]> - handy when you want to uncomment a section. - You need to stand in the tag and not on an other tag - <![CDATA[ <tag> ]]> - if you cursor is outside <tag> but inside the - CDATA tag the delition works. -<LocalLeader>{ Delete <![CDATA[ ]]> section {{{2 - Removes everything tag and Content -<LocalLeader>] Delete <!-- --> delimiters {{{2 - Uncommnet a block. -<LocalLeader>} Delete <!-- --> section {{{2 - Removes everything tag and Content -<LocalLeader>> shift right opening tag and closing tag. {{{2 - shift everything between the tags 1 shiftwide right -<LocalLeader>< shift left opening tag and closing tag. {{{2 - shift everything between the tags 1 shiftwide left -<LocalLeader>c Visual Place a CDATA section around the selected text. {{{2 - Place Cdata section around the block -<LocalLeader>< Visual Place a Comment around the selected text. {{{2 - Place comment around the block -<LocalLeader>5 Extend the visual selection to the matching tag. {{{2 -<LocalLeader>% - Extend the visual selection to the matching tag. Make sure you are at - the start of the opening tag or the end of the closing tag. -<LocalLeader>v Visual Place a tag around the selected text. {{{2 - - You are asked for tag and attributes. You - need to have selected text in visual mode before you can use this - mapping. See |visual-mode| for details. - Be careful where you place the marks. - The top uses append - The bottom uses append - Useful when marking up a text file - ------------------------------------------------------------------------------- - *xml-plugin-callbacks* - ------------------------------------------------------------------------------- - *xml-plugin-callbacks* - -Callback Functions {{{2 ~ - -A callback function is a function used to customize features on a per tag -basis. For example say you wish to have a default set of attributs when you -type an empty tag like this: - You type: <tag> - You get: <tag default="attributes"></tag> - -This is for any script programmers who wish to add xml-plugin support to -there own filetype plugins. - -Callback functions recive one attribute variable which is the tag name. The -all must return either a string or the number zero. If it returns a string -the plugin will place the string in the proper location. If it is a zero the -plugin will ignore and continue as if no callback existed. - -The following are implemented callback functions: - -HtmlAttribCallback - This is used to add default attributes to html tag. It is intended - for HTML files only. - -XmlAttribCallback - This is a generic callback for xml tags intended to add attributes. - - *xml-plugin-html* -Callback Example {{{2 ~ - -The following is an example of using XmlAttribCallback in your .vimrc -> - function XmlAttribCallback (xml_tag) - if a:xml_tag ==? "my-xml-tag" - return "attributes=\"my xml attributes\"" - else - return 0 - endif - endfunction -< -The following is a sample html.vim file type plugin you could use: -> - " Vim script file vim600:fdm=marker: - " FileType: HTML - " Maintainer: Devin Weaver <vim (at) tritarget.com> - " Location: http://www.vim.org/scripts/script.php?script_id=301 - - " This is a wrapper script to add extra html support to xml documents. - " Original script can be seen in xml-plugin documentation. - - " Only do this when not done yet for this buffer - if exists("b:did_ftplugin") - finish - endif - " Don't set 'b:did_ftplugin = 1' because that is xml.vim's responsability. - - let b:html_mode = 1 - - if !exists("*HtmlAttribCallback") - function HtmlAttribCallback( xml_tag ) - if a:xml_tag ==? "table" - return "cellpadding=\"0\" cellspacing=\"0\" border=\"0\"" - elseif a:xml_tag ==? "link" - return "href=\"/site.css\" rel=\"StyleSheet\" type=\"text/css\"" - elseif a:xml_tag ==? "body" - return "bgcolor=\"white\"" - elseif a:xml_tag ==? "frame" - return "name=\"NAME\" src=\"/\" scrolling=\"auto\" noresize" - elseif a:xml_tag ==? "frameset" - return "rows=\"0,*\" cols=\"*,0\" border=\"0\"" - elseif a:xml_tag ==? "img" - return "src=\"\" width=\"0\" height=\"0\" border=\"0\" alt=\"\"" - elseif a:xml_tag ==? "a" - if has("browse") - " Look up a file to fill the href. Used in local relative file - " links. typeing your own href before closing the tag with `>' - " will override this. - let cwd = getcwd() - let cwd = substitute (cwd, "\\", "/", "g") - let href = browse (0, "Link to href...", getcwd(), "") - let href = substitute (href, cwd . "/", "", "") - let href = substitute (href, " ", "%20", "g") - else - let href = "" - endif - return "href=\"" . href . "\"" - else - return 0 - endif - endfunction - endif - - " On to loading xml.vim - runtime ftplugin/xml.vim -< -=== END_DOC -"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" v im:tw=78:ts=8:ft=help:norl: -" vim600: set foldmethod=marker tabstop=8 shiftwidth=2 softtabstop=2 smartindent smarttab : -"fileencoding=iso-8859-15 -=== END_DOC -"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" - - - - - - -" Vim settingѕ {{{1 -" vim:tw=78:ts=2:ft=help:norl: -" vim: set foldmethod=marker tabstop=2 shiftwidth=2 softtabstop=2 smartindent smarttab : -"fileencoding=utf-8 - +xml.vim
\ No newline at end of file diff --git a/files/.vim/ftplugin/python.vim b/files/.vim/ftplugin/python.vim index a2c02dd..1bd39d7 100755 --- a/files/.vim/ftplugin/python.vim +++ b/files/.vim/ftplugin/python.vim @@ -1,4 +1,4 @@ setlocal tags+=$HOME/.vim/tags/python.ctags " Tag list settings -let g:Tlist_Show_One_File = 1 -let g:Tlist_GainFocus_On_ToggleOpen = 1 +let g:Tlist_Show_One_File = 1 +let g:Tlist_GainFocus_On_ToggleOpen = 1 diff --git a/files/.vim/ftplugin/xml.vim b/files/.vim/ftplugin/xml.vim index 55e9023..55e9023 100755..100644 --- a/files/.vim/ftplugin/xml.vim +++ b/files/.vim/ftplugin/xml.vim diff --git a/files/.vim/ftplugin/xsl.vim b/files/.vim/ftplugin/xsl.vim index eae609f..65289a9 100755..120000 --- a/files/.vim/ftplugin/xsl.vim +++ b/files/.vim/ftplugin/xsl.vim @@ -1,1860 +1 @@ -" Vim script file vim600:fdm=marker: -" FileType: XML -" Author: Rene de Zwart <renez (at) lightcon.xs4all.nl> -" Maintainer: Rene de Zwart <renez (at) lightcon.xs4all.nl> -" Last Change: $Date: 2007/03/17 12:39:40 $ -" Version: $Revision: 1.35 $ -" -" Licence: This program is free software; you can redistribute it -" and/or modify it under the terms of the GNU General Public -" License. See http://www.gnu.org/copyleft/gpl.txt -" Credits: Devin Weaver <vim (at) tritarget.com> et all -" for the original code. Guo-Peng Wen for the self -" install documentation code. -" Bart vam Deenen for makeElement function - - -" Observation - If you want to do something to a match pair most of the time -" you must do first the close tag. Because doing first the open -" tag could change the close tag position. - - - -" Only do this when not done yet for this buffer -if exists("b:did_ftplugin") - finish -endif -let b:did_ftplugin = 1 - -setlocal commentstring=<!--%s--> - -" XML: thanks to Johannes Zellner and Akbar Ibrahim -" - case sensitive -" - don't match empty tags <fred/> -" - match <!--, --> style comments (but not --, --) -" - match <!, > inlined dtd's. This is not perfect, as it -" gets confused for example by -" <!ENTITY gt ">"> -if exists("loaded_matchit") - let b:match_ignorecase=0 - let b:match_words = - \ '<:>,' . - \ '<\@<=!\[CDATA\[:]]>,'. - \ '<\@<=!--:-->,'. - \ '<\@<=?\k\+:?>,'. - \ '<\@<=\([^ \t>/]\+\)\%(\s\+[^>]*\%([^/]>\|$\)\|>\|$\):<\@<=/\1>,'. - \ '<\@<=\%([^ \t>/]\+\)\%(\s\+[^/>]*\|$\):/>' -endif - -" Script rgular expresion used. Documents those nasty criters {{{1 -let s:NoSlashBeforeGt = '\(\/\)\@\<!>' -" Don't check for quotes around attributes!!! -let s:Attrib = '\(\(\s\|\n\)\+\([^>= \t]\+=[^>&]\+\)\(\s\|\n\)*\)' -let s:OptAttrib = s:Attrib . '*'. s:NoSlashBeforeGt -let s:ReqAttrib = s:Attrib . '\+'. s:NoSlashBeforeGt -let s:OpenTag = '<[^!/?][^>]*' . s:OptAttrib -let s:OpenOrCloseTag = '<[^!?][^>]*'. s:OptAttrib -let s:CloseTag = '<\/[^>]*'. s:OptAttrib -let s:SpaceInfront = '^\s*<' -let s:EndofName = '\($\|\s\|>\)' - -" Buffer variables {{{1 -let b:emptyTags='^\(img\|input\|param\|frame\|br\|hr\|meta\|link\|base\|area\)$' -let b:firstWasEndTag = 0 -let b:html_mode =((&filetype =~ 'x\?html') && !exists("g:xml_no_html")) -let b:haveAtt = 0 -let b:lastTag = "" -let b:lastAtt = "" -let b:suffix = (exists('g:makeElementSuf') ? g:makeElementSuf : ';;') -let b:xml_use_xhtml = 0 -if exists('g:xml_use_xhtml') - let b:xml_use_xhtml = g:xml_use_xhtml -elseif &filetype == 'xhtml' - let b:xml_use_xhtml = 1 -en - - - - -" NewFileXML -> Inserts <?xml?> at top of new file. {{{1 -if !exists("*NewFileXML") -function! NewFileXML( ) - " Where is g:did_xhtmlcf_inits defined? - if &filetype == 'xml' || - \ (!exists ("g:did_xhtmlcf_inits") && - \ b:xml_use_xhtml && - \ (&filetype =~ 'x\?html')) - if append (0, '<?xml version="1.0"?>') - normal! G - endif - endif -endfunction -endif - - - -" Callback -> Checks for tag callbacks and executes them. {{{1 -if !exists("*s:Callback") -function! s:Callback( xml_tag, isHtml ) - let text = 0 - if a:isHtml == 1 && exists ("*HtmlAttribCallback") - let text = HtmlAttribCallback (a:xml_tag) - elseif exists ("*XmlAttribCallback") - let text = XmlAttribCallback (a:xml_tag) - endif - if text != '0' - execute "normal! i " . text ."\<Esc>l" - endif -endfunction -endif - -" SavePos() saves position in bufferwide variable {{{1 -if !exists('*s:SavePos') -fun! s:SavePos() - retu 'call cursor('.line('.').','. col('.'). ')' -endf -en - -" findOpenTag() {{{1 -if !exists('*s:findOpenTag') -fun! s:findOpenTag(flag) - call search(s:OpenTag,a:flag) -endf -en - -" findCloseTag() {{{1 -if !exists('*s:findCloseTag') -fun! s:findCloseTag(flag) - call search(s:CloseTag,a:flag) -endf -en - -" GetTagName() Gets the tagname from start position {{{1 -"Now lets go for the name part. The namepart are xmlnamechars which -"is quite a big range. We assume that everything after '<' or '</' -"until the first 'space', 'forward slash' or '>' ends de name part. -if !exists('*s:GetTagName') -fun! s:GetTagName(from) - let l:end = match(getline('.'), s:EndofName,a:from) - return strpart(getline('.'),a:from, l:end - a:from ) -endf -en -" hasAtt() Looks for attribute in open tag {{{1 -" expect cursor to be on < -if !exists('*s:hasAtt') -fun! s:hasAtt() - "Check if this open tag has attributes - let l:line = line('.') | let l:col = col('.') - if search(b:tagName . s:ReqAttrib,'W') > 0 - if l:line == line('.') && l:col == (col('.')-1) - let b:haveAtt = 1 - en - en -endf -en - - -" TagUnderCursor() Is there a tag under the cursor? {{{1 -" Set bufer wide variable -" - b:firstWasEndTag -" - b:tagName -" - b:endcol & b:endline only used by Match() -" - b:gotoCloseTag (if the tag under the cursor is one) -" - b:gotoOpenTag (if the tag under the cursor is one) -" on exit -" - returns 1 (true) or 0 (false) -" - position is at '<' -if !exists('*s:TagUnderCursor') -fun! s:TagUnderCursor() - let b:firstWasEndTag = 0 - let l:haveTag = 0 - let b:haveAtt = 0 - - "Lets find forward a < or a >. If we first find a > we might be in a tag. - "If we find a < first or nothing we are definitly not in a tag - - if getline('.')[col('.') - 1] == '>' - let b:endcol = col('.') - let b:endline = line('.') - if getline('.')[col('.')-2] == '/' - "we don't work with empty tags - retu l:haveTag - en - " begin: gwang customization for JSP development - if getline('.')[col('.')-2] == '%' - "we don't work with jsp %> tags - retu l:haveTag - en - " end: gwang customization for JSP development - " begin: gwang customization for PHP development - if getline('.')[col('.')-2] == '?' - "we don't work with php ?> tags - retu l:haveTag - en - " end: gwang customization for PHP development - elseif search('[<>]','W') >0 - if getline('.')[col('.')-1] == '>' - let b:endcol = col('.') - let b:endline = line('.') - if getline('.')[col('.')-2] == '-' - "we don't work with comment tags - retu l:haveTag - en - if getline('.')[col('.')-2] == '/' - "we don't work with empty tags - retu l:haveTag - en - el - retu l:haveTag - en - el - retu l:haveTag - en - - if search('[<>]','bW' ) >=0 - if getline('.')[col('.')-1] == '<' - if getline('.')[col('.')] == '/' - let b:firstWasEndTag = 1 - let b:gotoCloseTag = s:SavePos() - elseif getline('.')[col('.')] == '?' || getline('.')[col('.')] == '!' - "we don't deal with processing instructions or dtd - "related definitions - retu l:haveTag - el - let b:gotoOpenTag = s:SavePos() - en - el - retu l:haveTag - en - el - retu l:haveTag - en - - "we have established that we are between something like - "'</\?[^>]*>' - - let b:tagName = s:GetTagName(col('.') + b:firstWasEndTag) - "echo 'Tag ' . b:tagName - - "begin: gwang customization, do not work with an empty tag name - if b:tagName == '' - retu l:haveTag - en - "end: gwang customization, do not work with an empty tag name - - let l:haveTag = 1 - if b:firstWasEndTag == 0 - call s:hasAtt() - exe b:gotoOpenTag - en - retu l:haveTag -endf -en - -" Match(tagname) Looks for open or close tag of tagname {{{1 -" Set buffer wide variable -" - b:gotoCloseTag (if the Match tag is one) -" - b:gotoOpenTag (if the Match tag is one) -" on exit -" - returns 1 (true) or 0 (false) -" - position is at '<' -if !exists('*s:Match') -fun! s:Match(name) - let l:pat = '</\=' . a:name . s:OptAttrib - if b:firstWasEndTag - exe b:gotoCloseTag - let l:flags='bW' - let l:level = -1 - el - exe 'normal '.b:endline.'G0'.(b:endcol-1).'l' - let l:flags='W' - let l:level = 1 - en - while l:level && search(l:pat,l:flags) > 0 - let l:level = l:level + (getline('.')[col('.')] == '/' ? -1 : 1) - endwhile - if l:level - echo "no matching tag!!!!!" - retu l:level - en - if b:firstWasEndTag - let b:gotoOpenTag = s:SavePos() - call s:hasAtt() - exe b:gotoOpenTag - el - let b:gotoCloseTag = s:SavePos() - en - retu l:level == 0 -endf -en - -" InComment() Is there a Comment under the cursor? {{{1 -" - returns 1 (true) or 0 (false) - -if !exists('*s:InComment') -fun! s:InComment() -let b:endcom=0 -let b:begcom=0 - - "Lets find forward a < or a >. If we first find a > we might be in a comment. - "If we find a < first or nothing we are definitly not in a Comment - - if getline('.')[col('.') - 1] == '>' - if getline('.')[col('.')-2] == '-' && getline('.')[col('.')-3] == '-' - let b:endcomcol=col('.') - let b:endcomline=line('.') - let b:endcom=1 - retu 1 - en - elseif getline('.')[col('.')-1] == '<' && getline('.')[col('.')] == '!' - \ && getline('.')[col('.')+1] == '-' && getline('.')[col('.')+2] == '-' - let b:begcomcol= col('.') - let b:begcomline=line('.') - let b:begcom=1 - retu 1 - en - "We are not standing on a begin/end comment - "Is the first > an ending comment? - if search('[<>]','W') >0 - if getline('.')[col('.')-1] == '>' - if getline('.')[col('.')-2] == '-' && getline('.')[col('.')-3] == '-' - let b:endcomcol=col('.') - let b:endcomline=line('.') - let b:endcom=1 - retu 1 - en - en - en - "Forward is not a ending comment - "is backward a starting comment - - if search('[<>]','bW' ) >=0 - if getline('.')[col('.')-1] == '<' && getline('.')[col('.')] == '!' - \ && getline('.')[col('.')+1] == '-' && getline('.')[col('.')+2] == '-' - let b:begcomcol=col('.') - let b:begcomline=line('.') - let b:begcom=1 - retu 1 - en - en - retu 0 -endf -en - -" DelComment() Is there a Comment under the cursor? {{{1 -" - returns 1 (true) or 0 (false) - -if !exists('*s:DelComment') -fun! s:DelComment() - - let l:restore = s:SavePos() - if s:InComment() - if b:begcom - if search('-->','W' ) >=0 - normal hh3x - call cursor(b:begcomline,b:begcomcol) - normal 4x - retu 1 - en - el - if search('<!--','bW' ) >=0 - normal 4x - call cursor(b:endcomline,b:endcomcol) - normal hh3x - retu 1 - en - en - en - exe l:restore - retu 0 -endf -en - -" DelCommentSection() Is there a Comment under the cursor? {{{1 -" - returns 1 (true) or 0 (false) - -if !exists('*s:DelCommentSection') -fun! s:DelCommentSection() - - let l:restore = s:SavePos() - if s:InComment() - let l:sentinel = 'XmLSeNtInElXmL' - let l:len = strlen(l:sentinel) - if b:begcom - if search('-->','W' ) >=0 - exe "normal f>a".l:sentinel."\<Esc>" - call cursor(b:begcomline,b:begcomcol) - exe "normal \"xd/".l:sentinel."/e-".l:len."\<Cr>" - exe "normal ".l:len."x" - retu 1 - en - el - if search('<!--','bW' ) >=0 - let l:restore = s:SavePos() - call cursor(b:endcomline,b:endcomcol) - exe "normal a".l:sentinel."\<Esc>" - exe l:restore - exe "normal \"xd/".l:sentinel."/e-".l:len."\<Cr>" - exe "normal ".l:len."x" - retu 1 - en - en - en - exe l:restore - retu 0 -endf -en - -" DelCData() Is there a CData under the cursor? {{{1 -" - returns 1 (true) or 0 (false) - -if !exists('*s:DelCData') -fun! s:DelCData() - - let l:restore = s:SavePos() - if s:InCData() - if b:begdat - if search(']]>','W' ) >=0 - normal hh3x - call cursor(b:begdatline,b:begdatcol) - normal 9x - retu 1 - en - el - if search('<![CDATA[','bW' ) >=0 - normal 9x - call cursor(b:enddatline,b:enddatcol) - normal hh3x - retu 1 - en - en - en - exe l:restore - retu 0 -endf -en - -" InCData() Is there a CData under the cursor? {{{1 -" - returns 1 (true) or 0 (false) - -if !exists('*s:InCData') -fun! s:InCData() -let b:enddat=0 -let b:begdat=0 - - "Lets find forward a < or a >. If we first find a > we might be in a comment. - "If we find a < first or nothing we are definitly not in a Comment - - if getline('.')[col('.') - 1] == '>' - if getline('.')[col('.')-2] == ']' && getline('.')[col('.')-3] == ']' - let b:enddatcol=col('.') - let b:enddatline=line('.') - let b:enddat=1 - retu 1 - en - elseif getline('.')[col('.')-1] == '<' - if match(getline('.'),'<![CDATA[') > 0 - let b:begdatcol= col('.') - let b:begdatline=line('.') - let b:begdat=1 - retu 1 - en - en - "We are not standing on a begin/end comment - "Is the first > aending comment? - if search('[<>]','W') >0 - if getline('.')[col('.')-1] == '>' - if getline('.')[col('.')-2] == ']' && getline('.')[col('.')-3] == ']' - let b:enddatcol=col('.') - let b:enddatline=line('.') - let b:enddat=1 - retu 1 - en - en - en - "Forward is not a ending datment - "is backward a starting comment - - if search('[<>]','bW' ) >=0 - if getline('.')[col('.')-1] == '<' - if match(getline('.'),'<![CDATA[') > 0 - let l:newname = inputdialog('Found CDATA') - let b:begdatcol=col('.') - let b:begdatline=line('.') - let b:begdat=1 - retu 1 - en - en - en - retu 0 -endf -en - - -" DelCDataSection() Is there a CData under the cursor? {{{1 -" - returns 1 (true) or 0 (false) - -if !exists('*s:DelCDataSection') -fun! s:DelCDataSection() - - let l:restore = s:SavePos() - if s:InCData() - let l:sentinel = 'XmLSeNtInElXmL' - let l:len = strlen(l:sentinel) - if b:begdat - if search(']]>','W' ) >=0 - exe "normal f>a".l:sentinel."\<Esc>" - call cursor(b:begdatline,b:begdatcol) - exe "normal \"xd/".l:sentinel."/e-".l:len."\<Cr>" - exe "normal ".l:len."x" - retu 1 - en - el - if search('<![CDATA[','bW' ) >=0 - let l:restore = s:SavePos() - call cursor(b:enddatline,b:enddatcol) - exe "normal a".l:sentinel."\<Esc>" - exe l:restore - exe "normal \"xd/".l:sentinel."/e-".l:len."\<Cr>" - exe "normal ".l:len."x" - retu 1 - en - en - en - exe l:restore - retu 0 -endf -en - - -" Matches() Matches de tagname under de cursor {{{1 -if !exists('*s:Matches') -fun! s:Matches() - let l:restore = s:SavePos() - if s:TagUnderCursor() - if s:Match(b:tagName) - retu - en - en - exe l:restore -endf -en - -" MatchesVisual() Matches de tagname under de cursor {{{1 -if !exists('*s:MatchesVisual') -fun! s:MatchesVisual() - let l:restore = s:SavePos() - if s:TagUnderCursor() - if b:firstWasEndTag - normal f> - en - normal gv - if s:Match(b:tagName) - if b:firstWasEndTag == 0 - normal f> - en - retu - en - normal v - en - exe l:restore -endf -en - -" makeElement() makes the previous woord an tag and close {{{1 -if !exists('*s:makeElement') -function! s:makeElement() - let b:tagName = @@ - let b:haveAtt = 0 - let l:alone = (match(getline('.'),'^\s*>\s*$') >= 0) - let l:endOfLine = ((col('.')+1) == col('$')) - normal i<pf> - if b:html_mode && b:tagName =~? b:emptyTags - if b:haveAtt == 0 - call s:Callback (b:tagName, b:html_mode) - endif - if b:xml_use_xhtml - exe "normal i/\<Esc>l" - en - if l:endOfLine - start! - el - normal l - start - en - el - if b:haveAtt == 0 - call s:Callback (b:tagName, b:html_mode) - end - if l:alone - exe 'normal! o</pa>Ox>>$x' - start! - el - exe 'normal! a</pa>F<' - start - en - en -endfunction -en - -" CloseTagFun() closing the tag which is being typed {{{1 -if !exists('*s:CloseTagFun') -fun! s:CloseTagFun() - let l:restore = s:SavePos() - let l:endOfLine = ((col('.')+1) == col('$')) - if col('.') > 1 && getline('.')[col('.')-2] == '>' - "Multiline request. <t>></t> --> - "<t> - " cursor comes here - "</t> - normal h - if s:TagUnderCursor() - if b:firstWasEndTag == 0 - exe "normal 2f>s\<Cr>\<Esc>Ox\<Esc>>>$x" - start! - retu - en - en - elseif s:TagUnderCursor() - if b:firstWasEndTag == 0 - exe "normal />\<Cr>" - if b:html_mode && b:tagName =~? b:emptyTags - if b:haveAtt == 0 - call s:Callback (b:tagName, b:html_mode) - en - if b:xml_use_xhtml - exe "normal i/\<Esc>l" - en - if l:endOfLine - start! - retu - el - normal l - start - retu - en - el - if b:haveAtt == 0 - call s:Callback (b:tagName, b:html_mode) - en - exe "normal! a</" . b:tagName . ">\<Esc>F<" - start - retu - en - en - en - exe l:restore - if (col('.')+1) == col("$") - startinsert! - else - normal l - startinsert - en -endf -en - -" BlockTag() Surround a visual block with a tag {{{1 -" Be carefull where You place the block -" the top is done with insert! -" the bottem is done with append! -if !exists('*s:BlockTag') -fun! s:BlockTag(multi) - let l:newname = inputdialog('Surround block with : ',b:lastTag) - if strlen( l:newname) == 0 - retu - en - let b:lastTag = l:newname - let l:newatt = inputdialog('Attributes for '.l:newname.' : ',b:lastAtt) - if strlen(l:newatt) - let b:lastAtt = l:newatt - en - - "Get at the end of the block - if col('.') == col("'<") && line('.') == line("'<") - normal gvov - en - if a:multi - exe "normal! a\<Cr></".l:newname.">\<Cr>\<Esc>" - let l:eline = line('.') - normal gvov - if col('.') == col("'>") && line('.') == line("'>") - normal gvov - en - let l:sline = line(".") + 2 - exe "normal! i\<Cr><".l:newname. - \ (strlen(l:newatt) ? ' '.l:newatt : '' ) - \ .">\<Cr>\<Esc>" - let l:rep=&report - let &report=999999 - exe l:sline.','.l:eline.'>' - let &report= l:rep - exe 'normal '.l:sline.'G0mh'.l:eline."G$v'hgq" - el - exe "normal! a</".l:newname.">\<Esc>gvov" - if col('.') == col("'>") && line('.') == line("'>") - normal gvov - en - exe "normal! i<".l:newname. - \ (strlen(l:newatt) ? ' '.l:newatt : '' ) - \ .">\<Esc>" - en -endf -en -" BlockWith() Surround a visual block with a open and a close {{{1 -" Be carefull where You place the block -" the top is done with insert! -" the bottem is done with append! -if !exists('*s:BlockWith') -fun! s:BlockWith(open,close) - if col('.') == col("'<") && line('.') == line("'<") - normal gvov - en - exe "normal! a\<Cr>;x\<Esc>0cfx".a:close."\<Cr>\<Esc>" - normal gvov - exe "normal! i\<Cr>;x\<Esc>0cfx".a:open."\<Cr>\<Esc>" -endf -en -" vlistitem() Surround a visual block with a listitem para tag {{{1 -" Be carefull where You place the block -" the top is done with insert! -" the bottem is done with append! -if !exists('*s:vlistitem') -fun! s:vlistitem() - "Get at the end of the block - if col('.') == col("'<") && line('.') == line("'<") - normal gvov - en - exe "normal! a</para>\<Cr></listitem>\<Esc>mh" - normal gvov - exe "normal! i\<Cr><listitem>\<Cr>\<Tab><para>\<Esc>'h/listitem>/e+1\<Cr>" -endf -en -" Change() Only renames the tag {{{1 -if !exists('*s:Change') -fun! s:Change() - let l:restore = s:SavePos() - if s:TagUnderCursor() - let l:newname = inputdialog('Change tag '.b:tagName.' to : ',b:lastTag) - if strlen( l:newname) == 0 - retu - en - let b:lastTag = l:newname - if s:Match(b:tagName) - exe b:gotoCloseTag - exe 'normal 2lcw' . l:newname . "\<Esc>" - exe b:gotoOpenTag - exe 'normal lcw' . l:newname . "\<Esc>" - en - en -endf -en - -" Join() Joins two the same tag adjacent sections {{{1 -if !exists('*s:Join') -fun! s:Join() - let l:restore = s:SavePos() - if s:TagUnderCursor() - let l:pat = '<[^?!]\S\+\($\| \|\t\|>\)' - let l:flags='W' - if b:firstWasEndTag == 0 - let l:flags='Wb' - en - if search(s:OpenOrCloseTag,l:flags) > 0 - - let l:secondChar = getline('.')[col('.')] - if l:secondChar == '/' && b:firstWasEndTag ||l:secondChar != '/' && !b:firstWasEndTag - exe l:restore - retu - en - let l:end = 0 - if l:secondChar == '/' - let l:end = 1 - en - let l:name = s:GetTagName(col('.') + l:end) - if l:name == b:tagName - if b:firstWasEndTag - let b:gotoOpenTag = s:SavePos() - el - let b:gotoCloseTag = s:SavePos() - en - let l:DeleteTag = "normal d/>/e\<Cr>" - exe b:gotoCloseTag - exe l:DeleteTag - exe b:gotoOpenTag - exe l:DeleteTag - en - en - en - exe l:restore -endf -en - -" ChangeWholeTag() removes attributes and rename tag {{{1 -if !exists('*s:ChangeWholeTag') -fun! s:ChangeWholeTag() - if s:TagUnderCursor() - let l:newname = inputdialog('Change whole tag '.b:tagName.' to : ',b:lastTag) - if strlen(l:newname) == 0 - retu - en - let b:lastTag = l:newname - let l:newatt = inputdialog('Attributes for '.l:newname.' : ',b:lastAtt) - if strlen(l:newatt) - let b:lastAtt = l:newatt - en - if s:Match(b:tagName) - exe b:gotoCloseTag - exe "normal 2lc/>\<Cr>".l:newname."\<Esc>" - exe b:gotoOpenTag - exe "normal lc/>/\<Cr>".l:newname. - \ (strlen(l:newatt) ? ' '.l:newatt : '' ) - \."\<Esc>" - en - en -endf -en - -" Delete() Removes a tag '<a id="a">blah</a>' --> 'blah' {{{1 -if !exists('*s:Delete') -fun! s:Delete() - let l:restore = s:SavePos() - if s:TagUnderCursor() - if s:Match(b:tagName) - let l:DeleteTag = "normal d/>/e\<Cr>" - exe b:gotoCloseTag - exe l:DeleteTag - exe b:gotoOpenTag - exe l:DeleteTag - en - else - exe l:restore - en -endf -en - - -" DeleteSection() Deletes everything between start of open tag and end of {{{1 -" closing tag -if !exists('*s:DeleteSection') -fun! s:DeleteSection() - let l:restore = s:SavePos() - if s:TagUnderCursor() - if s:Match(b:tagName) - let l:sentinel = 'XmLSeNtInElXmL' - let l:len = strlen(l:sentinel) - let l:rep=&report - let &report=999999 - exe b:gotoCloseTag - exe "normal />\<Cr>a".l:sentinel."\<Esc>" - exe b:gotoOpenTag - exe "normal \"xd/".l:sentinel."/e-".l:len."\<Cr>" - exe "normal ".l:len."x" - let &report= l:rep - en - en -endf -en -" -" FoldTag() Fold the tag under the cursor {{{1 -if !exists('*s:FoldTag') -fun! s:FoldTag() - let l:restore = s:SavePos() - if s:TagUnderCursor() - let l:sline = line('.') - if s:Match(b:tagName) - if b:firstWasEndTag - exe '.,'.l:sline.'fold' - el - exe l:sline.',.fold' - en - en - el - exe l:restore - en -endf -en - -" FoldTagAll() Fold all tags of under the cursor {{{1 -" If no tag under the cursor it asks for a tag -if !exists('*s:FoldTagAll') -fun! s:FoldTagAll() - let l:restore = s:SavePos() - if s:TagUnderCursor() - let l:tname = b:tagName - el - let l:tname = inputdialog('Which tag to fold : ',b:lastTag) - if strlen(l:tname) == 0 - exe l:restore - retu - en - let b:lastTag = l:tname - en - normal G$ - let l:flag='w' - while search('<'.l:tname.s:OptAttrib,l:flag) > 0 - let l:flag='W' - let l:sline = line('.') - let l:level = 1 - while l:level && search('</\='.l:tname.s:OptAttrib,'W') > 0 - let l:level = l:level + (getline('.')[col('.')] == '/' ? -1 : 1) - endwhile - if l:level == 0 - exe l:sline.',.fold' - el - let l:tmp = - \ inputdialog("The tag ".l:tname."(".l:sline.") doesn't have a closetag") - break - en - endwhile - exe l:restore -endf -en - - -" StartTag() provide the opening tag {{{1 -if !exists('*s:StartTag') -fun! s:StartTag() - let l:restore = s:SavePos() - let l:level = 1 - if getline('.')[col('.')-1] == '<' - if s:TagUnderCursor() - if b:firstWasEndTag - exe 'normal! i<'. b:tagName.">\<Esc>F<" - retu - el - let l:level = l:level + 1 - en - en - exe l:restore - en - while l:level && search(s:OpenOrCloseTag ,'W') > 0 - let l:level = l:level + (getline('.')[col('.')] == '/' ? -1 : 1) - endwhile - if l:level == 0 - let l:Name = s:GetTagName(col('.') + 1) - exe l:restore - exe 'normal! i<'. l:Name.">\<Esc>" - en - exe l:restore -endf -en - - - -" EndTag() search for open tag and produce endtaf {{{1 -if !exists('*s:EndTag') -fun! s:EndTag() - let l:restore = s:SavePos() - let l:level = -1 - while l:level && search(s:OpenOrCloseTag,'bW') > 0 - let l:level = l:level + (getline('.')[col('.')] == '/' ? -1 : 1) - endwhile - if l:level == 0 - let l:Name = s:GetTagName(col('.')) - exe l:restore - exe 'normal a</'. l:Name.">\e" - el - exe l:restore - en -endf -en - - -" BeforeTag() surrounds the current tag with a new one {{{1 -if !exists('*s:BeforeTag') -fun! s:BeforeTag() - let l:restore = s:SavePos() - if s:TagUnderCursor() - let l:newname = - \ inputdialog('Surround Before Tag '.b:tagName.' with : ',b:lastTag) - if strlen(l:newname) == 0 - retu - en - let b:lastTag = l:newname - let l:newatt = inputdialog('Attributes for '.l:newname.' : ',b:lastAtt) - if strlen(l:newatt) - let b:lastAtt = l:newatt - en - if s:Match(b:tagName) - exe b:gotoCloseTag - exe "normal! />\<Cr>a\<Cr></" . l:newname . ">\<Esc>" - let l:To = line('.') - exe b:gotoOpenTag - exe 'normal! i<' . l:newname . - \ (strlen(l:newatt) ? ' '.l:newatt : '' ) - \.">\<Cr>\<Esc>" - let l:rep=&report - let &report=999999 - exe line('.').','.l:To.'>' - let &report= l:rep - en - exe l:restore - en -endf -en - -" CommentTag() surrounds the current tag with a new one {{{1 -if !exists('*s:CommentTag') -fun! s:CommentTag() - let l:restore = s:SavePos() - if s:TagUnderCursor() - if s:Match(b:tagName) - exe b:gotoCloseTag - exe "normal! />\<Cr>a\<Cr>-->\<Esc>" - let l:To = line('.') - exe b:gotoOpenTag - exe "normal! i<!--\<Cr>\<Esc>" - let l:rep=&report - let &report=999999 - exe line('.').','.l:To.'>' - let &report= l:rep - en - else - exe l:restore - en -endf -en -" AfterTag() surrounds the tags after the current one with new {{{1 -if !exists('*s:AfterTag') -fun! s:AfterTag() - let l:restore = s:SavePos() - if s:TagUnderCursor() - let l:newname = - \ inputdialog('Add Tag After '.b:tagName.' with : ',b:lastTag) - if strlen(l:newname) == 0 - retu - en - let b:lastTag = l:newname - let l:newatt = inputdialog('Attributes for '.l:newname.' : ',b:lastAtt) - if strlen(l:newatt) - let b:lastAtt = l:newatt - en - if s:Match(b:tagName) - exe b:gotoCloseTag - exe 'normal! i</' . l:newname . ">\<Cr>\<Esc>" - let l:To = line('.') - exe b:gotoOpenTag - exe "normal! />\<Cr>a\<Cr><".l:newname. - \ (strlen(l:newatt) ? ' '.l:newatt : '' ) - \.">\<Esc>" - let l:rep=&report - let &report=999999 - exe line('.').','.l:To.'>' - let &report= l:rep - en - en - exe l:restore -endf -en -" ShiftRight() Shift the tag to the right {{{1 -if !exists('*s:ShiftRight') -fun! s:ShiftRight() - let l:restore = s:SavePos() - if s:TagUnderCursor() - let l:sline = line('.') - if s:Match(b:tagName) - let l:eline = line('.') - if b:firstWasEndTag - exe l:eline.','.l:sline.'>' - el - exe l:sline.','.l:eline.'>' - en - en - en -endf -en - -" ShiftLeft() Shift the tag to the left {{{1 -if !exists('*s:ShiftLeft') -fun! s:ShiftLeft() - let l:restore = s:SavePos() - if s:TagUnderCursor() - let l:sline = line('.') - if s:Match(b:tagName) - let l:eline = line('.') - if b:firstWasEndTag - exe l:eline.','.l:sline.'<' - el - exe l:sline.','.l:eline.'<' - en - en - en -endf -en -" FormatTag() visual select the block and use gq {{{1 -if !exists('*s:FormatTag') -fun! s:FormatTag() - if s:TagUnderCursor() - if s:Match(b:tagName) - exe b:gotoCloseTag - normal hhmh - exe b:gotoOpenTag - exe "normal />/e+1\<Cr>v'hgq" - en - en -endf -en - - - - -" FormatTagAll() Format all tags of name under the cursor {{{1 -" If no tag under the cursor it asks for a tag -if !exists('*s:FormatTagAll') -fun! s:FormatTagAll() - let l:restore = s:SavePos() - if s:TagUnderCursor() - let l:tname = b:tagName - el - let l:tname = inputdialog('Format every tag : ') - if strlen(l:tname) == 0 - exe l:restore - retu - en - en - normal G$ - let l:flag = 'w' - while search('<'.l:tname . s:OptAttrib, l:flag) > 0 - let l:flag = 'W' - let l:sline = line('.') - let l:level = 1 - exe "normal />/e+1\<cr>mh" - while l:level && search('</\='.l:tname . s:EndofName,'W') > 0 - let l:level = l:level + (getline('.')[col('.')] == '/' ? -1 : 1) - endwhile - if l:level == 0 - normal hv'hogq - el - let l:tmp = - \ inputdialog("The tag ".l:tname."(".l:sline.") doesn't have a closetag") - break - en - endwhile - exe l:restore -endf -en - - -" IndentAll() indent all tags multiline {{{1 -if !exists('*s:IndentAll') -fun! s:IndentAll() - - let l:restore = s:SavePos() - let l:rep=&report - let &report=999999 - "shift everything left - normal 1G<G<G<G<G<G<GG$ - if search(s:OpenTag,'w') > 0 - let l:level = 1 - normal f> - "if there is something after the tag move that to the next line - if col('.')+1 != col('$') - echo "after tag".line('.') - exe "normal a\<Cr>\<Esc>" - el - normal j - en - normal >Gk$ - while search(s:OpenOrCloseTag,'W') > 0 - "if there is text before the tag then move the tag to the next line - if match(getline('.'),s:SpaceInfront) == -1 - exe "normal i\<Cr>\<Esc>l" - en - if getline('.')[col('.')] == '/' - normal <G0f> - "if there is something after the tag move that to the next line - if col('.')+1 != col('$') - exe "normal a\<Cr>\<Esc>" - en - let l:level = l:level - 1 - el - normal f> - "if there is something after the tag move that to the next line - if col('.')+1 != col('$') - exe "normal a\<Cr>\<Esc>" - el - normal j0 - en - normal >Gk$ - let l:level = l:level + 1 - en - endwhile - if l:level - let l:tmp = - \ inputdialog("The tags opening and closing are unbalanced ".l:level) - en - en - exe l:restore - let &report= l:rep -endf -en - - -" Menu options: {{{1 -augroup XML_menu_autos -au! -autocmd BufLeave,BufWinLeave * - \ if &filetype == "xml" || &filetype == "html" || &filetype == "xhtml" | - \ amenu disable Xml | - \ amenu disable Xml.* | - \ endif -autocmd BufEnter,BufWinEnter * - \ if &filetype == "xml" || &filetype == "html" || &filetype == "xhtml" | - \ amenu enable Xml | - \ amenu enable Xml.* | - \ endif -au BufNewFile * - \ if &filetype == "xml" || &filetype == "html" || &filetype == "xhtml" | - \ call NewFileXML() | - \ endif -augroup END -if !exists("g:did_xml_menu") - let g:did_xml_menu = 1 - :1011 vmenu <script> &Xml.BlockTag\ multi<Tab>V <Esc>:call <SID>BlockTag(1)<Cr> - vmenu <script> Xml.BlockTag\ inline<Tab>v <Esc>:call <SID>BlockTag(0)<CR> - vmenu <script> Xml.Insert\ listitem<Tab>l <Esc>:call <SID>vlistitem()<CR> - vmenu <script> Xml.Comment<Tab>< <Esc>:call <SID>BlockWith('<!--','-->')<Cr> - vmenu <script> Xml.Comment\ With\ CData<Tab>c <Esc>:call <SID>BlockWith('<![CDATA[',']]>')<Cr> - nmenu <script> Xml.Comment\ Tag<Tab>= <Esc>:call <SID>CommentTag()<Cr> - imenu <script> Xml.Comment\ Tag<Tab>= <Esc>:call <SID>CommentTag()<Cr> - nmenu <script> Xml.Change<Tab>c :call <SID>Change()<CR> - imenu <script> Xml.Change<Tab>c <C-C>:call <SID>Change()<CR> - nmenu <script> Xml.Change\ Whole\ Tag<Tab>C :call <SID>ChangeWholeTag()<CR> - imenu <script> Xml.Change\ Whole\ Tag<Tab>C <C-C>:call <SID>ChangeWholeTag()<CR> - nmenu <script> Xml.Delete\ Comment<Tab>] :call <SID>DelComment()<CR> - imenu <script> Xml.Delete\ Comment<Tab>] <C-C>:call <SID>DelComment()<CR> - nmenu <script> Xml.Delete\ Comment\ Section<Tab>} :call <SID>DelCommentSection()<CR> - imenu <script> Xml.Delete\ Comment\ Section<Tab>} <C-C>:call <SID>DelCommentSection()<CR> - nmenu <script> Xml.Delete\ CData<Tab>[ :call <SID>DelCData()<CR> - imenu <script> Xml.Delete\ CData<Tab>[ <C-C>:call <SID>DelCData()<CR> - nmenu <script> Xml.Delete\ CData\ Section<Tab>[ :call <SID>DelCDataSection()<CR> - imenu <script> Xml.Delete\ CData\ Section<Tab>[ <C-C>:call <SID>DelCDataSection()<CR> - nmenu <script> Xml.Delete\ Tag<Tab>d :call <SID>Delete()<CR> - imenu <script> Xml.Delete\ Tag<Tab>d <C-C>:call <SID>Delete()<CR> - nmenu <script> Xml.Delete\ Section<Tab>D :call <SID>DeleteSection()<CR> - imenu <script> Xml.Delete\ Section<Tab>D <C-C>:call <SID>DeleteSection()<CR> - nmenu <script> Xml.End\ Tag<Tab>e :call <SID>EndTag()<CR> - imenu <script> Xml.End\ Tag<Tab>e <C-C>:call <SID>EndTag()<CR> - nmenu <script> Xml.Fold\ Comment :?<!--?,/-->/fo<CR> - nmenu <script> Xml.Fold\ CData :?<!\[CDATA\[?,/\]\]>/fo<CR> - nmenu <script> Xml.Fold\ Processing\ instruc :?<\?[a-zA-Z]*?,/?>/fo<CR> - nmenu <script> Xml.Fold\ Tag<Tab>f :call <SID>FoldTag()<CR> - nmenu <script> Xml.Fold\ All\ Tags<Tab>F :call <SID>FoldTagAll()<CR> - nmenu <script> Xml.Format\ Tags<Tab>g :call <SID>FormatTag()<CR> - nmenu <script> Xml.Format\ All\ Tags<Tab>G :call <SID>FormatTagAll()<CR> - nmenu <script> Xml.Join<Tab>j :call <SID>Join()<CR> - imenu <script> Xml.Join<Tab>j <C-C>:call <SID>Join()<CR> - nmenu <script> Xml.Open\ After\ Tag<Tab>O :call <SID>AfterTag()<CR> - imenu <script> Xml.Open\ After\ Tag<Tab>O <C-C>:call <SID>AfterTag()<CR> - nmenu <script> Xml.open\ Before\ Tag<Tab>o :call <SID>BeforeTag()<CR> - imenu <script> Xml.open\ Before\ Tag<Tab>o <C-C>:call <SID>BeforeTag()<CR> - nmenu <script> Xml.Match<Tab>5 :call <SID>Matches()<CR> - imenu <script> Xml.Match<Tab>5 <C-C>:call <SID>Matches()<CR><C-\><C-G> - nmenu <script> Xml.Shift\ Left<Tab>< :call <SID>ShiftLeft()<CR> - imenu <script> Xml.Shift\ Left<Tab>< <C-C>:call <SID>ShiftLeft()<CR><C-\><C-G> - nmenu <script> Xml.Shift\ Right<Tab>> :call <SID>ShiftRight()<CR> - imenu <script> Xml.Shift\ Right<Tab>> <C-C>:call <SID>ShiftRight()<CR><C-\><C-G> - nmenu <script> Xml.Start\ Tag<Tab>s :call <SID>StartTag()<CR> - imenu <script> Xml.Start\ Tag<Tab>s <C-C>:call <SID>StartTag()<CR><C-\><C-G> -en - -" Section: Doc installation {{{1 -" Function: s:XmlInstallDocumentation(full_name, revision) {{{2 -" Install help documentation. -" Arguments: -" full_name: Full name of this vim plugin script, including path name. -" revision: Revision of the vim script. #version# mark in the document file -" will be replaced with this string with 'v' prefix. -" Return: -" 1 if new document installed, 0 otherwise. -" Note: Cleaned and generalized by guo-peng Wen -"''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - -function! s:XmlInstallDocumentation(full_name, revision) - " Name of the document path based on the system we use: - if (has("unix")) - " On UNIX like system, using forward slash: - let l:slash_char = '/' - let l:mkdir_cmd = ':silent !mkdir -p ' - else - " On M$ system, use backslash. Also mkdir syntax is different. - " This should only work on W2K and up. - let l:slash_char = '\' - let l:mkdir_cmd = ':silent !mkdir ' - endif - - let l:doc_path = l:slash_char . 'doc' - "let l:doc_home = l:slash_char . '.vim' . l:slash_char . 'doc' - - " Figure out document path based on full name of this script: - let l:vim_plugin_path = fnamemodify(a:full_name, ':h') - "let l:vim_doc_path = fnamemodify(a:full_name, ':h:h') . l:doc_path - let l:vim_doc_path = matchstr(l:vim_plugin_path, - \ '.\{-}\ze\%(\%(ft\)\=plugin\|macros\)') . l:doc_path - if (!(filewritable(l:vim_doc_path) == 2)) - echomsg "Doc path: " . l:vim_doc_path - execute l:mkdir_cmd . l:vim_doc_path - if (!(filewritable(l:vim_doc_path) == 2)) - " Try a default configuration in user home: - "let l:vim_doc_path = expand("~") . l:doc_home - let l:vim_doc_path = matchstr(&rtp, - \ escape($HOME, '\') .'[/\\]\%(\.vim\|vimfiles\)') - if (!(filewritable(l:vim_doc_path) == 2)) - execute l:mkdir_cmd . l:vim_doc_path - if (!(filewritable(l:vim_doc_path) == 2)) - " Put a warning: - echomsg "Unable to open documentation directory" - echomsg " type :help add-local-help for more informations." - return 0 - endif - endif - endif - endif - - " Exit if we have problem to access the document directory: - if (!isdirectory(l:vim_plugin_path) - \ || !isdirectory(l:vim_doc_path) - \ || filewritable(l:vim_doc_path) != 2) - return 0 - endif - - " Full name of script and documentation file: - let l:script_name = 'xml.vim' - let l:doc_name = 'xml-plugin.txt' - let l:plugin_file = l:vim_plugin_path . l:slash_char . l:script_name - let l:doc_file = l:vim_doc_path . l:slash_char . l:doc_name - - " Bail out if document file is still up to date: - if (filereadable(l:doc_file) && - \ getftime(l:plugin_file) < getftime(l:doc_file)) - return 0 - endif - - " Prepare window position restoring command: - if (strlen(@%)) - let l:go_back = 'b ' . bufnr("%") - else - let l:go_back = 'enew!' - endif - - " Create a new buffer & read in the plugin file (me): - setl nomodeline - exe 'enew!' - exe 'r ' . l:plugin_file - - setl modeline - let l:buf = bufnr("%") - setl noswapfile modifiable - - norm zR - norm gg - - " Delete from first line to a line starts with - " === START_DOC - 1,/^=\{3,}\s\+START_DOC\C/ d - - " Delete from a line starts with - " === END_DOC - " to the end of the documents: - /^=\{3,}\s\+END_DOC\C/,$ d - - " Remove fold marks: - "% s/{\{3}[1-9]/ / - - " Add modeline for help doc: the modeline string is mangled intentionally - " to avoid it be recognized by VIM: - call append(line('$'), '') - call append(line('$'), ' v' . 'im:tw=78:ts=8:fen:fdm=marker:ft=help:norl:') - - " Replace revision: - exe "normal :1,5s/#version#/ v" . a:revision . "/\<CR>" - - " Save the help document: - exe 'w! ' . l:doc_file - exe l:go_back - exe 'bw ' . l:buf - - " Build help tags: - exe 'helptags ' . l:vim_doc_path - - return 1 -endfunction -" }}}2 - -let s:revision= - \ substitute("$Revision: 1.35 $",'\$\S*: \([.0-9]\+\) \$','\1','') -silent! let s:install_status = - \ s:XmlInstallDocumentation(expand('<sfile>:p'), s:revision) -if (s:install_status == 1) - echom expand("<sfile>:t:r") . '-plugin v' . s:revision . - \ ': Help-documentation installed.' -endif - - -" Mappings of keys to functions {{{1 -nnoremap <silent> <buffer> <LocalLeader>5 :call <SID>Matches()<Cr> -vnoremap <silent> <buffer> <LocalLeader>5 <Esc>:call <SID>MatchesVisual()<Cr> -nnoremap <silent> <buffer> <LocalLeader>% :call <SID>Matches()<Cr> -vnoremap <silent> <buffer> <LocalLeader>% <Esc>:call <SID>MatchesVisual()<Cr> -nnoremap <silent> <buffer> <LocalLeader>c :call <SID>Change()<Cr> -nnoremap <silent> <buffer> <LocalLeader>C :call <SID>ChangeWholeTag()<Cr> -nnoremap <silent> <buffer> <LocalLeader>d :call <SID>Delete()<Cr> -nnoremap <silent> <buffer> <LocalLeader>D :call <SID>DeleteSection()<Cr> -nnoremap <silent> <buffer> <LocalLeader>e :call <SID>EndTag()<Cr> -nnoremap <silent> <buffer> <LocalLeader>] :call <SID>DelComment()<Cr> -nnoremap <silent> <buffer> <LocalLeader>} :call <SID>DelCommentSection()<Cr> -nnoremap <silent> <buffer> <LocalLeader>f :call <SID>FoldTag()<Cr> -nnoremap <silent> <buffer> <LocalLeader>F :call <SID>FoldTagAll()<Cr> -nnoremap <silent> <buffer> <LocalLeader>g :call <SID>FormatTag()<Cr> -nnoremap <silent> <buffer> <LocalLeader>G :call <SID>FormatTagAll()<Cr> -nnoremap <silent> <buffer> <LocalLeader>I :call <SID>IndentAll()<Cr> -nnoremap <silent> <buffer> <LocalLeader>j :call <SID>Join()<Cr> -nnoremap <silent> <buffer> <LocalLeader>O :call <SID>BeforeTag()<Cr> -nnoremap <silent> <buffer> <LocalLeader>= :call <SID>CommentTag()<Cr> -nnoremap <silent> <buffer> <LocalLeader>o :call <SID>AfterTag()<Cr> -nnoremap <silent> <buffer> <LocalLeader>s :call <SID>StartTag()<Cr> -nnoremap <silent> <buffer> <LocalLeader>[ :call <SID>DelCData()<Cr> -nnoremap <silent> <buffer> <LocalLeader>{ :call <SID>DelCDataSection()<Cr> -nnoremap <silent> <buffer> <LocalLeader>> :call <SID>ShiftRight()<Cr> -nnoremap <silent> <buffer> <LocalLeader>< :call <SID>ShiftLeft()<Cr> -vnoremap <silent> <buffer> <LocalLeader>l <Esc>:call <SID>vlistitem()<Cr> -vnoremap <silent> <buffer> <LocalLeader>v <Esc>:call <SID>BlockTag(0)<Cr> -vnoremap <silent> <buffer> <LocalLeader>V <Esc>:call <SID>BlockTag(1)<Cr> -vnoremap <silent> <buffer> <LocalLeader>c <Esc>:call <SID>BlockWith('<![CDATA[',']]>')<Cr> -vnoremap <silent> <buffer> <LocalLeader>< <Esc>:call <SID>BlockWith('<!--','-->')<Cr> - -" Move around functions. -noremap <silent><buffer> [[ m':call <SID>findOpenTag("bW")<CR> -noremap <silent><buffer> ]] m':call <SID>findOpenTag( "W")<CR> -noremap <silent><buffer> [] m':call <SID>findCloseTag( "bW")<CR> -noremap <silent><buffer> ][ m':call <SID>findCloseTag( "W")<CR> - -" Move around comments -noremap <silent><buffer> ]" :call search('^\(\s*<!--.*\n\)\@<!\(\s*-->\)', "W")<CR> -noremap <silent><buffer> [" :call search('\%(^\s*<!--.*\n\)\%(^\s*-->\)\@!', "bW")<CR> - - -setlocal iskeyword=@,48-57,_,192-255,58 -exe 'inoremap <silent> <buffer> '.b:suffix. " ><Esc>db:call <SID>makeElement()<Cr>" -if !exists("g:xml_tag_completion_map") - inoremap <silent> <buffer> > ><Esc>:call <SID>CloseTagFun()<Cr> -else - execute "inoremap <silent> <buffer> " . g:xml_tag_completion_map . " ><Esc>:call <SID>CloseTagFun()<Cr>" -endif - - - -finish - -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""/*}}}*/ -" Section: Documentation content {{{1 -"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -=== START_DOC -*xml-plugin.txt* Help edit XML and SGML documents. #version# - - XML Edit ~ - -A filetype plugin to help edit XML and SGML documents. - -This script provides some convenience when editing XML (and some SGML -including HTML) formated documents. It allows you to jump to the -beginning or end of the tag block your cursor is in. '%' will jump -between '<' and '>' within the tag your cursor is in. When in insert -mode and you finish a tag (pressing '>') the tag will be completed. If -you press '>' twice it will place the cursor in the middle of the tags -on it's own line (helps with nested tags). - -Usage: Place this file into your ftplugin directory. To add html support -Sym-link or copy this file to html.vim in your ftplugin directory. To activte -the script place 'filetype plugin on' in your |.vimrc| file. See |ftplugins| -for more information on this topic. - -If the file edited is of type "html" and "xml_use_html" is defined then -the following tags will not auto complete: <img>, <input>, <param>, -<frame>, <br>, <hr>, <meta>, <link>, <base>, <area> - -If the file edited is of type 'html' and 'xml_use_xhtml' is defined the -above tags will autocomplete the xml closing staying xhtml compatable. -ex. <hr> becomes <hr /> (see |xml-plugin-settings|) - -Known Bugs {{{1 ~ - -- < & > marks inside of a CDATA section are interpreted as actual XML tags - even if unmatched. -- The script can not handle leading spaces such as < tag></ tag> it is - illegal XML syntax and considered very bad form. -- Placing a literal `>' in an attribute value will auto complete despite that - the start tag isn't finished. This is poor XML anyway you should use - > instead. - - ------------------------------------------------------------------------------- - *xml-plugin-settings* -Options {{{1 - -(All options must be placed in your |.vimrc| prior to the |ftplugin| -command.) - -xml_tag_completion_map - Use this setting to change the default mapping to auto complete a - tag. By default typing a literal `>' will cause the tag your editing - to auto complete; pressing twice will auto nest the tag. By using - this setting the `>' will be a literal `>' and you must use the new - mapping to perform auto completion and auto nesting. For example if - you wanted Control-L to perform auto completion inmstead of typing a - `>' place the following into your .vimrc: > - let xml_tag_completion_map = "<C-l>" -< -xml_no_auto_nesting (Not Working!!!!!) - This turns off the auto nesting feature. After a completion is made - and another `>' is typed xml-edit automatically will break the tag - accross multiple lines and indent the curser to make creating nested - tqags easier. This feature turns it off. Enter the following in your - .vimrc: > - let xml_no_auto_nesting = 1 -< -xml_use_xhtml - When editing HTML this will auto close the short tags to make valid - XML like <hr/> and <br/>. Enter the following in your vimrc to - turn this option on: > - let xml_use_xhtml = 1 - if the filetype is xhtml and g:xml_use_xhtml doesn't exists - the script defines it to be 1. (This also assumes that you have linked - xml.vim to xhtml.vim. Otherwise this item is moot) - For a file to be of xhtml type there need to be a doctype declaration!! - just naming a file something.xhtml doesn't make it type xhtml! -< -xml_no_html - This turns of the support for HTML specific tags. Place this in your - .vimrc: > - let xml_no_html = 1 -< ------------------------------------------------------------------------------- - *xml-plugin-mappings* - -Mapings and their functions {{{1 - -Typing '>' will start the tag closing routine. -Typing (Where | means cursor position) - <para>| -results in - <para>|</para> - -Typing - <para>>|</para> -results in - <para> - | - </para> -typing a lone '>' and no '<' in front of it accepts the '>' (But having -lone '>' or '<' in a XML file is frown upon except in <!CDATA> sections, -and that will throw of the plugin!!). - -Typing </tag> or <tag/> also results in na expanding. So when editing -html type <input .... /> - -The closing routing also ignores DTD tags '<!,,>' and processing -instructions '<?....?>'. Thus typing these result in no expansion. - - -<LocalLeader> is a setting in VIM that depicts a prefix for scripts and -plugins to use. By default this is the backslash key `\'. See |mapleader| -for details. - -;; make element out previous word and close it {{{2 - - when typing a word;; wil create <word>|</word> - when word on its own line it will be - <word> - | - </word> - the suffix can be changed by setting - let makeElementSuf = ',,,' in your .vimrc - Thanks to Bart van Deenen - (http://www.vim.org/scripts/script.php?script_id=632) - -[ and ] mappings {{{2 - <LocalLeader>[ Delete <![CDATA[ ]]> delimiters - <LocalLeader>{ Delete <![CDATA[ ]]> section - <LocalLeader>] Delete <!-- --> delimiters - <LocalLeader>} Delete <!-- --> section - [[ Goto to the previous open tag - [[ Goto to the next open tag - [] Goto to the previous close tag - ][ Goto to the next close tag - [" Goto to the next comment - ]" Goto the previous comment -<LocalLeader>5 Jump to the matching tag. {{{2 -<LocalLeader>% Jump to the matching tag. - - -<LocalLeader>c Rename tag {{{2 - -<LocalLeader>C Rename tag and remove attributes {{{2 - Will ask for attributes - -<LocalLeader>d Deletes the surrounding tags from the cursor. {{{2 - <tag1>outter <tag2>inner text</tag2> text</tag1> - | - Turns to: - outter <tag2>inner text</tag2> text - | - -<LocalLeader>D Deletes the tag and it contents {{{2 - - and put it in register x. - <tag1>outter <tag2>inner text</tag2> text</tag1> - | - Turns to: - <tag1>outter text</tag1> - -<LocalLeader>e provide endtag for open tags. {{{2 - - provide endtag for open tags. Watch where de cursor is - <para><listitem>list item content - | - pressing \e twice produces - <para><listitem>list item content</para></listitem> - -<LocalLeader>f fold the tag under the cursor {{{2 - <para> - line 1 - line 2 - line 3 - </para> - \f produces - +-- 5 lines: <para>-------------------------- - - -<LocalLeader>F all tags of name 'tag' will be fold. {{{2 - - If there isn't a tag under - the cursor you will be asked for one. - -<LocalLeader>g Format (Vim's gq function) {{{2 - - will make a visual block of tag under cursor and then format using gq - - -<LocalLeader>G Format all tags under cursor (Vim's gq function) {{{2 - - If there isn't a tag under - the cursor you will be asked for one. - - -<LocalLeader>I Indent all tags {{{2 - - will create a multiline layout every opening tag will be shifted out - and every closing tag will be shifted in. Be aware that the rendering - of the XML through XSLT and/or DSSSL, might be changed by this. - Be aware tha if the file is big, more than 1000 lines, the reformatting - takes a long time because vim has to make a big undo buffer. - For example using \I on the example below: - - <chapter><title>Indent</title><para>The documentation</para></chapter> - - - Becomes - - <chapter> - <title> - Indent - </title> - <para> - The documentation - </para> - </chapter> - - -<LocalLeader>j Joins two the SAME sections together. {{{2 - - The sections must be next to each other. - <para> This is line 1 - of a paragraph. </para> - <para> This is line 2 - | - of a paragraph. </para> - \j produces - <para> This is line 1 - of a paragraph. - This is line 2 - of a paragraph. </para> - -<LocalLeader>l visual surround the block with listitem and para {{{2 - When marking up docbook tekst you have the issue that listitems - consist of 2 item. This key combination inserts them both, - - blaah - | - \l produces - <listitem> - <para>blaah</para> - </listitem> - -<LocalLeader>o Insert a tag inside the current one (like vim o) {{{2 - You are asked for tag and attributes. - - <tag1><tag2><tag3>blaah</tag3></tag2></tag1> - | - \o produces - <tag1> - <aftertag><tag2><tag3>blaah</tag3></tag2></aftertag> - </tag1> - -<LocalLeader>O Insert a tag outside the current one (like vim O) {{{2 - You are asked for tag and attributes. - <tag1><tag2><tag3>blaah</tag3></tag2></tag1> - | - \O produces - <beforetag> - <tag1><tag2><tag3>blaah</tag3></tag2></tag1> - </beforetag> - -<LocalLeader>s Insert an opening tag for an closing tag. {{{2 - list item content</para></listitem> - | - pressing \s twice produces - <para><listitem>list item content</para></listitem> - -<LocalLeader>[ Delete <![CDATA[ ]]> delimiters {{{2 - Removes Only <CDATA[ and ]]> - handy when you want to uncomment a section. - You need to stand in the tag and not on an other tag - <![CDATA[ <tag> ]]> - if you cursor is outside <tag> but inside the - CDATA tag the delition works. -<LocalLeader>{ Delete <![CDATA[ ]]> section {{{2 - Removes everything tag and Content -<LocalLeader>] Delete <!-- --> delimiters {{{2 - Uncommnet a block. -<LocalLeader>} Delete <!-- --> section {{{2 - Removes everything tag and Content -<LocalLeader>> shift right opening tag and closing tag. {{{2 - shift everything between the tags 1 shiftwide right -<LocalLeader>< shift left opening tag and closing tag. {{{2 - shift everything between the tags 1 shiftwide left -<LocalLeader>c Visual Place a CDATA section around the selected text. {{{2 - Place Cdata section around the block -<LocalLeader>< Visual Place a Comment around the selected text. {{{2 - Place comment around the block -<LocalLeader>5 Extend the visual selection to the matching tag. {{{2 -<LocalLeader>% - Extend the visual selection to the matching tag. Make sure you are at - the start of the opening tag or the end of the closing tag. -<LocalLeader>v Visual Place a tag around the selected text. {{{2 - - You are asked for tag and attributes. You - need to have selected text in visual mode before you can use this - mapping. See |visual-mode| for details. - Be careful where you place the marks. - The top uses append - The bottom uses append - Useful when marking up a text file - ------------------------------------------------------------------------------- - *xml-plugin-callbacks* - ------------------------------------------------------------------------------- - *xml-plugin-callbacks* - -Callback Functions {{{2 ~ - -A callback function is a function used to customize features on a per tag -basis. For example say you wish to have a default set of attributs when you -type an empty tag like this: - You type: <tag> - You get: <tag default="attributes"></tag> - -This is for any script programmers who wish to add xml-plugin support to -there own filetype plugins. - -Callback functions recive one attribute variable which is the tag name. The -all must return either a string or the number zero. If it returns a string -the plugin will place the string in the proper location. If it is a zero the -plugin will ignore and continue as if no callback existed. - -The following are implemented callback functions: - -HtmlAttribCallback - This is used to add default attributes to html tag. It is intended - for HTML files only. - -XmlAttribCallback - This is a generic callback for xml tags intended to add attributes. - - *xml-plugin-html* -Callback Example {{{2 ~ - -The following is an example of using XmlAttribCallback in your .vimrc -> - function XmlAttribCallback (xml_tag) - if a:xml_tag ==? "my-xml-tag" - return "attributes=\"my xml attributes\"" - else - return 0 - endif - endfunction -< -The following is a sample html.vim file type plugin you could use: -> - " Vim script file vim600:fdm=marker: - " FileType: HTML - " Maintainer: Devin Weaver <vim (at) tritarget.com> - " Location: http://www.vim.org/scripts/script.php?script_id=301 - - " This is a wrapper script to add extra html support to xml documents. - " Original script can be seen in xml-plugin documentation. - - " Only do this when not done yet for this buffer - if exists("b:did_ftplugin") - finish - endif - " Don't set 'b:did_ftplugin = 1' because that is xml.vim's responsability. - - let b:html_mode = 1 - - if !exists("*HtmlAttribCallback") - function HtmlAttribCallback( xml_tag ) - if a:xml_tag ==? "table" - return "cellpadding=\"0\" cellspacing=\"0\" border=\"0\"" - elseif a:xml_tag ==? "link" - return "href=\"/site.css\" rel=\"StyleSheet\" type=\"text/css\"" - elseif a:xml_tag ==? "body" - return "bgcolor=\"white\"" - elseif a:xml_tag ==? "frame" - return "name=\"NAME\" src=\"/\" scrolling=\"auto\" noresize" - elseif a:xml_tag ==? "frameset" - return "rows=\"0,*\" cols=\"*,0\" border=\"0\"" - elseif a:xml_tag ==? "img" - return "src=\"\" width=\"0\" height=\"0\" border=\"0\" alt=\"\"" - elseif a:xml_tag ==? "a" - if has("browse") - " Look up a file to fill the href. Used in local relative file - " links. typeing your own href before closing the tag with `>' - " will override this. - let cwd = getcwd() - let cwd = substitute (cwd, "\\", "/", "g") - let href = browse (0, "Link to href...", getcwd(), "") - let href = substitute (href, cwd . "/", "", "") - let href = substitute (href, " ", "%20", "g") - else - let href = "" - endif - return "href=\"" . href . "\"" - else - return 0 - endif - endfunction - endif - - " On to loading xml.vim - runtime ftplugin/xml.vim -< -=== END_DOC -"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" v im:tw=78:ts=8:ft=help:norl: -" vim600: set foldmethod=marker tabstop=8 shiftwidth=2 softtabstop=2 smartindent smarttab : -"fileencoding=iso-8859-15 -=== END_DOC -"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" - - - - - - -" Vim settingѕ {{{1 -" vim:tw=78:ts=2:ft=help:norl: -" vim: set foldmethod=marker tabstop=2 shiftwidth=2 softtabstop=2 smartindent smarttab : -"fileencoding=utf-8 - +xml.vim
\ No newline at end of file diff --git a/files/.vim/snippets/xml.snippets b/files/.vim/snippets/xml.snippets index 3b202cf..1032f5a 100755 --- a/files/.vim/snippets/xml.snippets +++ b/files/.vim/snippets/xml.snippets @@ -1,2 +1,2 @@ snippet xml - <?xml version="1.0" encoding="${1:UTF-8}"?>${2} + <?xml version="${1:1.0}" encoding="${2:utf-8}"?>${3} diff --git a/files/.vim/snippets/xslt.snippets b/files/.vim/snippets/xslt.snippets new file mode 100644 index 0000000..977782d --- /dev/null +++ b/files/.vim/snippets/xslt.snippets @@ -0,0 +1,6 @@ +snippet template: + <xsl:template match="${1}"> + ${2} + </xsl:template> +snippet valueof: + <xsl:value-of select="${1}"/> |
