" Vimball Archiver by Charles E. Campbell, Jr., Ph.D. UseVimball finish ftplugin/c/drcstubs.vim [[[1 337 " drcstubs.vim: Dr Chip's C Stubs (a plugin) " isk is set to include # so as not to break #if " " Author: Charles E. Campbell, Jr. (PhD) " Date: Nov 21, 2007 " Version: 3c ASTRO-ONLY " " --------------------------------------------------------------------- " Usage: (requires 6.0 or later) {{{1 " " These maps all work during insert mode while editing a C " or C++ program. Use either the shorthand or longhand maps " below, and the associated construct will be expanded to " include parentheses, curly braces, and the cursor will be " moved to a convenient location, still in insert mode, for " further editing. " " Shorthand Longhand " Map Map " --------- -------- " i` if` " e` els[e]` " ei` eli[f]` " f` for` " w` wh[ile]` " s` sw[itch]` " c` ca[se]` " d` defa[ult]` " do` " in[clude]` yields #include " de[fine]` yields #define " E` Ed[bg]` (see http://mysite.verizon.net/astronaut/dbg) " R` Rd[bg]` (see http://mysite.verizon.net/astronaut/dbg) " D` Dp[rintf]` (see http://mysite.verizon.net/astronaut/dbg) " #` #ifdef ... #endif " ?` ? "" : "null " " " Caveat: these maps will not work if "set paste" is on " " --------------------------------------------------------------------- " Installation: {{{2 " " This copy of DrC's C-Stubs is filetype plugin for vim 6.0: put it in " ${HOME}/.vim/ftplugin/c/ -and- ${HOME}/.vim/ftplugin/cpp/ " (or make suitable links) and put "filetype plugin on" in your <.vimrc>. " " "For I am convinced that neither death nor life, neither angels nor demons, " neither the present nor the future, nor any powers, nor height nor depth, " nor anything else in all creation, will be able to separate us from the " love of God that is in Christ Jesus our Lord." Rom 8:38 " ======================================================================= " Load Once: {{{1 if exists("b:loaded_drcstubs") finish endif let b:loaded_drcstubs= "v3c" let b:undo_ftplugin ="let &isk=@,48-57,_" " --------------------------------------------------------------------- " Special Syntax: {{{1 syn keyword cTodo COMBAK syn match cTodo "^[- ]*COMBAK[- ]*$" setlocal isk+=# setlocal isk-=: "DechoTabOn " ===================================================================== " Public Interface: {{{1 " backquote calls DrChipCStubs function if !hasmapto('UseDrCStubs') imap ` UseDrCStubs endif inoremap UseDrCStubs :call DrChipCStubs()a " provide help for drcstubs com! Drcstubs call s:CMapHlp() if has("gui") && has("gui_running") && !exists("s:did_drcstubs_menu") let s:did_drcstubs_menu= 1 menu DrChip.DrCStubs.Help :Drcstubs imenu DrChip.DrCStubs.if if` imenu DrChip.DrCStubs.else e` imenu DrChip.DrCStubs.elseif ei` imenu DrChip.DrCStubs.for f` imenu DrChip.DrCStubs.while w` imenu DrChip.DrCStubs.switch s` imenu DrChip.DrCStubs.case c` imenu DrChip.DrCStubs.default d` imenu DrChip.DrCStubs.do do` imenu DrChip.DrCStubs.include in` imenu DrChip.DrCStubs.define de` imenu DrChip.DrCStubs.Edbg E` imenu DrChip.DrCStubs.Rdbg R` imenu DrChip.DrCStubs.Dprintf D` imenu DrChip.DrCStubs.ifdef #` imenu DrChip.DrCStubs.?\.\. ?` endif " ===================================================================== " Functions: {{{1 " --------------------------------------------------------------------- " DrChipCStubs: this function changes the backquote into {{{2 " text based on what the preceding word was fun! s:DrChipCStubs() " call Dfunc("DrChipCStubs()") let vekeep= &ve set ve= let wrd= expand("") let chr= substitute(getline("."),'^.*\%'.col('.').'c\(.\).*$','\1','') if strlen(chr) > 1 let chr = substitute(wrd,'^.*\(.\)$','\1','') endif let inline= (virtcol("$") - virtcol(".")) > 1 " call Decho("wrd<".wrd."> chr<".chr."> inline=".inline) if chr =~ '?' " call Decho('chr=~?') if inline exe 'norm! xi? "" : "null ",' else exe 'norm! xa? "" : "null ",' endif elseif wrd =~ '\' " call Decho('\}\k$F(" ino f{:iun o elseif wrd =~ '\' " call Decho('\}\k$F(" ino f{:iun o elseif wrd =~ '\' exe "norm! bdWaelse {\}\O \\" " call Decho('\' exe "norm! xaelse {\}\O \\" " call Decho('\' exe "norm! bdWaelse if() {\}\k$F(" ino f{:iun o " call Decho('\' exe "norm! bdWaelse if() {\}\k$F(" ino f{:iun o " call Decho('\' exe "norm! bdWafor(;;) {\}\k$F(" ino :call DrCCFor(1)0f;a " call Decho('\' exe "norm! xafor(;;) {\}\k$F(" ino :call DrCCFor(1)0f;a " call Decho('\') elseif wrd =~ 'wh\%[ile]\>' exe "norm! bdWawhile() {\}\k$F(" ino f{:iun o " call Decho('\' exe "norm! xawhile() {\}\k$F(" ino f{:iun o " call Decho('\') elseif wrd =~ 'sw\%[itch]\>' exe "norm! bdWaswitch() {\}\k$F(" ino f{:iun o " call Decho('\' exe "norm! xaswitch() {\}\k$F(" ino f{:iun o " call Decho('\' exe "norm! bdWacase 1:\break;\khf:hxh" ino $a/* %%% */:s/case \zs\(.*:\)\s*\/\* %%%/\1 \/* \1/:iun o " call Decho('\' exe "norm! xacase 1:\break;\khf:hxh" ino $a/* %%% */:s/case \zs\(.*:\)\s*\/\* %%%/\1 \/* \1/:iun o " call Decho('\' exe "norm! bdWadefault:\break;\O \\" " call Decho('\' exe "norm! xadefault:\break;\O \\" " call Decho('\') elseif wrd =~ '\' exe "norm! bdWado {\} while();\O \$" ino :iun ?\f{%f(a " call Decho('\' exe "norm! bdWaEdbg((\"\ma[[?)\%BdwP`apa()\"));\F(" ino :iun /"));$li " call Decho('\' exe "norm! xaEdbg((\"\ma[[?)\%BdwP`apa()\"));\F(" ino :iun /"));$li " call Decho('\' exe "norm! bdWaRdbg((\"\ma[[?)\%BdwP`apa\"));\F\"h" ino :iun /"));$l " call Decho('\' exe "norm! xaRdbg((\"\ma[[?)\%BdwP`apa\"));\F\"h" ino :iun /"));$l " call Decho('\' exe "norm! bdWaDprintf((1,\"\"));\4h" ino :iun /"));$l " call Decho('\' exe "norm! xaDprintf((1,\"\"));\4h" ino :iun /"));$l " call Decho('\' exe "norm! bdW0i#include \" " call Decho('\' exe "norm! bdW0i#define \" " call Decho('\#endif\kA" " call Decho('#') else exe "norm! a`\" endif let &ve= vekeep " call Dret("DrChipCStubs") endfun " --------------------------------------------------------------------- " DrCCFor: {{{2 fun! s:DrCCFor(cnt) if a:cnt == 1 ino :call DrCCFor(2)0f;;a elseif a:cnt == 2 ino :iun o else endif endfun " --------------------------------------------------------------------- " CMapHlp: sets up a special window holding a list of my C-related {{{2 " maps, imaps, etc fun! s:CMapHlp() " call Dfunc("CMapHlp()") " create DrC's C Stubs window if !exists("s:c_helpbuf") || !bufexists(s:c_helpbuf) let isfkeep= &isfname set isfname-=[ set isfname-=] exe "bo sp ".escape("[DrC's C Stubs]"," '[]") set buftype=nofile set bufhidden=wipe set noswapfile set noro let &isfname = isfkeep let s:c_helpbuf = bufnr("%") endif put ='_ Imaps_' put ='_Longhand Shorthand Expands To_' put =' -------- --------- ----------' put =' if i if(X) {\|Y\|}' put =' els[e] e else {\|X\|}' put =' eli[f] ei else if(X) {\|Y\|}' put =' fo[r] f for(X;Y;Z) {\|W\|}' put =' wh[ile] w while(X) {\|Y\|}' put =' sw[itch] s switch(X) {\|Y\|}' put =' ca[se] c case X:\|Y\|break;' put =' defa[ult] d default:\|Y\|break;' put =' do do {\|X\|} while(Y);' put =' Ed[bg] E Edbg((\"func(X)\",Y));' put =' Rd[bg] R Rdbg((\"func X\",Y));' put =' Dp[rintf] D Dprintf((1,\"X\",Y));' put =' in[clude] #include X' put =' de[fine] #define X' put =' # #ifdef X ... #endif' put =' ' put =' \|=carriage return X,Y,Z,W=successive cursor placements' " syntax highlighting syn match CmapBar '---\+' syn match CmapInfo '([^)]\+)' contains=CmapParen syn match CmapTitle '^.*{{{\d$' contains=CmapIgnore syn match CmapTitle '_.\{-}_' contains=CmapIgnore syn match CmapIgnore '{{{\d' contained syn match CmapIgnore '_' contained syn match CmapParen '[{}()]' contained syn match CmapExpansion '\t .*$' contains=CmapKeys,CmapParen,CmapCursor,CmapNewline syn match CmapCursor '\<[XYZW]\>' contained syn match CmapNewline '|' contained syn case match syn keyword CmapKeys contained if else for while switch case default do Edbg Rdbg Dprintf #include #define #ifdef #endif DDmatout DDvecout DCmatout DCvecout if !exists("b:did_drcstubs_help") command -nargs=+ HiLink hi def link HiLink CmapBar Delimiter HiLink CmapIgnore Ignore HiLink CmapInfo String HiLink CmapNewline Delimiter HiLink CmapParen Delimiter HiLink CmapTitle Statement HiLink CmapKeys Statement HiLink CmapCursor Special let b:did_drcstubs_help= 1 delc HiLink endif norm! 1Gdd setlocal ro setlocal fdm=marker norm! zM " call Dret("CMapHlp") endfun " ===================================================================== " Modelines: {{{1 " vim: fdm=marker ftplugin/sh/drcstubs.vim [[[1 256 " drcstubs.vim: Dr Chip's Sh Stubs (a plugin) " " Author: Charles E. Campbell, Jr. (PhD) " Date: Nov 04, 2009 " Version: 3b ASTRO-ONLY " " Usage: (requires 6.0 or later) " " These maps all work during insert mode while editing vim " scripts. Use either the shorthand or longhand maps " below, and the associated construct will be expanded to " include parentheses, curly braces, and the cursor will be " moved to a convenient location, still in insert mode, for " further editing. " " Shorthand Longhand " Map Map " --------- -------- " c` c[ase]` " i` if` " e` els[e]` " ei` eli[f]` " fo` for` " fu` fu[nction]` " w` wh[ile]` " " Caveat: these maps will not work if "set paste" is on " " After a line with [[...]], a line matching "^\s*($" " (ie. enter a "(" on an otherwise blank line) " will toggle between "[[..]]" and "((...))" on the line above. " Furthermore, a \( on such a line will become simply a "(", " so one can still enter a line beginning with an open parenthesis. " " Installation: " " This copy of DrC's Sh-Stubs is a ftplugin for vim 6.0: put it in " ${HOME}/.vim/ftplugin/sh/ " (or make suitable links) and have "filetype plugin on" in your <.vimrc>. " " "Blessed is the man who endures temptation, for when he has " been approved, he will receive the crown of life, which the Lord " promised to those who love him." James 1:12 " " ======================================================================= " Load Once: {{{1 if exists("b:loaded_drcstubs") finish endif let b:loaded_drcstubs= "v3b" " --------------------------------------------------------------------- " Special Syntax: {{{1 syn keyword vimTodo COMBAK syn match vimTodo "^[- ]*COMBAK[- ]*$" " --------------------------------------------------------------------- " Public Interface: {{{1 " backquote calls DrChipShStubs function if !hasmapto('UseDrCStubs') imap ` UseDrCShStubs endif inoremap UseDrCShStubs :call DrCShStubs()a inoremap ( (:call DrCShParenChk() " provide help for drcstubs com! Drcstubs call s:ShMapHlp() " --------------------------------------------------------------------- " DrCShStubs: this function changes the backquote into {{{1 " text based on what the preceding word was fun! DrCShStubs() let vekeep= &ve set ve= let wrd=expand("") if wrd =~ '\esac\k$FXxh" ino :iun o elseif wrd =~ '\' exe "norm! xacase X in\esac\k$FXxh" ino :iun o elseif wrd =~ '\' exe "norm! bdWafor X in ; do\done\k$FXxh" " ino :iun 0f;hha ino :call DrCShFor()0f;hha elseif wrd =~ '\' exe "norm! xafor X in ; do\done\k$FXxh" ino :call DrCShFor()0f;hha elseif wrd =~ '\' exe "norm! bdWaif [[ X ]]; then\fi\k$FXxh" ino :iun o elseif wrd =~ '\' exe "norm! xaif [[ X ]]; then\fi\k$FXxh" ino :iun o elseif wrd =~ '\' exe "norm! bdWaelse\ \hx" elseif wrd =~ '\' exe "norm! xaelse\ \hx" elseif wrd =~ '\' exe "norm! bdWaelif [[ X ]]; then\$FXxh" ino :iun o elseif wrd =~ '\' exe "norm! bdWaelif [[ X ]]; then\$FXxh" ino :iun o elseif wrd =~ '\' exe "norm! bdWafunction X\{\}\kk0fXxa" ino 0j:iun o elseif wrd =~ '\' exe "norm! bdWawhile [[ X ]]; do\done\k$FXxh" ino 0:iun o elseif wrd =~ '\' exe "norm! xawhile [[ X ]]; do\done\k$FXxh" ino 0:iun o else exe "norm! a`\" endif let &ve= vekeep endfun " --------------------------------------------------------------------- " DrCShParenChk: fun! s:DrCShParenChk() let curline= line(".") let prvline= curline - 1 if getline(curline) =~ '^\s*($' && getline(prvline) =~ '\[\[.\{-}]]' exe prvline.'s/\[\[/((/e' exe prvline.'s/]]/))/e' norm! j$xa elseif getline(curline) =~ '^\s*($' && getline(prvline) =~ '((.\{-}))' exe prvline.'s/((/[[/e' exe prvline.'s/))/]]/e' norm! j$xa elseif getline(curline) =~ '^\s*\\($' norm! hhxl endif endfun " --------------------------------------------------------------------- " DrCShFor: {{{2 fun! s:DrCShFor() ino :iun o endfun " --------------------------------------------------------------------- " ShMapHlp: sets up a special window holding a list of my Sh-related {{{1 " maps, imaps, etc fun! s:ShMapHlp() " call Dfunc("ShMapHlp()") " create DrC's Sh Stubs window if !exists("s:sh_helpbuf") || !bufexists(s:sh_helpbuf) let isfkeep= &isfname set isfname-=[ set isfname-=] exe "bo sp ".escape("[DrC's Sh Stubs]"," '[]") set buftype=nofile set bufhidden=wipe set noswapfile set noro let &isfname = isfkeep let s:sh_helpbuf = bufnr("%") endif put ='_ Imaps_' put ='_Longhand Shorthand Expands To_' put =' -------- --------- ----------' put =' ca[se]` c` case X in\|Y\|esac' put =' fo[r]` f` for X in Y ; do\|Z\|done' put =' if` i` if [[ X ]]; then\|Y\|fi' put =' eli[f]` ei` elif [[ X ]]; then\|Y' put =' els[e]` e` else\|X' put =' fu[nction]` function X\|{\|Y\|}' put =' wh[ile]` w` while [[ X ]]; do\|Y\|done' put =' ' put =' \|=carriage return X,Y,Z=successive cursor placements' " syntax highlighting syn match SHmapBar '---\+' syn match SHmapInfo '([^)]\+)' contains=SHmapParen syn match SHmapTitle '^.*{{{\d$' contains=SHmapIgnore syn match SHmapTitle '_.\{-}_' contains=SHmapIgnore syn match SHmapIgnore '{{{\d' contained syn match SHmapIgnore '_' contained syn match SHmapParen '[()]' contained syn match SHmapExpansion '\t .*$' contains=SHmapKeys,SHmapParen,SHmapCursor,SHmapNewline syn match SHmapCursor '\<[XYZ]\>' contained syn match SHmapNewline '|' contained syn case match syn keyword SHmapKeys contained case esac do done for if in then else elif function fi while if !exists("b:did_drcstubs_help") command -nargs=+ HiLink hi def link HiLink SHmapBar Delimiter HiLink SHmapIgnore Ignore HiLink SHmapInfo String HiLink SHmapNewline Delimiter HiLink SHmapParen Delimiter HiLink SHmapTitle Statement HiLink SHmapKeys Statement HiLink SHmapCursor Special let b:did_drcstubs_help= 1 delc HiLink endif norm! 1Gdd setlocal ro setlocal fdm=marker norm! zM " call Dret("ShMapHlp") endfun " --------------------------------------------------------------------- " s:ShMenuToggle: toggle display of menu augroup DrcShStubsEvents au! au BufEnter * call s:ShMenuToggle(1) au BufLeave * call s:ShMenuToggle(0) augroup END fun! s:ShMenuToggle(menustate) if &ft == "sh" && has("gui") && has("gui_running") && has("menu") " call Dfunc("s:ShMenuToggle(menustate=".a:menustate.") ft<".&ft.">") if a:menustate imenu DrChip.ShStubs.Caseca` ca` imenu DrChip.ShStubs.Forfo` fo` imenu DrChip.ShStubs.Ifif` if` imenu DrChip.ShStubs.Elseels` els` imenu DrChip.ShStubs.ElseIfeli` eli` imenu DrChip.ShStubs.Functionfun` fun` imenu DrChip.ShStubs.Whilewh` wh` else silent! iunmenu DrChip.ShStubs.Case silent! iunmenu DrChip.ShStubs.For silent! iunmenu DrChip.ShStubs.If silent! iunmenu DrChip.ShStubs.Else silent! iunmenu DrChip.ShStubs.ElseIf silent! iunmenu DrChip.ShStubs.Function silent! iunmenu DrChip.ShStubs.While endif " call Dret("s:ShMenuToggle") endif endfun " --------------------------------------------------------------------- " vim: fdm=marker ftplugin/tex/drcstubs.vim [[[1 493 " drcstubs.vim: " Author: Charles E. Campbell, Jr. (Ph.D.) " Date: Jan 16, 2009 " Version: 3c ASTRO-ONLY " " Usage: {{{1 " Double-quotes automatically converted to ``...'' " Construct expanded upon use of backquote " ie. enum` -> " \begin{enumerate} " \item " \end{enumerate} " " Both of these kinds of expansions are taken " during insert mode. " " This script is designed to work with " .vim/indent/tex.vim indentation-control script. " " Environments And Abbreviations: {{{1 " Short Form Long Form " arr` array` " ctr` center` " desc` description` " enum` enumerate` " eps` epsf` (for insertion of an eps figure) " eqn` equation` " eqna` eqnarray` " eqns` " i` (creates a \item) " item` itemize` " mat` matrix` " mini` minipage` " sli` " tab` tabular` " fig` figure` " frac` " v` \verb`` " verb` verbatim` " " Script Style Support: {{{1 " bf` \textbf{} " it` \textit{} " rm` \textrm{} " sc` \textsc{} " sf` \textsf{} " sl` \textsl{} " tt` \texttt{} " mtt` \mathtt{} " mrm` \mathrm{} " mbf` \mathbf{} " msf` \mathsf{} " mtt` \mathtt{} " mit` \mathit{} " mcal` \mathcal{} " " Greek Letters: {{{1 " Short-Form Stands-for Short-Form Stands-for " ---------- ------------- ---------- ---------- " a` \alpha v \nu " b` \beta f \xi " g` \gamma p \pi " d` \delta vp \varpi " e` \epsilon r \rho " ve` \varepsilon vr \varrho " z` \zeta s \sigma " n` \eta v \varsigma " t` \theta t \tau " vt` \vartheta u \upsilon " io` \iota h \phi " k` \kappa vh \varphi " l` \lambda x \chi " m` \mu q \psi " w` \omega " " If none of the above abbreviations immediately precedes the backquote, " then the backquote will be inserted as is. " --------------------------------------------------------------------- " Load Once: {{{1 if exists("b:loaded_drcstubs") finish endif let b:loaded_drcstubs= "v3c" " --------------------------------------------------------------------- " LaTeX settings: {{{1 ino \< \verb`<` ino \> \verb`>` ino \~ \verb`~` " --------------------------------------------------------------------- " Comment jumping: (based on idea from Michael Geddes) {{{1 " ]% : jump to beginning of next comment block " [% : jump to ending of previous comment block noremap ]% :call search('^\(\s*%.*\n\)\@ noremap [% :call search('\%(^\s*%.*\n\)\%(^\s*%\)\@!','bW') " --------------------------------------------------------------------- " Provides support for [i and [d : {{{1 setlocal include=\\\\input setlocal define=\\(def\\\\|let\\) setlocal et " --------------------------------------------------------------------- " DrCTexStubs and Quote insertion-maps: {{{1 ino ` :call DrCTexStubs()a ino " =TexQuotes() " --------------------------------------------------------------------- " DrCTexStubs Function: {{{1 fun! DrCTexStubs() "{{{2 " call Dfunc("DrCTexStubs()") exe "norm! a \h" let wrd = expand("") let vekeep = &ve set ve= " set up init: {{{2 let init= (col(".") >= col("$")-1)? "diwA" : "diwi" " set up lblline: look for "\ref{...}" in preceding 10 lines {{{2 let curline = line(".") call SaveWinPosn() let lblline = search('\\ref{',"bW") if lblline != 0 && lblline > curline-10 let lblline= substitute(getline("."),'^.*ref{\([-a-zA-Z:][-a-zA-Z0-9]*\)}.*$','\1','e') if search('\\label{'.lblline.'}','bw') " if \label{lblline} is already in document, then don't repeat it let lblline= "" endif else let lblline= "" endif call RestoreWinPosn() " call Decho("lblline<".lblline.">") " align` if wrd =~ '\\\end{align}\kox\x" else exe "silent! norm! ".init."\\begin{align}\\label{".lblline."}\\\end{align}\kox\x" endif " arr` elseif wrd =~ '\\\left[\\begin{array}{ccc}\\\end{array}\\right]\0wi \YP0wDA " "cases` elseif wrd =~ '\LEFT&\\text{RIGHT}\\\end{cases}\kFLh\" " cen` elseif wrd =~ '\\\end{center}\ko\" " des` elseif wrd =~ '\\\end{description}\ko\\item[] \ba\" ino 0f]l:iun a " enum` elseif wrd =~ '\\\end{enumerate}\ko\\item \" " epsf` elseif wrd =~ 'epsf\=' " {{{2 if lblline == "" exe "silent! norm! bcw\\begin{figure}[H]\\centering\\framebox{\\epsfbox{X.eps}}\\end{figure}\FXcw\" else exe "silent! norm! bcw\\begin{figure}[H]\\label{".lblline."}\\centering\\framebox{\\epsfbox{X.eps}}\\end{figure}\FXcw\" endif " eqna` elseif wrd =~ 'eqna\%[rray]' " {{{2 if lblline == "" exe "silent! norm! ".init."\\begin{eqnarray}\\\end{eqnarray}\ko & = & \\\\\0f&hh" else exe "silent! norm! ".init."\\begin{eqnarray}\\label{".lblline."}\\\end{eqnarray}\ko & = & \\\\\0f&hh" endif ino 02f&l:iun a " eq` elseif wrd =~ 'eq\%[uation]' || wrd =~ '\\\end{equation}\kox\x" else exe "silent! norm! ".init."\\begin{equation}\\label{".lblline."}\\\end{equation}\kox\x" endif " eqns` elseif wrd =~ '\\\begin{eqnarray*}\\\end{eqnarray*}}\\hfill\\parbox{\\eqnaLengthR}{\\begin{eqnarray}\\end{eqnarray}}\ko variable & = & value \\\\\0fvh" else exe "silent! norm! ".init."\\parbox{\\eqnaLengthL}{\\\begin{eqnarray*}\\\end{eqnarray*}}\\hfill\\parbox{\\eqnaLengthR}{\\begin{eqnarray}\\label{".lblline."}\\end{eqnarray}}\ko variable & = & value \\\\\0fvh" endif " fig` elseif wrd =~ '\ \\framebox{X}\ \\caption{CAPTION HERE}\ \\end{figure}\0kkfXcw\" else exe "silent! norm! bcw\\begin{figure}[H]\\label{".lblline."}\\centering\ \\framebox{X}\ \\caption{CAPTION HERE}\ \\end{figure}\0kkfXcw\" endif " fla` elseif wrd =~ 'fla\%[lign]' " {{{2 if lblline == "" exe "silent! norm! ".init."\\begin{flalign}\\\end{flalign}\kox\x" else exe "silent! norm! ".init."\\begin{flalign}\\label{".lblline."}\\\end{flalign}\kox\x" endif " frac` elseif wrd =~ '\2hi" ino 02f{:iun a " item` elseif wrd =~ '\\\end{itemize}\ko\\item \" " i` elseif wrd =~ '\' " {{{2 if v:version >= 700 let swp = SaveWinPosn() let bgn = 1 let end = 1 while bgn <= end && bgn > 0 && end > 0 let end= search('\\end\>','bnW') let bgn= search('\\begin\>','bW') endwhile call RestoreWinPosn(swp) if getline(bgn) =~ "description" exe "silent! norm! ".init."\\item[] \hha" ino 0f]l:iun a else exe "silent! norm! ".init."\\item " endif else exe "silent! norm! ".init."\\item " endif " ind` elseif wrd =~ '\\\end{indentation}\ko\x" " gat` elseif wrd =~ '\\\end{gather}\kox\x" else exe "silent! norm! ".init."\\begin{gather}\\label{".lblline."}\\\end{gather}\kox\x" endif " multi` elseif wrd =~ '\2F{" " multl` elseif wrd =~ '\\\end{multline}\kox\x" else exe "silent! norm! ".init."\\begin{multline}\\label{".lblline."}\\\end{multline}\kox\x" endif " sli` elseif wrd =~ '\\\end{slide}\k0fXxi" ino :iun o elseif wrd =~ '\\\end{tabular}\\end{center}\\" else exe "silent! norm! bcw\\begin{center}\\begin{tabular}{X}\\label{".lblline."}\\\end{tabular}\\end{center}\\" endif exe "silent! norm! kk0fXxi" ino :iun o " split` elseif wrd =~ '\\\end{split}\\end{equation}\kox\x" else exe "silent! norm! ".init."\\begin{equation}\\label{".lblline."}\\begin{split}\\\end{split}\\end{equation}\kox\x" endif " tab` elseif wrd =~ '\" if lblline == "" exe "silent! norm! o\\begin{table}[H]\\\begin{center}\\begin{tabular}{||l|l|l||}\\\hline\\hline\\\multicolumn{1}{||c|}{Column 1} &\\\multicolumn{1}{c|}{Column 2} &\\\multicolumn{1}{c||}{Column 3} \\\\\\\hline\ ...&...&...\\\\\\\\\hline\\hline\\\\end{tabular}\\end{center}\\\caption{Table Name}\\\end{table}\\" else exe "silent! norm! o\\begin{table}[H]\\label{".lblline."}\\\begin{center}\\begin{tabular}{||l|l|l||}\\\hline\\hline\\\multicolumn{1}{||c|}{Column 1} &\\\multicolumn{1}{c|}{Column 2} &\\\multicolumn{1}{c||}{Column 3} \\\\\\\hline\ ...&...&...\\\\\\\\\hline\\hline\\\\end{tabular}\\end{center}\\\caption{Table Name}\\\end{table}\\" endif exe "silent! norm! ?begin{tabular}?\fl;h" " verb` elseif wrd =~ '\\\end{verbatim}\kox\x" " v` elseif wrd =~ '\xi\\verb``\ha" ino f`:iun a " mat` elseif wrd =~ '\\\begin{array}{cc}\X & & \\\\\ \ & & \\\end{array}\0xo\\right]\?X\x" " mini` elseif wrd =~ '\\\end{minipage}\ko\" " LaTeX script support " {{{2 " bf` elseif wrd =~ '\i" ino f}:iun a " it` elseif wrd =~ '\i" ino f}:iun a " rm` elseif wrd =~ '\i" ino f}:iun a " sc` elseif wrd =~ '\i" ino f}:iun a " sf` elseif wrd =~ '\i" ino f}:iun a " sl` elseif wrd =~ '\i" ino f}:iun a " tt` elseif wrd =~ '\i" ino f}:iun a " mcal` elseif wrd =~ '\i" ino f}:iun a " mbf` elseif wrd =~ '\i" ino f}:iun a " mit` elseif wrd =~ '\i" ino f}:iun a " mrm` elseif wrd =~ '\i" ino f}:iun a " msf` elseif wrd =~ '\i" ino f}:iun a " mtt` elseif wrd =~ '\i" ino f}:iun a " Lower case Greek alphabet " {{{2 " a` elseif wrd =~ '\' exe "silent! norm! r\\aalpha\a" " b` elseif wrd =~ '\' exe "silent! norm! r\\abeta\a" " g` elseif wrd =~ '\' exe "silent! norm! r\\agamma\a" " d` elseif wrd =~ '\' exe "silent! norm! r\\adelta\a" " e` elseif wrd =~ '\' exe "silent! norm! r\\aepsilon\a" " ve` elseif wrd =~ '\' exe "silent! norm! ".init."\\varepsilon" " z` elseif wrd =~ '\' exe "silent! norm! r\\azeta\a" " n` elseif wrd =~ '\' exe "silent! norm! r\\aeta\a" " t` elseif wrd =~ '\' exe "silent! norm! r\\atheta\a" " vt` elseif wrd =~ '\' exe "silent! norm! ".init."\\vartheta" " io` elseif wrd =~ '\' exe "silent! norm! ".init."\\iota" " k` elseif wrd =~ '\' exe "silent! norm! r\\akappa\a" " l` elseif wrd =~ '\' exe "silent! norm! r\\alambda\a" " m` elseif wrd =~ '\' exe "silent! norm! r\\amu\a" " vv` elseif wrd =~ '\' exe "silent! norm! r\\anu\a" " p` elseif wrd =~ '\' exe "silent! norm! r\\api\a" " vp` elseif wrd =~ '\' exe "silent! norm! ".init."\\varpi" " r` elseif wrd =~ '\' exe "silent! norm! r\\arho\a" " vr` elseif wrd =~ '\' exe "silent! norm! ".init."\\varrho" " vt` elseif wrd =~ '\' exe "silent! norm! ".init."\\vartheta" " s` elseif wrd =~ '\' exe "silent! norm! r\\asigma\a" " vs` elseif wrd =~ '\' exe "silent! norm! r\\avarsigma\a" " tau` elseif wrd =~ '\' exe "silent! norm! r\\atau\a" " u` elseif wrd =~ '\' exe "silent! norm! r\\aupsilon\a" " h` elseif wrd =~ '\' exe "silent! norm! r\\aphi\a" " vh` elseif wrd =~ '\' exe "silent! norm! ".init."\\varphi" " x` elseif wrd =~ '\' exe "silent! norm! r\\achi\a" " q` elseif wrd =~ '\' exe "silent! norm! r\\apsi\a" " w` elseif wrd =~ '\' exe "silent! norm! r\\aomega\a" else exe "silent! norm! a`\" endif let &ve= vekeep " call Dret("DrCTexStubs") endfun " --------------------------------------------------------------------- " TexQuotes: converts a '"' into `` or '' in LaTeX. {{{1 " Supports an imap fu! TexQuotes() let line = getline(".") let curpos = col(".")-1 let insert = "''" let left = strpart(line, curpos-1, 1) let tzid = synIDtrans(hlID("texZone")) let curcol = col(".") - 1 if tzid == synIDtrans(synID(line("."),curcol,1)) let insert= '"' elseif left == "\\" exe "norm! hr\"i\"\l" let insert = '' elseif left == ' ' || left == ' ' || left == '' let insert = '``' endif return insert endfun " --------------------------------------------------------------------- " vim:fdm=marker doc/drcstubs.txt [[[1 215 *drcstubs.txt* DrChip's C Stubs Jun 29, 2009 Author: Charles E. Campbell, Jr. (remove NOSPAM from Campbell's email first) Copyright: (c) 2004-2005 by Charles E. Campbell, Jr. *drcstubs-copyright* The VIM LICENSE applies to drcstubs.vim and drcstubs.txt (see |copyright|) except use "drcstubs" instead of "Vim" No warranty, express or implied. Use At-Your-Own-Risk. ============================================================================== 1. Contents *drcstubs* *drcstubs-contents* 1. Contents.............................: |drcstubs-contents| 2. Usage................................: |drcstubs-usage| C Language Support...................: |drcstubs-c| LaTeX Language Support...............: |drcstubs-tex| Vim Language Support.................: |drcstubs-vim| 3. Installation.........................: |drcstubs-install| 4. History..............................: |drcstubs-history| ============================================================================== 2. Usage *drcstubs-usage* All of the DrCStubs ftplugin scripts provide maps which work during insert mode. One may use either the shorthand or longhand maps to invoke the corresponding imap. They are invoked whenever a string is followed by a backquote. One major advantage of these imaps is that they, in turn, take advantage of the user's cindent settings and/or indentation scripts. Thus the result should be as if the user had typed them him/herself. These imaps will not operate if "set paste:" is on. In the maps below: An "X" is where the cursor will end up after the map is invoked. An "Y" is where the cursor will end up after an is pressed. A "|" means a newline. Another form of help is available by typing > :Drcstubs < ------------------ C LANGUAGE SUPPORT *drcstubs-c* ------------------ > Shorthand Longhand Expands Map Map To < --------- -------- ------- i` if` if(X) {Y} e` els[e]` else {X} ei` eli[f]` else if(X) {Y} f` for\=` for(X;;) {Y} w` wh[ile]` while(X) {Y} s` sw[itch]` switch(X) {Y} c` ca[se]` case X: Y break; d` defa[ult]` default: Y break; ` do` do {X} while(Y); E` Ed[bg]` Edbg((\"func(X)\"Y)); R` Rd[bg]` Rdbg((\"funcX\"Y)); D` Dp[rintf]` Dprintf((1,\"X\"Y)); in[clude]` #include X de[fine]` #define X #` #ifdef X ... #endif ------------- LATEX SUPPORT *drcstubs-tex* *drcstubs-latex* ------------- > Environments And Abbreviations Shorthand Longhand Expands Map Map To < --------- -------- ------- align` \begin{align}|X|\end{align} arr` array` \left[\begin{array}{ccc}|X|\end{array}\right] ctr` center` \begin{center}|X|\end{center} desc` description` \begin{description}|\item[X]|\end{sdescription} enum` enumerate` \begin{enumerate}|\item X|\end{enumerate} eps` epsf` \begin{figure}[H]\centering\framebox{\epsfbox{X.eps}}\end{figure} eqn` equation` \begin{equation}|X|\end{equation} eqna` eqnarray` \begin{eqnarray}|X&=& Y \\|\end{eqnarray} fig` figure` \begin{figure}[H]\centering \framebox{X} \caption{CAPTION HERE} \end{figure} flalign` \begin{flalign}|X|\end{flalign} frac` \frac{X}{Y} gat` gather` \begin{gather}|X|\end{gather} i` \item X i` \item[X] Y (if vim v7, and in a description block) item` itemize` \begin{itemize}|\item X|\end{itemize} mat` matrix` \left[|\begin{array}{cc}| X & & \\|& & |\end{array}|\right] mini` minipage` \begin{minipage}[H]{4in}|X|\end{minipage} multc` multicol` \multicolumn{1}{X|c|}{MultiColumn} multl` multline` \begin{multline}|X|\end{multline} split` \begin{equation}\begin{split}|X|\end{split}\end{equation} tab` tabular` (too long for here) v` \verb`X` verb` verbatim` \begin{verbatim}|X|\end{verbatim} > Script Style Support Shorthand Longhand Expands Map Map To < --------- -------- ------- bf` \textbf{} it` \textit{} rm` \textrm{} sc` \textsc{} sf` \textsf{} sl` \textsl{} tt` \texttt{} mtt` \mathtt{} mrm` \mathrm{} mbf` \mathbf{} msf` \mathsf{} mtt` \mathtt{} mit` \mathit{} mcal` \mathcal{} > Greek Letters: Shorthand Expands Shorthand Expands Map To Map To < --------- ------- --------- ------- a` \alpha v \nu b` \beta f \xi g` \gamma p \pi d` \delta vp \varpi e` \epsilon r \rho ve` \varepsilon vr \varrho z` \zeta s \sigma n` \eta v \varsigma t` \theta t \tau vt` \vartheta u \upsilon io` \iota h \phi k` \kappa vh \varphi l` \lambda x \chi m` \mu q \psi w` \omega ---------- SH SUPPORT *drcstubs-sh* ---------- > Shorthand Longhand Expands Map Map To < --------- -------- ------- ca[se]` c` case X in|Y|esac fo[r]` f` for X in Y ; do|Z|done if` i` if [[ X ]]; then|Y|fi eli[f]` ei` elif [[ X ]]; then|Y els[e]` e` else|X fu[nction]` function X|{|Y|} wh[ile]` w` while [[ X ]]; do|Y|done ----------- VIM SUPPORT *drcstubs-vim* ----------- > Shorthand Longhand Expands Map Map To < --------- -------- ------- i if if X|endif e els[e] else|X ei eli[f] elseif X fu[nction] fun! X(Y)|endfun w wh[ile] while X|endwhile F Df[unc] call Dfunc("func(X)")|Y R Dr[et] call Dret("return func X") D De[echo] call Decho("X")|Y ============================================================================== 3. Installation *drcstubs-install* a) place drcstubs.tar.gz in your Unix: $HOME/.vim Windows: ..wherever..\vimfiles directory b) gunzip drcstubs.tar.gz c) tar -oxvf drcstubs.tar d) Unix: vim :helptags ~/.vim/doc Windows: vim :helptags ..wherever../vimfiles/doc e) Have a line in your <.vimrc> file such as: filetype plugin indent on The next time you bring up vim with one of the supported filetypes (C, C++, LaTeX, Vim, sh-ksh-bash) the Drcstubs maps will be available for use. They work best if you've set up cindent (see |'cinoptions'|); the one I use follows, but may well not be the style to which you are accustomed: set cino=>s,e0,n0,f0,{0,}4,^-1s,:0,=s,g0,h1s,p2,t0,+2,(2,)20,*30 You'll also want automatic indentation. Vim comes with several such scripts; the ones I've customized are available at http://vim.sourceforge.net/scripts/script.php?script_id=1270 ============================================================================== 4. History *drcstubs-history* 3 Jun 29, 2009 : put silent! on iunmenu calls to prevent unwanted error messages when inappropriately invoked. vim: ts=4