" Copy search matched text " -- " From http://www.vim.org/tips/tip.php?tip_id=478 " -- " previous clear the clipboard with this command :normal "*y0 " Usage: :g//call YankMatched() " function! YankMatched() let index = 0 let xEnd = 0 let @"="" while index >= 0 let @" = @" . matchstr(getline("."), '' . histget("/", -1), index) let xEnd = matchend(getline("."), '' . histget("/", -1), index) let index = match(getline("."), '' . histget("/", -1), xEnd) endwhile unlet index unlet xEnd endfunction " Add line break after the current character function! Char_SuffixNewLine() exec ".,.call SuffixNewLine( '" . getline(".")[col(".")-1] . "' )" endfunction " Add line break after the current word function! Word_SuffixNewLine() exec ".,.call SuffixNewLine( '" . expand() . "' )" endfunction " Add line break after given string function! SuffixNewLine(...) range let str_no = 1 while str_no <= a:0 exec 'let var = a:' . str_no " - ` (backquote) used in s/// as delimiter is hard to recognize; " OTOH they are rarer than other delimiters. Thus decrease the " need of escaping delimiter character appreaing in a pattern. " " - Failed match error messages are suppressed (/e). exec a:firstline . "," . a:lastline . 's`\(' . var . '\)`\1\r`ge' let str_no = str_no +1 endwhile unlet! var unlet str_no endfunction " Insert line break before given string function! PrefixNewLine(...) range let str_no = 1 while str_no <= a:0 exec 'let var = a:' . str_no " - ` (backquote) used in s/// as delimiter is hard to recognize; " OTOH they are rarer than other delimiters. Thus decrease the " need of escaping delimiter character appreaing in a pattern. " " - Failed match error messages are suppressed (/e). exec a:firstline . "," . a:lastline . 's`\(' . var . '\)`\r\1`ge' let str_no = str_no +1 endwhile unlet! var unlet str_no endfunction "function! PrePostpend() " exec ' = i\textit{' . . 'i}' "endfunction " Set up syntax & highlighting, given that syntax is in .syn & " highlighting is in .hilight ... unless 'print' is true. In " that case, print.hilight is used. " " Two optional arguments: a:1 is to set the syntax if different than " a:type itself; a:2 is to set highlighting for printing. " function! Set_Syntax_Hilight( type, ...) syn clear so $vim_cf/default.syn exec 'so ' . $vim_cf . '/' . a:type . '.syn' " Set syntax if given. if exists( "a:1" ) exec 'set syn=' . a:1 else exec 'set syn=' . a:type endif hi clear " Set highlighting for printing if specified. if exists( "a:2" ) so $vim_cf/print.hilight else so $vim_cf/default.hilight exec 'so ' . $vim_cf . '/' . a:type . '.hilight' endif endfunction