+ blockdiff.vim, vgrepsup.vim

git-svn-id: https://vimsuite.svn.sourceforge.net/svnroot/vimsuite/trunk@147 eb2d0018-73a3-4aeb-bfe9-1def61c9ec69
This commit is contained in:
stefan 2007-11-05 10:58:58 +00:00
parent 2457040044
commit 522f5b30cc
19 changed files with 4799 additions and 2751 deletions

View File

@ -29,7 +29,7 @@ setlocal expandtab
"set cindent
setlocal cinoptions=*200,)100,(s,w1
let &l:shiftwidth = tabwidth
setlocal formatoptions=croq
setlocal formatoptions=wan2croql
setlocal formatexpr=KgsFormat()
" commenting

View File

@ -25,13 +25,20 @@ syn keyword damosFunction einstelleSprache oeffneOSp liesBezeichner oeffnePV
syn keyword damosFunction liesAdressDatei anlegeDatenstand
syn keyword damosFunction liesKonservierung speichere schreibeHexDatei
syn keyword damosFunction schreibeASAP_AgIAsw
syn keyword damosFunction kdoOTypCheck ausfuehreTrans pruefeAutoRam
syn keyword damosFunction kdoOTypCheck ausfuehre ausfuehreTrans pruefeAutoRam
syn keyword damosFunction pruefeFktKonsistenz schreibeFhlListAusFktKonsPruef
syn keyword damosFunction oeffneQuellDatenstand fuelleAusTestwerte
syn keyword damosFunction definiereSGGrAuswahl anlegeAsw entferneAsw schneideAsw
syn keyword damosFunction schliesseAsw setzeUmfang schreibeDatenquelle
syn keyword damosFunction schreibeFktIncludeAbh anlegeOSp importiereObjekte
syn keyword damosFunction schliesseOSp
syn keyword damosFunction anlegeProjekt anlegePV liesDefBase
syn keyword damosFunction schliesseOSp schliesseQuellDatenstand
syn keyword damosFunction anzeigeVarKod liefereName
syn keyword damosFunction pruefeAblKonsistenz pruefeBezeichnerListe
syn keyword damosFunction pruefeRefInfo pruefeSpeicherbereiche
syn keyword damosFunction pruefeMinPMaxP pruefeVarKod vater
syn keyword damosFunction schreibeFhlListAusBezKonsPruef schreibeFktIncludeAsw
syn keyword damosCommand exit Dam DAMOS quellDst
syn match damosSeperator "[<>,:]"

View File

@ -13,6 +13,7 @@ syntax keyword kgsDefinitions fkt_bezeichner kgs_bezeichner ram_bezeichner
syntax keyword kgsDefinitions ram_groesse lok_ram_groesse kennwert kennlinie
syntax keyword kgsDefinitions gruppenkennlinie gruppenkennfeld gruppenstuetzstellen
syntax keyword kgsDefinitions kennfeld kennwerteblock systemkonstante festkennlinie
syntax keyword kgsDefinitions kenngroessen_gruppe ramgroessen_gruppe
syntax keyword kgsRefgroessen ref_ram_groesse ref_kenngroesse
syntax keyword kgsKomponents umrechnung codesyntax datentyp adressierschema
syntax keyword kgsKomponents bitanzahl element_anzahl bitbasis_typ bitposition

View File

@ -10,7 +10,7 @@ setlocal softtabstop=4
setlocal formatoptions=croq
" vimfiles sollen immer im unix-Format gespeichert werden
if filewritable(expand('%'))
if &modifiable
setlocal fileformat=unix
endif

View File

@ -14,6 +14,10 @@ if exists('nochangelog')
endif
function s:ReportRev(Rev)
if a:Rev >= '145'
echo 'Neu seit Rev: 145'
echo 'BlockDiff: Markieren -> BlockDiff -> Markieren -> BlockDiff -> neuer Tab'
echo 'Gsub: global substitute'
if a:Rev >= '139'
echo 'Neu seit Rev: 129'
echo 'Projekt laden über project.vim'

View File

@ -323,3 +323,67 @@ disk
false
true
copy_FCMTabEntryType
brief
author
date
Ramgrößen
lint
Ramwert
Adaptionswertes
restore
Adaptionswert
Adaptionsgrößen
Adaptionswerten
ref
ram
bezeichner
groesse
RaMNonVolatileRamU16
umrechnung
dez
Initialisierungswert
kennwert
KgMKwWU16
uint16
Doxygen
doku
page
Fahrsoftware
section
Adaptionsvorgänge
create
li
Ramgröße
code
wertp
endcode
include
b
Init
Objektspeicher
Desc
Preprozessor
Description
Hint
BMSX
Mainpage
Developersguide
Entwicklerdoku
mainpage
image
html
jpg
Developers
Guide
Library
BDL
Coding
Guidelines
Applikationsdaten
subsection
check
subsubsection
Applikationslabel
Codesyntaxen
shade
Headers

Binary file not shown.

View File

@ -1,7 +1,6 @@
ScriptID SourceID Filename
--------------------------
642 7080 GetLatestVimScripts.vim
1075 7079 netrw.vim
1075 7738 netrw.vim
1502 7078 vimball.vim
1008 3118 srec.vim (ftplugin)
1009 3119 srec.vim (syntax file)
@ -12,12 +11,18 @@ ScriptID SourceID Filename
51 171 cscope_macros.vim
102 5306 DirDiff.vim
1189 6533 matrix.vim
1173 7046 tcomment
1173 7588 tcomment
948 2878 Scons Compiler plugin
1709 6421 Scons Syntax file
1772 7248 DAMOS.zip DAMOS tools (von Stefan)
987 6978 DoxygenToolkit.vim
1397 6887 xml.vim
1290 5190 LogiPat
1881 7244 svndiff
1290 5190 LogiPat.vim
1881 7505 svndiff
1462 5612 dtd2xml
1046 4249 Lusty Explorer
2043 7805 VimPdb (debugging python)
1776 7810 Vimgrep Replace
2048 7815 BlockDiff
642 7080 getscript.vim
642 7080 :AutoInstall: GetLatestVimScripts.vim

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,7 @@
" netrwSettings.vim: makes netrw settings simpler
" Date: Mar 26, 2007
" Date: Jun 04, 2007
" Maintainer: Charles E Campbell, Jr <drchipNOSPAM at campbellfamily dot biz>
" Version: 9
" Version: 11
" Copyright: Copyright (C) 1999-2007 Charles E. Campbell, Jr. {{{1
" Permission is hereby granted to use and distribute this code,
" with or without modifications, provided that this copyright
@ -19,13 +19,13 @@
if exists("g:loaded_netrwSettings") || &cp
finish
endif
let g:loaded_netrwSettings = "v9"
let g:loaded_netrwSettings = "v11"
" ---------------------------------------------------------------------
" NetrwSettings: {{{1
fun! netrwSettings#NetrwSettings()
" this call is here largely just to insure that netrw has been loaded
call netrw#NetSavePosn()
call netrw#NetrwSavePosn()
if !exists("g:loaded_netrw")
echohl WarningMsg | echomsg "***sorry*** netrw needs to be loaded prior to using NetrwSettings" | echohl None
return
@ -101,6 +101,11 @@ fun! netrwSettings#NetrwSettings()
else
put = 'let g:netrw_browsex_viewer = (not defined)'
endif
let cdescline= line("$")
put ='let g:netrw_cd_escape...'
put = 'let g:netrw_compress = '.g:netrw_compress
let decompressline= line("$")
put ='let g:netrw_decompress...'
put = 'let g:netrw_dirhistmax = '.g:netrw_dirhistmax
put = 'let g:netrw_fastbrowse = '.g:netrw_fastbrowse
put = 'let g:netrw_ftp_browse_reject = '.g:netrw_ftp_browse_reject
@ -111,12 +116,15 @@ fun! netrwSettings#NetrwSettings()
put = 'let g:netrw_keepdir = '.g:netrw_keepdir
put = 'let g:netrw_list_cmd = '.g:netrw_list_cmd
put = 'let g:netrw_list_hide = '.g:netrw_list_hide
put = 'let g:netrw_local_mkdir = '.g:netrw_local_mkdir
put = 'let g:netrw_local_rmdir = '.g:netrw_local_rmdir
put = 'let g:netrw_liststyle = '.g:netrw_liststyle
put = 'let g:netrw_localcopycmd = '.g:netrw_localcopycmd
put = 'let g:netrw_local_mkdir = '.g:netrw_local_mkdir
put = 'let g:netrw_localmovecmd = '.g:netrw_localmovecmd
put = 'let g:netrw_local_rmdir = '.g:netrw_local_rmdir
put = 'let g:netrw_maxfilenamelen = '.g:netrw_maxfilenamelen
put = 'let g:netrw_menu = '.g:netrw_menu
put = 'let g:netrw_mkdir_cmd = '.g:netrw_mkdir_cmd
put = 'let g:netrw_preview = '.g:netrw_preview
put = 'let g:netrw_rename_cmd = '.g:netrw_rename_cmd
put = 'let g:netrw_rm_cmd = '.g:netrw_rm_cmd
put = 'let g:netrw_rmdir_cmd = '.g:netrw_rmdir_cmd
@ -142,13 +150,15 @@ fun! netrwSettings#NetrwSettings()
silent %s/= $/= ''/e
1
" Put in shq setting.
" Put in g:netrw_shq setting and g:netrw_cd_escape
" (deferred so as to avoid the quote manipulation just preceding)
if g:netrw_shq == "'"
call setline(shqline,'let g:netrw_shq = "'.g:netrw_shq.'"')
else
call setline(shqline,"let g:netrw_shq = '".g:netrw_shq."'")
endif
call setline(cdescline,"let g:netrw_cd_escape = ".'"'.escape(g:netrw_cd_escape,'\"').'"')
call setline(decompressline,"let g:netrw_decompress = ".substitute(string(g:netrw_decompress),"^'\\(.*\\)'$",'\1',''))
set nomod

File diff suppressed because it is too large Load Diff

View File

@ -1,37 +1,65 @@
*tComment.txt* tComment -- An easily extensible & universal comment plugin
Author: Thomas Link, samul AT web.de
Author: Thomas Link, micathom AT gmail com?subject=vim
tComment provides easy to use, file type sensible comments for Vim. It
tComment provides easy to use, file-type sensible comments for Vim. It
can handle embedded syntax.
*tComment-Installation*
Installation~
Copy the file tComment.vim to your plugin directory (~/.vim/plugins/ or
similar). See |standard-plugin| for further details.
Edit the vba file and type:
:so %
See :help vimball for details. If you use vim 7.0, you may need to
update your vimball installation first.
*tComment-uninstall*
In case you have some bash or similar, you can feed the file
etc/tComment.lst to rm: >
cd $HOME/.vim/
rm -i `cat etc/tComment.lst`
*tComment-Usage*
Usage~
The command TComment is bound to <c-_><c-_> by default. TComment works
like a toggle, i.e., it will comment out text that contains uncommented
lines, and it will remove comment markup for already commented text
(i.e. text that contains no uncommented lines).
TComment works like a toggle, i.e., it will comment out text that
contains uncommented lines, and it will remove comment markup for
already commented text (i.e. text that contains no uncommented lines).
If the file-type is properly defined, TComment will figure out which
comment string to use. Otherwise you use |TCommentDefineType()| to
override the default choice.
TComment can properly handle an embedded syntax, e.g., ruby/python/perl
regions in vim scripts, HTML or JavaScript in php code etc.
*tComment-Key-Bindings*
Key bindings~
Most of the time the default toggle keys will do what you want (or to be
more precise: what I think it should to ;-).
*g:tcommentMapLeaderOp1*
*g:tcommentMapLeaderOp2*
As operator (the prefix can be customized via g:tcommentMapLeaderOp1
and g:tcommentMapLeaderOp2):
gc{motion} :: Toggle comments (for small comments within one line
the &filetype_inline style will be used, if
defined)
gcc :: Toggle comment for the current line
gC{motion} :: Comment region
gCc :: Comment the current line
*g:tcommentOpModeExtra*
By default the cursor stays put. If you want the cursor to the end of
the commented text, set g:tcommentOpModeExtra to '>' (but this may not
work properly with exclusive motions).
Primary key maps:
<c-_><c-_> :: :TComment
<c-_><space> :: :TComment <QUERY COMMENT-BEGIN ?COMMENT-END>
<c-_>b :: :TCommentBlock
<c-_>a :: :TCommentAs <QUERY COMMENT TYPE>
<c-_>n :: :TCommentAs &filetype <QUERY COUNT>
<c-_>s :: :TCommentAs &filetype_<QUERY COMMENT SUBTYPE>
<c-_>i :: :TCommentInline
<c-_>r :: :TCommentRight
@ -46,6 +74,7 @@ A secondary set of key maps is defined for normal mode.
<Leader>_r :: :TCommentRight
<Leader>_b :: :TCommentBlock
<Leader>_a :: :TCommentAs <QUERY COMMENT TYPE>
<Leader>_n :: :TCommentAs &filetype <QUERY COUNT>
<Leader>_s :: :TCommentAs &filetype_<QUERY COMMENT SUBTYPE>
Keymaps are configurable via the following variables:
@ -96,7 +125,7 @@ Alternatively, you can type (? meaning "optional argument"):
:?<range> TCommentRight!
NOTE: This command comments out the text to the right of the cursor.
If a visual selection was made (be it block-wise or not), all lines
are commented out at from the current cursor positon downwards.
are commented out at from the current cursor position downwards.
The bang (!) variants always comment out the selected text and don't
work as toggles.
@ -112,7 +141,7 @@ Alternatively, you can type (? meaning "optional argument"):
'commentstring'.
If you want to define, e.g., a fancy block comment style for html
you could do something like: >
you put something like this into ~/.vim/after/plugin/tComment.vim:>
call TCommentDefineType("html_fancy_block", "<!--%s -->\n -- ")
@ -135,7 +164,7 @@ Goals~
- Handle embedded syntax like php+html or html+javaScript+css; you
have to set g:tcommentGuessFileType_{&filetype} to 1 or to the
fallback file type in order to activate this feature for other file
fall-back file-type in order to activate this feature for other file
types than php or html
tComment deduces the correct file type from the syntax name, similar
@ -149,7 +178,7 @@ Goals~
buffer local &commentstring option (which can be set on a vim
|modeline|)
- Use 'commentstring' or 'comments' as a fallback (i.e., if a filetype
- Use 'commentstring' or 'comments' as a fallback (i.e., if a file-type
is properly defined, TComment will automatically support it)
- Same short-cut for commenting text and for removing comment markup
@ -157,10 +186,10 @@ Goals~
- The decision whether text should be commented or uncommented is made
on the basis of the whole selection (not line by line); comments in
code that should be commented aren't uncommented as it is the case
with some other plugins
with some other plug-ins
As of version 1.5, the following file types are explicitly defined
(other filetypes are most likely supported through the 'commentstring'
(other file-types are most likely supported through the 'commentstring'
or 'comments' variables):
ada, apache, autoit, catalog, cpp, css, c, cfg, conf, desktop,

View File

@ -8,6 +8,7 @@
:MkVimball pi_vimball.txt /*:MkVimball*
:Nexplore pi_netrw.txt /*:Nexplore*
:Pexplore pi_netrw.txt /*:Pexplore*
:Rexplore pi_netrw.txt /*:Rexplore*
:RmVimball pi_vimball.txt /*:RmVimball*
:Sexplore pi_netrw.txt /*:Sexplore*
:TComment tComment.txt /*:TComment*
@ -1283,8 +1284,10 @@ g:netrw_alto pi_netrw.txt /*g:netrw_alto*
g:netrw_altv pi_netrw.txt /*g:netrw_altv*
g:netrw_browse_split pi_netrw.txt /*g:netrw_browse_split*
g:netrw_browsex_viewer pi_netrw.txt /*g:netrw_browsex_viewer*
g:netrw_compress pi_netrw.txt /*g:netrw_compress*
g:netrw_cygwin pi_netrw.txt /*g:netrw_cygwin*
g:netrw_dav_cmd pi_netrw.txt /*g:netrw_dav_cmd*
g:netrw_decompress pi_netrw.txt /*g:netrw_decompress*
g:netrw_extracmd pi_netrw.txt /*g:netrw_extracmd*
g:netrw_fastbrowse pi_netrw.txt /*g:netrw_fastbrowse*
g:netrw_fetch_cmd pi_netrw.txt /*g:netrw_fetch_cmd*
@ -1304,11 +1307,15 @@ g:netrw_list_hide pi_netrw.txt /*g:netrw_list_hide*
g:netrw_liststyle pi_netrw.txt /*g:netrw_liststyle*
g:netrw_local_mkdir pi_netrw.txt /*g:netrw_local_mkdir*
g:netrw_local_rmdir pi_netrw.txt /*g:netrw_local_rmdir*
g:netrw_localcopycmd pi_netrw.txt /*g:netrw_localcopycmd*
g:netrw_localmovecmd pi_netrw.txt /*g:netrw_localmovecmd*
g:netrw_maxfilenamelen pi_netrw.txt /*g:netrw_maxfilenamelen*
g:netrw_menu pi_netrw.txt /*g:netrw_menu*
g:netrw_mkdir_cmd pi_netrw.txt /*g:netrw_mkdir_cmd*
g:netrw_nogx pi_netrw.txt /*g:netrw_nogx*
g:netrw_noretmap pi_netrw.txt /*g:netrw_noretmap*
g:netrw_passwd pi_netrw.txt /*g:netrw_passwd*
g:netrw_preview pi_netrw.txt /*g:netrw_preview*
g:netrw_rcp_cmd pi_netrw.txt /*g:netrw_rcp_cmd*
g:netrw_rm_cmd pi_netrw.txt /*g:netrw_rm_cmd*
g:netrw_rmdir_cmd pi_netrw.txt /*g:netrw_rmdir_cmd*
@ -1318,6 +1325,7 @@ g:netrw_scp_cmd pi_netrw.txt /*g:netrw_scp_cmd*
g:netrw_scpport pi_netrw.txt /*g:netrw_scpport*
g:netrw_sftp_cmd pi_netrw.txt /*g:netrw_sftp_cmd*
g:netrw_shq pi_netrw.txt /*g:netrw_shq*
g:netrw_silent pi_netrw.txt /*g:netrw_silent*
g:netrw_sort_by pi_netrw.txt /*g:netrw_sort_by*
g:netrw_sort_direction pi_netrw.txt /*g:netrw_sort_direction*
g:netrw_sort_sequence pi_netrw.txt /*g:netrw_sort_sequence*
@ -1333,6 +1341,9 @@ g:netrw_win95ftp pi_netrw.txt /*g:netrw_win95ftp*
g:netrw_winsize pi_netrw.txt /*g:netrw_winsize*
g:tcommentMapLeader1 tComment.txt /*g:tcommentMapLeader1*
g:tcommentMapLeader2 tComment.txt /*g:tcommentMapLeader2*
g:tcommentMapLeaderOp1 tComment.txt /*g:tcommentMapLeaderOp1*
g:tcommentMapLeaderOp2 tComment.txt /*g:tcommentMapLeaderOp2*
g:tcommentOpModeExtra tComment.txt /*g:tcommentOpModeExtra*
g:vimball_home pi_vimball.txt /*g:vimball_home*
g:visincr_datedivset visincr.txt /*g:visincr_datedivset*
getlatestvimscripts-install pi_getscript.txt /*getlatestvimscripts-install*
@ -1384,10 +1395,15 @@ netrw-bookmarks pi_netrw.txt /*netrw-bookmarks*
netrw-browse pi_netrw.txt /*netrw-browse*
netrw-browse-cmds pi_netrw.txt /*netrw-browse-cmds*
netrw-browse-intro pi_netrw.txt /*netrw-browse-intro*
netrw-browse-var pi_netrw.txt /*netrw-browse-var*
netrw-browse-maps pi_netrw.txt /*netrw-browse-maps*
netrw-browser pi_netrw.txt /*netrw-browser*
netrw-browser-options pi_netrw.txt /*netrw-browser-options*
netrw-browser-var pi_netrw.txt /*netrw-browser-var*
netrw-browsing pi_netrw.txt /*netrw-browsing*
netrw-c pi_netrw.txt /*netrw-c*
netrw-cadaver pi_netrw.txt /*netrw-cadaver*
netrw-chgup pi_netrw.txt /*netrw-chgup*
netrw-clean pi_netrw.txt /*netrw-clean*
netrw-contents pi_netrw.txt /*netrw-contents*
netrw-cr pi_netrw.txt /*netrw-cr*
netrw-credits pi_netrw.txt /*netrw-credits*
@ -1425,10 +1441,21 @@ netrw-list pi_netrw.txt /*netrw-list*
netrw-listbookmark pi_netrw.txt /*netrw-listbookmark*
netrw-listhack pi_netrw.txt /*netrw-listhack*
netrw-login pi_netrw.txt /*netrw-login*
netrw-maps pi_netrw.txt /*netrw-maps*
netrw-mT pi_netrw.txt /*netrw-mT*
netrw-mb pi_netrw.txt /*netrw-mb*
netrw-mc pi_netrw.txt /*netrw-mc*
netrw-md pi_netrw.txt /*netrw-md*
netrw-me pi_netrw.txt /*netrw-me*
netrw-mf pi_netrw.txt /*netrw-mf*
netrw-ml_get pi_netrw.txt /*netrw-ml_get*
netrw-mm pi_netrw.txt /*netrw-mm*
netrw-move pi_netrw.txt /*netrw-move*
netrw-mp pi_netrw.txt /*netrw-mp*
netrw-mr pi_netrw.txt /*netrw-mr*
netrw-mt pi_netrw.txt /*netrw-mt*
netrw-mu pi_netrw.txt /*netrw-mu*
netrw-mx pi_netrw.txt /*netrw-mx*
netrw-mz pi_netrw.txt /*netrw-mz*
netrw-netrc pi_netrw.txt /*netrw-netrc*
netrw-nexplore pi_netrw.txt /*netrw-nexplore*
netrw-nread pi_netrw.txt /*netrw-nread*
@ -1437,6 +1464,8 @@ netrw-o pi_netrw.txt /*netrw-o*
netrw-options pi_netrw.txt /*netrw-options*
netrw-p pi_netrw.txt /*netrw-p*
netrw-p1 pi_netrw.txt /*netrw-p1*
netrw-p10 pi_netrw.txt /*netrw-p10*
netrw-p11 pi_netrw.txt /*netrw-p11*
netrw-p2 pi_netrw.txt /*netrw-p2*
netrw-p3 pi_netrw.txt /*netrw-p3*
netrw-p4 pi_netrw.txt /*netrw-p4*
@ -1462,12 +1491,14 @@ netrw-read pi_netrw.txt /*netrw-read*
netrw-ref pi_netrw.txt /*netrw-ref*
netrw-rename pi_netrw.txt /*netrw-rename*
netrw-reverse pi_netrw.txt /*netrw-reverse*
netrw-rexplore pi_netrw.txt /*netrw-rexplore*
netrw-s pi_netrw.txt /*netrw-s*
netrw-settings pi_netrw.txt /*netrw-settings*
netrw-sexplore pi_netrw.txt /*netrw-sexplore*
netrw-sort pi_netrw.txt /*netrw-sort*
netrw-sortsequence pi_netrw.txt /*netrw-sortsequence*
netrw-source pi_netrw.txt /*netrw-source*
netrw-ssh-hack pi_netrw.txt /*netrw-ssh-hack*
netrw-starpat pi_netrw.txt /*netrw-starpat*
netrw-starstar pi_netrw.txt /*netrw-starstar*
netrw-starstarpat pi_netrw.txt /*netrw-starstarpat*
@ -1505,7 +1536,6 @@ tComment-Installation tComment.txt /*tComment-Installation*
tComment-Key-Bindings tComment.txt /*tComment-Key-Bindings*
tComment-Usage tComment.txt /*tComment-Usage*
tComment-commands tComment.txt /*tComment-commands*
tComment-uninstall tComment.txt /*tComment-uninstall*
tComment.txt tComment.txt /*tComment.txt*
vba pi_vimball.txt /*vba*
vimball pi_vimball.txt /*vimball*

View File

@ -0,0 +1,86 @@
" Vim BlockDiff-Plugin
"
" Author: Timo Teifel
" Email: timo dot teifel at teifel dot net
" Version: 1.0
" Date: 22 Oct 2007
" Licence: GPL v2.0
"
" Usage:
" - Select first block
" - Depending on the configuration, select:
" - Menu BlockDiff-> This\ is\ Block\ 1
" - Popup-Menu -> This\ is\ Block\ 1
" - ,d1
" - select second block (may be in another file, but in the same
" Vim window)
" - Menu BlockDiff-> This\ is\ Block\ 2,\ start\ diff
" - Popup-Menu -> This\ is\ Block\ 2,\ start\ diff
" - ,d2
" - Script opens a new tab, splits it and shows the diff between
" the two blocks.
" - Close the tab when done
"
let s:save_cpo = &cpo
set cpo&vim
" ---------- Configuration ----------------------------------------------------
" uncomment one or more of these blocks:
" Create menu entry:
vmenu BlockDiff.This\ is\ block\ 1 :call BlockDiff_GetBlock1()<CR>
vmenu BlockDiff.This\ is\ block\ 2,\ start\ diff :call BlockDiff_GetBlock2()<CR>
" Create popup-menu-entry:
"vmenu PopUp.BlockDiff.This\ is\ block\ 1 :call BlockDiff_GetBlock1()<CR>
"vmenu PopUp.BlockDiff.This\ is\ block\ 2,\ start\ diff :call BlockDiff_GetBlock2()<CR>
" Shortcuts
"vmap ,d1 :call BlockDiff_GetBlock1()<CR>
"vmap ,d2 :call BlockDiff_GetBlock2()<CR>
" ---------- Code -------------------------------------------------------------
fun! BlockDiff_GetBlock1() range
let s:regd = @@
" copy selected block into unnamed register
exe a:firstline . "," . a:lastline . "y"
" save block for later use in variable
let s:block1 = @@
" restore unnamed register
let @@ = s:regd
endfun
fun! BlockDiff_GetBlock2() range
let s:regd = @@
exe a:firstline . "," . a:lastline . "y"
" Open new tab, paste second selected block
tabnew
normal p
" to prevent 'No write since last change' message:
se buftype=nowrite
diffthis
" vsplit left for first selected block
lefta vnew
" copy first block into unnamed register & paste
let @@ = s:block1
normal p
se buftype=nowrite
" start diff
diffthis
" restore unnamed register
let @@ = s:regd
endfun
let &cpo = s:save_cpo
unlet s:save_cpo

View File

@ -1,6 +1,6 @@
" netrwPlugin.vim: Handles file transfer and remote directory listing across a network
" PLUGIN SECTION
" Date: Jan 05, 2007
" Date: Aug 09, 2007
" Maintainer: Charles E Campbell, Jr <NdrOchip@ScampbellPfamily.AbizM-NOSPAM>
" GetLatestVimScripts: 1075 1 :AutoInstall: netrw.vim
" Copyright: Copyright (C) 1999-2005 Charles E. Campbell, Jr. {{{1
@ -64,11 +64,10 @@ augroup Network
augroup END
" Commands: :Nread, :Nwrite, :NetUserPass {{{2
com! -count=1 -nargs=* Nread call netrw#NetSavePosn()<bar>call netrw#NetRead(<count>,<f-args>)<bar>call netrw#NetRestorePosn()
com! -range=% -nargs=* Nwrite call netrw#NetSavePosn()<bar><line1>,<line2>call netrw#NetWrite(<f-args>)<bar>call netrw#NetRestorePosn()
com! -count=1 -nargs=* Nread call netrw#NetrwSavePosn()<bar>call netrw#NetRead(<count>,<f-args>)<bar>call netrw#NetrwRestorePosn()
com! -range=% -nargs=* Nwrite call netrw#NetrwSavePosn()<bar><line1>,<line2>call netrw#NetWrite(<f-args>)<bar>call netrw#NetrwRestorePosn()
com! -nargs=* NetUserPass call NetUserPass(<f-args>)
com! -nargs=+ Ncopy call netrw#NetObtain(<f-args>)
com! -nargs=* Nsource call netrw#NetSavePosn()<bar>call netrw#NetSource(<f-args>)<bar>call netrw#NetRestorePosn()
com! -nargs=* Nsource call netrw#NetrwSavePosn()<bar>call netrw#NetSource(<f-args>)<bar>call netrw#NetrwRestorePosn()
" Commands: :Explore, :Sexplore, Hexplore, Vexplore {{{2
com! -nargs=* -bar -bang -count=0 -complete=dir Explore call netrw#Explore(<count>,0,0+<bang>0,<q-args>)
@ -80,7 +79,8 @@ com! -nargs=* -bar -bang Nexplore call netrw#Explore(-1,0,0,<q-args>)
com! -nargs=* -bar -bang Pexplore call netrw#Explore(-2,0,0,<q-args>)
" Commands: NetrwSettings {{{2
com! -nargs=0 NetrwSettings :call netrwSettings#NetrwSettings()
com! -nargs=0 NetrwSettings call netrwSettings#NetrwSettings()
com! -bang NetrwClean call netrw#NetrwClean(<bang>0)
" Maps:
if !exists("g:netrw_nogx") && maparg('g','n') == ""

View File

@ -1,51 +1,59 @@
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" svndiff (C) 2007 Ico Doornekamp
" svndiff 2.0 (C) 2007 Ico Doornekamp
"
" Introduction
" ------------
"
" NOTE: This plugin is linux-only!
" NOTE: This plugin is unix-only!
"
" An experimental vim 7.0 plugin for showing svn diff information in a file
" while editing. This plugin runs a diff between the current buffer and the
" original subversion file, and applies highlighting to show where the buffer
" differs. The original text is not shown, only colors are used to indicate
" where changes were made.
" An small vim 7.0 plugin for showing svn diff information in a file while
" editing. This plugin runs a diff between the current buffer and the original
" subversion file, and shows coloured tags indicating where the buffer differs
" from the original file from the subversion repository. The original text is
" not shown, only signs are used to indicate where changes were made.
"
" The following syntax highlight groups are used:
" The following symbols and syntax highlight groups are used for the tags:
"
" DiffAdd: Newly added lines. (default=blue)
" > DiffAdd: Newly added lines. (default=blue)
"
" DiffChange: Lines which are changed from the original. (default=cyan)
"
" DiffDel: Applied to the lines directly above and below a deleted
" block (default=magenta)
" ! DiffChange: Lines which are changed from the original. (default=cyan)
"
" < DiffDel: Applied to the lines directly above and below a deleted block
" (default=magenta)
" Usage
" -----
"
" The plugin defines one function: Svndiff_show(). This function figures out
" the difference between the current file and it's subversion original, and
" creates the syntax highlighting patterns. You'll need to call this function
" after making changes to update the highlighting.
" The plugin defines one function: Svndiff(). This function figures out the
" difference between the current file and it's subversion original, and adds
" the tags at the places where the buffer differs from the original file from
" subversion. You'll need to call this function after making changes to update
" the highlighting.
"
"
" The function takes an optional argument specifying an additional action to
" perform:
"
" "prev": jump to the previous different block
" "next": jump to the next different block
" "prev" : jump to the previous different block
" "next" : jump to the next different block
" "clear" : clean up all tags
"
" You might want to map some keys to run the Svndiff_show function. For example,
" add to your .vimrc:
" You might want to map some keys to run the Svndiff function. For
" example, add to your .vimrc:
"
" noremap <F3> :call Svndiff_show("prev")<CR>
" noremap <F4> :call Svndiff_show("next")<CR>
" noremap <F3> :call Svndiff("prev")<CR>
" noremap <F4> :call Svndiff("next")<CR>
" noremap <F5> :call Svndiff("clear")<CR>
"
" And optionally another keymap to cleanup the diff highlighting and revert to
" the original syntax:
" Colors
" ------
"
" noremap <F5> :syntax on<CR>
" Personally, I find the following colours more intuitive for diff colours:
" red=deleted, green=added, yellow=changed. If you want to use these colours,
" try adding the following lines to your .vimrc
"
" hi DiffAdd ctermfg=0 ctermbg=2 guibg='green'
" hi DiffDelete ctermfg=0 ctermbg=1 guibg='red'
" hi DiffChange ctermfg=0 ctermbg=3 guibg='yellow'
"
" Changelog
" ---------
@ -56,10 +64,15 @@
"
" 1.2 2007-06-14 Updated diff arguments from -u0 (obsolete) to -U0
"
" 2.0 2007-08-16 Changed from syntax highlighting to using tags, thanks
" to Noah Spurrier for the idea. NOTE: the name of the
" function changed from Svndiff_show() to Svndiff(), so
" you might need to update your .vimrc mappings!
"
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
function! Svndiff_show(...)
function! Svndiff(...)
let cmd = exists("a:1") ? a:1 : ''
let fname = bufname("%")
@ -75,19 +88,32 @@ function! Svndiff_show(...)
end
" Reset syntax highlighting
" Remove all signs. If the cmd is 'clear', return right away. NOTE: this
" command removes all signs from the file, also if they were not placed by
" the this plugin. If this bothers your, tell me and I'll fix it.
sign unplace *
if cmd == 'clear'
return
endif
" Define sign characters and colors
syntax off
sign define svnadd text=> texthl=diffAdd
sign define svndelete text=< texthl=diffDelete
sign define svnchange text=! texthl=diffChange
" Pipe the current buffer contents to a shell command calculating the diff
" in a friendly parsable format
" This is where the magic happens: pipe the current buffer contents to a
" shell command calculating the diff in a friendly parsable format.
let contents = join(getbufline("%", 1, "$"), "\n")
let diff = system("diff -U0 <(svn cat " . fname . ") <(cat;echo)", contents)
" Parse the output of the diff command and hightlight changed, added and
" Parse the output of the diff command and put signs at changed, added and
" removed lines
for line in split(diff, '\n')
@ -105,20 +131,25 @@ function! Svndiff_show(...)
if old_count == 0
let from = new_from
let to = new_from + new_count - 1
let group = 'DiffAdd'
let name = 'svnadd'
elseif new_count == 0
let from = new_from
let to = new_from + 1
let group = 'DiffDelete'
let name = 'svndelete'
else
let from = new_from
let to = new_from + new_count - 1
let group = 'DiffChange'
let name = 'svnchange'
endif
" Set the actual syntax highlight
" Add signs to mark the changed lines
exec 'syntax region ' . group . ' start=".*\%' . from . 'l" end=".*\%' . to . 'l"'
let line = from
while line <= to
exec 'sign place ' . from . ' line=' . line . ' name=' . name . ' file=' . fname
let line = line + 1
endwhile
" Check if we need to jump to prev/next diff block
@ -141,6 +172,9 @@ function! Svndiff_show(...)
endfor
" Set the cursor to the new position, if requested
if jump_to > 0
call setpos(".", [ 0, jump_to, 1, 0 ])
endif

View File

@ -1,18 +1,18 @@
" tComment.vim -- An easily extensible & universal comment plugin
" @Author: Thomas Link (samul AT web.de)
" @Author: Thomas Link (micathom AT gmail com)
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
" @Created: 27-Dez-2004.
" @Last Change: 2007-04-15.
" @Revision: 1.6.285
" @Last Change: 2007-08-30.
" @Revision: 1.7.608
"
" vimscript #1173
if &cp || exists('loaded_tcomment')
finish
endif
let loaded_tcomment = 106
let loaded_tcomment = 107
fun! s:DefVar(name, val)
function! s:DefVar(name, val)
if !exists(a:name)
" exec "let ". a:name ."='". a:val ."'"
exec 'let '. a:name .'="'. escape(a:val, '"\') .'"'
@ -24,6 +24,10 @@ call s:DefVar('g:tcommentBlankLines', 1)
call s:DefVar('g:tcommentMapLeader1', '<c-_>')
call s:DefVar('g:tcommentMapLeader2', '<Leader>_')
" call s:DefVar('g:tcommentMapLeaderOp1', '<Leader>-')
call s:DefVar('g:tcommentMapLeaderOp1', 'gc')
call s:DefVar('g:tcommentMapLeaderOp2', 'gC')
call s:DefVar('g:tcommentOpModeExtra', '')
" Guess the file type based on syntax names always or for some fileformat only
call s:DefVar('g:tcommentGuessFileType', 0)
@ -37,6 +41,16 @@ call s:DefVar('g:tcommentGuessFileType_vim', 1)
call s:DefVar('g:tcommentIgnoreTypes_php', 'sql')
if !exists('g:tcommentSyntaxMap') "{{{2
let g:tcommentSyntaxMap = {
\ 'vimMzSchemeRegion': 'scheme',
\ 'vimPerlRegion': 'perl',
\ 'vimPythonRegion': 'python',
\ 'vimRubyRegion': 'ruby',
\ 'vimTclRegion': 'tcl',
\ }
endif
" If you don't define these variables, TComment will use &commentstring
" instead. We override the default values here in order to have a blank after
" the comment marker. Block comments work only if we explicitly define the
@ -56,12 +70,12 @@ call s:DefVar('g:tcommentBlockXML', "<!--%s-->\n ")
call s:DefVar('g:tcommentInlineXML', "<!-- %s -->")
" Currently this function just sets a variable
fun! TCommentDefineType(name, commentstring)
function! TCommentDefineType(name, commentstring)
call s:DefVar('g:tcomment_'. a:name, a:commentstring)
let s:tcommentFileTypesDirty = 1
endf
fun! TCommentTypeExists(name)
function! TCommentTypeExists(name)
return exists('g:tcomment_'. a:name)
endf
@ -110,6 +124,7 @@ call TCommentDefineType('java_inline', g:tcommentInlineC )
call TCommentDefineType('java_block', g:tcommentBlockC )
call TCommentDefineType('lisp', '; %s' )
call TCommentDefineType('m4', 'dnl %s' )
call TCommentDefineType('mail', '> %s' )
call TCommentDefineType('nroff', '.\\" %s' )
call TCommentDefineType('objc', '/* %s */' )
call TCommentDefineType('objc_inline', g:tcommentInlineC )
@ -144,6 +159,7 @@ call TCommentDefineType('sh', '# %s' )
call TCommentDefineType('sql', '-- %s' )
call TCommentDefineType('spec', '# %s' )
call TCommentDefineType('sps', '* %s.' )
call TCommentDefineType('sps_block', '* %s.' )
call TCommentDefineType('tcl', '# %s' )
call TCommentDefineType('tex', '%% %s' )
call TCommentDefineType('tpl', '<!-- %s -->' )
@ -151,6 +167,7 @@ call TCommentDefineType('viki', '%% %s' )
call TCommentDefineType('viki_3', '%%%%%% %s' )
call TCommentDefineType('viki_inline', '{cmt: %s}' )
call TCommentDefineType('vim', '" %s' )
call TCommentDefineType('vim_3', '""" %s' )
call TCommentDefineType('websec', '# %s' )
call TCommentDefineType('xml', '<!-- %s -->' )
call TCommentDefineType('xml_inline', g:tcommentInlineXML)
@ -162,7 +179,7 @@ call TCommentDefineType('yaml', '# %s' )
let s:tcommentFileTypesDirty = 1
fun! s:DefaultValue(option)
function! s:DefaultValue(option)
exec 'let '. a:option .' = &'. a:option
exec 'set '. a:option .'&'
exec 'let default = &'. a:option
@ -180,22 +197,23 @@ let s:nullCommentString = '%s'
" B ... block
" I ... inline
" R ... right
fun! TComment(beg, end, ...)
function! TComment(beg, end, ...)
" save the cursor position
let co = col('.')
let li = line('.')
let s:pos_end = getpos("'>")
let commentMode = a:0 >= 1 ? a:1 : 'G'
let commentAnyway = a:0 >= 2 ? (a:2 == '!') : 0
if commentMode ==# 'IG'
let commentMode = line("'<") == line("'>") ? 'I' : 'G'
if commentMode =~# 'i'
let commentMode = substitute(commentMode, '\Ci', line("'<") == line("'>") ? 'I' : 'G', 'g')
endif
if commentMode ==# 'R' || commentMode ==# 'I'
if commentMode =~# 'R' || commentMode =~# 'I'
let cstart = col("'<")
if cstart == 0
let cstart = col('.')
endif
if commentMode ==# 'R'
let commentMode = 'G'
if commentMode =~# 'R'
let commentMode = substitute(commentMode, '\CR', 'G', 'g')
let cend = 0
else
let cend = col("'>")
@ -204,6 +222,7 @@ fun! TComment(beg, end, ...)
let cstart = 0
let cend = 0
endif
" TLogVAR commentMode, cstart, cend
" get the correct commentstring
if a:0 >= 3 && a:3 != ''
let cms = s:EncodeCommentPart(a:3) .'%s'
@ -211,7 +230,7 @@ fun! TComment(beg, end, ...)
let cms = cms . s:EncodeCommentPart(a:4)
endif
else
exec s:GetCommentString(a:beg, a:end, commentMode)
let [cms, commentMode] = s:GetCommentString(a:beg, a:end, commentMode)
endif
let cms0 = s:BlockGetCommentString(cms)
let cms0 = escape(cms0, '\')
@ -221,14 +240,15 @@ fun! TComment(beg, end, ...)
" turn commentstring into a search pattern
let cmtCheck = s:SPrintF(cmtCheck, '\(\_.\{-}\)')
" set commentMode and indentStr
exec s:CommentDef(a:beg, a:end, cmtCheck, commentMode, cstart, cend)
let [indentStr, uncomment] = s:CommentDef(a:beg, a:end, cmtCheck, commentMode, cstart, cend)
" TLogVAR indentStr, uncomment
if commentAnyway
let mode = 0
let uncomment = 0
endif
" go
if commentMode ==# 'B'
if commentMode =~# 'B'
" We want a comment block
call s:CommentBlock(a:beg, a:end, mode, cmtCheck, cms, indentStr)
call s:CommentBlock(a:beg, a:end, uncomment, cmtCheck, cms, indentStr)
else
" We want commented lines
" final search pattern for uncommenting
@ -237,11 +257,16 @@ fun! TComment(beg, end, ...)
let cmtReplace = escape(cms0, '"/')
silent exec a:beg .','. a:end .'s/\V'.
\ s:StartRx(cstart) . indentStr .'\zs\(\.\*\)'. s:EndRx(cend) .'/'.
\ '\=s:ProcessedLine('. mode .', submatch(0), "'. cmtCheck .'", "'. cmtReplace .'")/ge'
\ '\=s:ProcessedLine('. uncomment .', submatch(0), "'. cmtCheck .'", "'. cmtReplace .'")/ge'
endif
" reposition cursor
" silent exec 'norm! '. li .'G'. co .'|'
call cursor(li, co)
" TLogVAR commentMode
if commentMode =~ '>'
call setpos('.', s:pos_end)
else
" TLogVAR li, co
call cursor(li, co)
endif
endf
" :line1,line2 TComment ?commentBegin ?commentEnd
@ -257,10 +282,68 @@ command! -bang -range -nargs=* TCommentBlock keepjumps call TComment(<line1>, <l
command! -bang -range -nargs=* TCommentInline keepjumps call TComment(<line1>, <line2>, 'I', "<bang>", <f-args>)
" :line1,line2 TCommentMaybeInline ?commentBegin ?commentEnd
command! -bang -range -nargs=* TCommentMaybeInline keepjumps call TComment(<line1>, <line2>, 'IG', "<bang>", <f-args>)
command! -bang -range -nargs=* TCommentMaybeInline keepjumps call TComment(<line1>, <line2>, 'i', "<bang>", <f-args>)
function! TCommentOperator(type, ...) "{{{3
let commentMode = a:0 >= 1 ? a:1 : ''
let bang = a:0 >= 2 ? a:2 : ''
let sel_save = &selection
let &selection = "inclusive"
let reg_save = @@
" let pos = getpos('.')
" TLogVAR a:type
try
if a:type == 'line'
silent exe "normal! '[V']"
let commentMode1 = 'G'
elseif a:type == 'block'
silent exe "normal! `[\<C-V>`]"
let commentMode1 = 'I'
else
silent exe "normal! `[v`]"
let commentMode1 = 'i'
endif
if empty(commentMode)
let commentMode = commentMode1
endif
let beg = line("'[")
let end = line("']")
norm! 
let commentMode .= g:tcommentOpModeExtra
call TComment(beg, end, commentMode, bang)
finally
let &selection = sel_save
let @@ = reg_save
if g:tcommentOpModeExtra !~ '>'
" TLogVAR pos
" call setpos('.', pos)
call setpos('.', w:tcommentPos)
unlet! w:tcommentPos
endif
endtry
endf
function! TCommentOperatorLine(type) "{{{3
call TCommentOperator(a:type, 'G')
endf
function! TCommentOperatorAnyway(type) "{{{3
call TCommentOperator(a:type, '', '!')
endf
function! TCommentOperatorLineAnyway(type) "{{{3
call TCommentOperator(a:type, 'G', '!')
endf
" comment text as if it were of a specific filetype
fun! TCommentAs(beg, end, commentAnyway, filetype)
function! TCommentAs(beg, end, commentAnyway, filetype, ...)
let ccount = a:0 >= 1 ? a:1 : 1
" TLogVAR ccount
if a:filetype =~ '_block$'
let commentMode = 'B'
let ft = substitute(a:filetype, '_block$', '', '')
@ -271,23 +354,36 @@ fun! TCommentAs(beg, end, commentAnyway, filetype)
let commentMode = 'G'
let ft = a:filetype
endif
exec s:GetCommentString(a:beg, a:end, commentMode, ft)
let pre = substitute(cms, '%s.*$', '', '')
let [cms, commentMode] = s:GetCommentString(a:beg, a:end, commentMode, ft)
let pre = substitute(cms, '%s.*$', '', '')
let pre = substitute(pre, '%%', '%', 'g')
let post = substitute(cms, '^.\{-}%s', '', '')
let post = substitute(post, '%%', '%', 'g')
call TComment(a:beg, a:end, commentMode, a:commentAnyway, pre, post)
if ccount > 1
let pre_l = matchlist(pre, '^\(\S\+\)\(.*\)$')
" TLogVAR pre_l
if !empty(get(pre_l, 1))
let pre = repeat(pre_l[1], ccount) . pre_l[2]
endif
let post_l = matchlist(post, '^\(\s*\)\(.\+\)$')
" TLogVAR post_l
if !empty(get(post_l, 2))
let post = post_l[1] . repeat(post_l[2], ccount)
endif
endif
keepjumps call TComment(a:beg, a:end, commentMode, a:commentAnyway, pre, post)
endf
" :line1,line2 TCommentAs commenttype
command! -bang -complete=custom,TCommentFileTypes -range -nargs=1 TCommentAs
command! -bang -complete=custom,TCommentFileTypes -range -nargs=+ TCommentAs
\ call TCommentAs(<line1>, <line2>, "<bang>", <f-args>)
if (g:tcommentMapLeader1 != '')
exec 'noremap <silent> '. g:tcommentMapLeader1 .'<c-_> :TComment<cr>'
exec 'vnoremap <silent> '. g:tcommentMapLeader1 .'<c-_> :TCommentMaybeInline<cr>'
exec 'inoremap <silent> '. g:tcommentMapLeader1 .'<c-_> <c-o>:TComment<cr>'
exec 'noremap <silent> '. g:tcommentMapLeader1 .'p vip:TComment<cr>'
exec 'noremap <silent> '. g:tcommentMapLeader1 .'p m`vip:TComment<cr>``'
exec 'inoremap <silent> '. g:tcommentMapLeader1 .'p <c-o>:norm! m`vip<cr>:TComment<cr><c-o>``'
exec 'noremap '. g:tcommentMapLeader1 .'<space> :TComment '
exec 'inoremap '. g:tcommentMapLeader1 .'<space> <c-o>:TComment '
exec 'inoremap <silent> '. g:tcommentMapLeader1 .'r <c-o>:TCommentRight<cr>'
@ -298,6 +394,8 @@ if (g:tcommentMapLeader1 != '')
exec 'inoremap '. g:tcommentMapLeader1 .'b <c-o>:TCommentBlock<cr>'
exec 'noremap '. g:tcommentMapLeader1 .'a :TCommentAs '
exec 'inoremap '. g:tcommentMapLeader1 .'a <c-o>:TCommentAs '
exec 'noremap '. g:tcommentMapLeader1 .'n :TCommentAs <c-r>=&ft<cr> '
exec 'inoremap '. g:tcommentMapLeader1 .'n <c-o>:TCommentAs <c-r>=&ft<cr> '
exec 'noremap '. g:tcommentMapLeader1 .'s :TCommentAs <c-r>=&ft<cr>_'
exec 'inoremap '. g:tcommentMapLeader1 .'s <c-o>:TCommentAs <c-r>=&ft<cr>_'
endif
@ -311,13 +409,22 @@ if (g:tcommentMapLeader2 != '')
exec 'vnoremap <silent> '. g:tcommentMapLeader2 .'r :TCommentRight<cr>'
exec 'noremap '. g:tcommentMapLeader2 .'b :TCommentBlock<cr>'
exec 'noremap '. g:tcommentMapLeader2 .'a :TCommentAs '
exec 'noremap '. g:tcommentMapLeader2 .'n :TCommentAs <c-r>=&ft<cr> '
exec 'noremap '. g:tcommentMapLeader2 .'s :TCommentAs <c-r>=&ft<cr>_'
endif
if (g:tcommentMapLeaderOp1 != '')
exec 'noremap <silent> '. g:tcommentMapLeaderOp1 .' :let w:tcommentPos = getpos(".") \| set opfunc=TCommentOperator<cr>g@'
exec 'noremap <silent> '. g:tcommentMapLeaderOp1 .'c :let w:tcommentPos = getpos(".") \| set opfunc=TCommentOperatorLine<cr>g@$'
endif
if (g:tcommentMapLeaderOp2 != '')
exec 'noremap <silent> '. g:tcommentMapLeaderOp2 .' :let w:tcommentPos = getpos(".") \| set opfunc=TCommentOperatorAnyway<cr>g@'
exec 'noremap <silent> '. g:tcommentMapLeaderOp2 .'c :let w:tcommentPos = getpos(".") \| set opfunc=TCommentOperatorLineAnyway<cr>g@$'
endif
" ----------------------------------------------------------------
" collect all variables matching ^tcomment_
fun! TCommentCollectFileTypes()
function! TCommentCollectFileTypes()
if s:tcommentFileTypesDirty
let t = @t
try
@ -338,7 +445,7 @@ endf
call TCommentCollectFileTypes()
" return a list of filetypes for which a tcomment_{&ft} is defined
fun! TCommentFileTypes(ArgLead, CmdLine, CursorPos)
function! TCommentFileTypes(ArgLead, CmdLine, CursorPos)
call TCommentCollectFileTypes()
if a:ArgLead == ''
return &filetype ."\n". g:tcommentFileTypes
@ -347,16 +454,15 @@ fun! TCommentFileTypes(ArgLead, CmdLine, CursorPos)
endif
endf
fun! s:EncodeCommentPart(string)
function! s:EncodeCommentPart(string)
return substitute(a:string, '%', '%%', 'g')
endf
" s:GetCommentString(beg, end, commentMode, ?filetype="")
" => RecordCMS
fun! s:GetCommentString(beg, end, commentMode, ...)
function! s:GetCommentString(beg, end, commentMode, ...)
let ft = a:0 >= 1 ? a:1 : ''
if ft != ''
exec s:GetCustomCommentString(ft, a:commentMode)
let [cms, commentMode] = s:GetCustomCommentString(ft, a:commentMode)
else
let cms = ''
let commentMode = a:commentMode
@ -383,12 +489,12 @@ fun! s:GetCommentString(beg, end, commentMode, ...)
return s:GetCustomCommentString(&filetype, a:commentMode, s:GuessCurrentCommentString(a:commentMode))
endif
endif
return s:RecordCMS(cms, commentMode)
return [cms, commentMode]
endf
" s:SPrintF(formatstring, ?values ...)
" => string
fun! s:SPrintF(string, ...)
function! s:SPrintF(string, ...)
let n = 1
let r = ''
let s = a:string
@ -421,7 +527,7 @@ fun! s:SPrintF(string, ...)
endwh
endf
fun! s:StartRx(pos)
function! s:StartRx(pos)
if a:pos == 0
return '\^'
else
@ -429,7 +535,7 @@ fun! s:StartRx(pos)
endif
endf
fun! s:EndRx(pos)
function! s:EndRx(pos)
if a:pos == 0
return '\$'
else
@ -437,18 +543,18 @@ fun! s:EndRx(pos)
endif
endf
fun! s:GetIndentString(line, start)
function! s:GetIndentString(line, start)
let start = a:start > 0 ? a:start - 1 : 0
return substitute(strpart(getline(a:line), start), '\V\^\s\*\zs\.\*\$', '', '')
endf
fun! s:CommentDef(beg, end, checkRx, commentMode, cstart, cend)
function! s:CommentDef(beg, end, checkRx, commentMode, cstart, cend)
let mdrx = '\V'. s:StartRx(a:cstart) .'\s\*'. a:checkRx .'\s\*'. s:EndRx(0)
let line = getline(a:beg)
if a:cstart != 0 && a:cend != 0
let line = strpart(line, 0, a:cend - 1)
endif
let mode = (line =~ mdrx)
let uncomment = (line =~ mdrx)
let it = s:GetIndentString(a:beg, a:cstart)
let il = indent(a:beg)
let n = a:beg + 1
@ -459,50 +565,52 @@ fun! s:CommentDef(beg, end, checkRx, commentMode, cstart, cend)
let it = s:GetIndentString(n, a:cstart)
let il = jl
endif
if a:commentMode ==# 'G'
if a:commentMode =~# 'G'
if !(getline(n) =~ mdrx)
let mode = 0
let uncomment = 0
endif
endif
endif
let n = n + 1
endwh
if a:commentMode ==# 'B'
if a:commentMode =~# 'B'
let t = @t
try
silent exec 'norm! '. a:beg.'G1|v'.a:end.'G$"ty'
let mode = (@t =~ mdrx)
let uncomment = (@t =~ mdrx)
finally
let @t = t
endtry
endif
return 'let indentStr="'. it .'" | let mode='. mode
return [it, uncomment]
endf
fun! s:ProcessedLine(mode, match, checkRx, replace)
function! s:ProcessedLine(uncomment, match, checkRx, replace)
if !(a:match =~ '\S' || g:tcommentBlankLines)
return a:match
endif
if a:mode
" uncomment
let ml = len(a:match)
if a:uncomment
let rv = substitute(a:match, a:checkRx, '\1\2', '')
else
" comment
let rv = s:SPrintF(a:replace, a:match)
endif
" let md = len(rv) - ml
let s:pos_end = getpos('.')
let s:pos_end[2] += len(rv)
" TLogVAR pe, md, a:match
let rv = escape(rv, '\ ')
let rv = substitute(rv, '\n', '\\\n', 'g')
return rv
endf
fun! s:CommentBlock(beg, end, mode, checkRx, replace, indentStr)
function! s:CommentBlock(beg, end, uncomment, checkRx, replace, indentStr)
let t = @t
try
silent exec 'norm! '. a:beg.'G1|v'.a:end.'G$"td'
let ms = s:BlockGetMiddleString(a:replace)
let mx = escape(ms, '\')
if a:mode
" uncomment
if a:uncomment
let @t = substitute(@t, '\V\^\s\*'. a:checkRx .'\$', '\1', '')
if ms != ''
let @t = substitute(@t, '\V\n'. a:indentStr . mx, '\n'. a:indentStr, 'g')
@ -510,7 +618,6 @@ fun! s:CommentBlock(beg, end, mode, checkRx, replace, indentStr)
let @t = substitute(@t, '^\n', '', '')
let @t = substitute(@t, '\n\s*$', '', '')
else
" comment
let cs = s:BlockGetCommentString(a:replace)
let cs = a:indentStr . substitute(cs, '%s', '%s'. a:indentStr, '')
if ms != ''
@ -530,15 +637,14 @@ endf
" inspired by Meikel Brandmeyer's EnhancedCommentify.vim
" this requires that a syntax names are prefixed by the filetype name
" s:GuessFileType(beg, end, commentMode, filetype, ?fallbackFiletype)
" => RecordCMS
fun! s:GuessFileType(beg, end, commentMode, filetype, ...)
function! s:GuessFileType(beg, end, commentMode, filetype, ...)
if a:0 >= 1 && a:1 != ''
exec s:GetCustomCommentString(a:1, a:commentMode)
let [cms, commentMode] = s:GetCustomCommentString(a:1, a:commentMode)
if cms == ''
let cms = s:GuessCurrentCommentString(a:commentMode)
endif
else
let commentMode = 'G'
let commentMode = s:CommentMode(a:commentMode, 'G')
let cms = s:GuessCurrentCommentString(0)
endif
let n = a:beg
@ -547,7 +653,10 @@ fun! s:GuessFileType(beg, end, commentMode, filetype, ...)
let le = col('$')
while m < le
let syntaxName = synIDattr(synID(n, m, 1), 'name')
if syntaxName =~ g:tcommentFileTypesRx
let ftypeMap = get(g:tcommentSyntaxMap, syntaxName)
if !empty(ftypeMap)
return s:GetCustomCommentString(ftypeMap, a:commentMode, cms)
elseif syntaxName =~ g:tcommentFileTypesRx
let ft = substitute(syntaxName, g:tcommentFileTypesRx, '\1', '')
if exists('g:tcommentIgnoreTypes_'. a:filetype) && g:tcommentIgnoreTypes_{a:filetype} =~ '\<'.ft.'\>'
let m = m + 1
@ -562,10 +671,14 @@ fun! s:GuessFileType(beg, end, commentMode, filetype, ...)
endwh
let n = n + 1
endwh
return s:RecordCMS(cms, commentMode)
return [cms, commentMode]
endf
fun! s:GuessCurrentCommentString(commentMode)
function! s:CommentMode(commentMode, newmode) "{{{3
return substitute(a:commentMode, '\w\+', a:newmode, 'g')
endf
function! s:GuessCurrentCommentString(commentMode)
let valid_cms = (stridx(&commentstring, '%s') != -1)
if &commentstring != s:defaultCommentString && valid_cms
" The &commentstring appears to have been set and to be valid
@ -589,9 +702,9 @@ fun! s:GuessCurrentCommentString(commentMode)
endif
endf
fun! s:ConstructFromComments(commentMode)
function! s:ConstructFromComments(commentMode)
exec s:ExtractCommentsPart('')
if a:commentMode == 'G' && line != ''
if a:commentMode =~# 'G' && line != ''
return line .' %s'
endif
exec s:ExtractCommentsPart('s')
@ -614,7 +727,7 @@ fun! s:ConstructFromComments(commentMode)
endif
endf
fun! s:ExtractCommentsPart(key)
function! s:ExtractCommentsPart(key)
" let key = a:key != "" ? a:key .'[^:]*' : ""
let key = a:key . '[bnflrxO0-9-]*'
let val = substitute(&comments, '^\(.\{-},\)\{-}'. key .':\([^,]\+\).*$', '\2', '')
@ -628,36 +741,31 @@ fun! s:ExtractCommentsPart(key)
endf
" s:GetCustomCommentString(ft, commentMode, ?default="")
" => RecordCMS
fun! s:GetCustomCommentString(ft, commentMode, ...)
function! s:GetCustomCommentString(ft, commentMode, ...)
let commentMode = a:commentMode
let customComment = exists('g:tcomment_'. a:ft)
if commentMode ==# 'B' && exists('g:tcomment_'. a:ft .'_block')
if commentMode =~# 'B' && exists('g:tcomment_'. a:ft .'_block')
let cms = g:tcomment_{a:ft}_block
elseif commentMode ==# 'I' && exists('g:tcomment_'. a:ft .'_inline')
elseif commentMode =~? 'I' && exists('g:tcomment_'. a:ft .'_inline')
let cms = g:tcomment_{a:ft}_inline
elseif customComment
let cms = g:tcomment_{a:ft}
let commentMode = 'G'
let commentMode = s:CommentMode(commentMode, 'G')
elseif a:0 >= 1
let cms = a:1
let commentMode = 'G'
let commentMode = s:CommentMode(commentMode, 'G')
else
let cms = ''
let commentMode = 'G'
let commentMode = s:CommentMode(commentMode, 'G')
endif
return s:RecordCMS(cms, commentMode)
return [cms, commentMode]
endf
fun! s:RecordCMS(cms, commentMode)
return 'let cms="'. escape(a:cms, '"') .'" | let commentMode="'. a:commentMode .'"'
endf
fun! s:BlockGetCommentString(cms)
function! s:BlockGetCommentString(cms)
return substitute(a:cms, '\n.*$', '', '')
endf
fun! s:BlockGetMiddleString(cms)
function! s:BlockGetMiddleString(cms)
let rv = substitute(a:cms, '^.\{-}\n\([^\n]*\)', '\1', '')
return rv == a:cms ? '' : rv
endf
@ -724,3 +832,18 @@ code you have to use TCommentAs
- Made key maps configurable via g:tcommentMapLeader1 and
g:tcommentMapLeader2
1.7
- gc{motion} (see g:tcommentMapLeaderOp1) functions as a comment toggle
operator (i.e., something like gcl... works, mostly); gC{motion} (see
g:tcommentMapLeaderOp2) will unconditionally comment the text.
- TCommentAs takes an optional second argument (the comment level)
- New "n" map: TCommentAs &filetype [COUNT]
- Defined mail comments/citations
- g:tcommentSyntaxMap: Map syntax names to filetypes for buffers with
mixed syntax groups that don't match the filetypeEmbeddedsyntax scheme (e.g.
'vimRubyRegion', which should be commented as ruby syntax, not as vim
syntax)
- FIX: Comments in vim*Region
- TComment: The use of the type argument has slightly changed (IG -> i,
new: >)

View File

@ -0,0 +1,76 @@
" Author: Michael Geddes ( vimmer at frog.wheelycreek.net )
"
" Created for zimnyx on IRC
" Version:0.2
"
" Do a global search replace on a directory.
"
"
" Copyright: Copyright me. Feel free to use, share, modify & distribute the
" script but acknowledge me please.
"
" vim: ts=2 sw=2 et
fun! GlobSearchReplace( fileglob, sub, rep, flag)
let v:errmsg=''
exe 'vimgrep /'.escape(a:sub,'/').'/ '.a:fileglob
if v:errmsg != '' | return 0 | endif
let countup=0
let more=1
while 1
silent exe 's/'.escape(a:sub, '/').'/'.escape(a:rep,'/').'/'.a:flag
let countup+=1
try
silent cnext
catch
if v:exception !~ 'E553:' | echoerr v:exception | endif
break
endtry
endwhile
return countup
endfun
fun! s:CallGlobReplace(str)
if strlen(a:str) == 0
echoerr 'Usage: /sub/rep/flags files'
return 0
endif
let firstch= a:str[0]
let argidx=0
let arg0=''
let arg1=''
let argflags=''
let argfileglob=''
let idx=1
let str=a:str
while idx < strlen(str)
let ch=str[idx]
if ch=='\' && idx+1 < strlen(str) && str[idx+1] == firstch
let str=str[0:idx].str[idx+1:]
elseif ch==firstch
let arg{argidx}=str[1:idx-1]
let argidx+=1
let str=str[idx : ]
let idx=0
if argidx==2
break
endif
endif
let idx+=1
endwhile
if argidx == 2
echo ' argidx=2'
let idx+=1
while idx < strlen(str)
if str[idx]=~'\s'
let idx+=1
break
endif
let argflags=argflags.str[idx]
let idx+=1
endwhile
let argfileglob=str[idx : ]
endif
call GlobSearchReplace( argfileglob, arg0, arg1, argflags)
endfun
com! -nargs=1 Gsub :call s:CallGlobReplace(<q-args>)

View File

@ -1,71 +1,73 @@
" Language : Netrw Remote-Directory Listing Syntax
" Maintainer : Charles E. Campbell, Jr.
" Last change: Nov 27, 2006
" Version : 9
" ---------------------------------------------------------------------
" Syntax Clearing: {{{1
if version < 600
syntax clear
elseif exists("b:current_syntax")
finish
endif
" ---------------------------------------------------------------------
" Directory List Syntax Highlighting: {{{1
syn cluster NetrwGroup contains=netrwHide,netrwSortBy,netrwSortSeq,netrwQuickHelp,netrwVersion
syn match netrwSpecial "\%(\S\+ \)*\S\+[*|=]\ze\%(\s\{2,}\|$\)" contains=netrwClassify
syn match netrwDir "\.\{1,2}/" contains=netrwClassify
syn match netrwDir "\%(\S\+ \)*\S\+/" contains=netrwClassify
syn match netrwDir "^\S*/" contains=netrwClassify
syn match netrwSizeDate "\<\d\+\s\d\{1,2}/\d\{1,2}/\d\{4}\s" contains=netrwDateSep skipwhite nextgroup=netrwTime
syn match netrwSymLink "\%(\S\+ \)*\S\+@\ze\%(\s\{2,}\|$\)" contains=netrwClassify
syn match netrwExe "\%(\S\+ \)*\S\+\*\ze\%(\s\{2,}\|$\)" contains=netrwClassify,netrwTreeIgnore
syn match netrwTreeIgnore contained "^\%(| \)*"
syn match netrwClassify "[*=|@/]\ze\%(\s\{2,}\|$\)" contained
syn match netrwDateSep "/" contained
syn match netrwTime "\d\{1,2}:\d\{2}:\d\{2}" contained contains=netrwTimeSep
syn match netrwTimeSep ":"
syn match netrwComment '".*\%(\t\|$\)' contains=@NetrwGroup
syn match netrwHide '^"\s*\(Hid\|Show\)ing:' skipwhite nextgroup=netrwHidePat
syn match netrwSlash "/" contained
syn match netrwHidePat "[^,]\+" contained skipwhite nextgroup=netrwHideSep
syn match netrwHideSep "," contained transparent skipwhite nextgroup=netrwHidePat
syn match netrwSortBy "Sorted by" contained transparent skipwhite nextgroup=netrwList
syn match netrwSortSeq "Sort sequence:" contained transparent skipwhite nextgroup=netrwList
syn match netrwList ".*$" contained contains=netrwComma
syn match netrwComma "," contained
syn region netrwQuickHelp matchgroup=Comment start="Quick Help:\s\+" end="$" contains=netrwHelpCmd keepend contained
syn match netrwHelpCmd "\S\ze:" contained skipwhite nextgroup=netrwCmdSep
syn match netrwCmdSep ":" contained nextgroup=netrwCmdNote
syn match netrwCmdNote ".\{-}\ze " contained
syn match netrwVersion "(netrw.*)" contained
" ---------------------------------------------------------------------
" Highlighting Links: {{{1
if !exists("did_drchip_dbg_syntax")
let did_drchip_netrwlist_syntax= 1
hi link netrwClassify Function
hi link netrwCmdSep Delimiter
hi link netrwComment Comment
hi link netrwDir Directory
hi link netrwHelpCmd Function
hi link netrwHidePat Statement
hi link netrwList Statement
hi link netrwVersion Identifier
hi link netrwSymLink Special
hi link netrwExe PreProc
hi link netrwDateSep Delimiter
hi link netrwTimeSep netrwDateSep
hi link netrwComma netrwComment
hi link netrwHide netrwComment
endif
" Current Syntax: {{{1
let b:current_syntax = "netrwlist"
" ---------------------------------------------------------------------
" vim: ts=8 fdm=marker
" Language : Netrw Remote-Directory Listing Syntax
" Maintainer : Charles E. Campbell, Jr.
" Last change: Aug 08, 2007
" Version : 10
" ---------------------------------------------------------------------
" Syntax Clearing: {{{1
if version < 600
syntax clear
elseif exists("b:current_syntax")
finish
endif
" ---------------------------------------------------------------------
" Directory List Syntax Highlighting: {{{1
syn cluster NetrwGroup contains=netrwHide,netrwSortBy,netrwSortSeq,netrwQuickHelp,netrwVersion,netrwCopyTgt
syn match netrwSpecial "\%(\S\+ \)*\S\+[*|=]\ze\%(\s\{2,}\|$\)" contains=netrwClassify
syn match netrwDir "\.\{1,2}/" contains=netrwClassify
syn match netrwDir "\%(\S\+ \)*\S\+/" contains=netrwClassify
syn match netrwDir "^\S*/" contains=netrwClassify
syn match netrwSizeDate "\<\d\+\s\d\{1,2}/\d\{1,2}/\d\{4}\s" contains=netrwDateSep skipwhite nextgroup=netrwTime
syn match netrwSymLink "\%(\S\+ \)*\S\+@\ze\%(\s\{2,}\|$\)" contains=netrwClassify
syn match netrwExe "\%(\S\+ \)*\S\+\*\ze\%(\s\{2,}\|$\)" contains=netrwClassify,netrwTreeIgnore
syn match netrwTreeIgnore contained "^\%(| \)*"
syn match netrwClassify "[*=|@/]\ze\%(\s\{2,}\|$\)" contained
syn match netrwDateSep "/" contained
syn match netrwTime "\d\{1,2}:\d\{2}:\d\{2}" contained contains=netrwTimeSep
syn match netrwTimeSep ":"
syn match netrwComment '".*\%(\t\|$\)' contains=@NetrwGroup
syn match netrwHide '^"\s*\(Hid\|Show\)ing:' skipwhite nextgroup=netrwHidePat
syn match netrwSlash "/" contained
syn match netrwHidePat "[^,]\+" contained skipwhite nextgroup=netrwHideSep
syn match netrwHideSep "," contained transparent skipwhite nextgroup=netrwHidePat
syn match netrwSortBy "Sorted by" contained transparent skipwhite nextgroup=netrwList
syn match netrwSortSeq "Sort sequence:" contained transparent skipwhite nextgroup=netrwList
syn match netrwCopyTgt "Copy/Move Tgt:" contained transparent skipwhite nextgroup=netrwList
syn match netrwList ".*$" contained contains=netrwComma
syn match netrwComma "," contained
syn region netrwQuickHelp matchgroup=Comment start="Quick Help:\s\+" end="$" contains=netrwHelpCmd keepend contained
syn match netrwHelpCmd "\S\ze:" contained skipwhite nextgroup=netrwCmdSep
syn match netrwCmdSep ":" contained nextgroup=netrwCmdNote
syn match netrwCmdNote ".\{-}\ze " contained
syn match netrwVersion "(netrw.*)" contained
" ---------------------------------------------------------------------
" Highlighting Links: {{{1
if !exists("did_drchip_dbg_syntax")
let did_drchip_netrwlist_syntax= 1
hi link netrwClassify Function
hi link netrwCmdSep Delimiter
hi link netrwComment Comment
hi link netrwDir Directory
hi link netrwHelpCmd Function
hi link netrwHidePat Statement
hi link netrwList Statement
hi link netrwVersion Identifier
hi link netrwSymLink Special
hi link netrwExe PreProc
hi link netrwDateSep Delimiter
hi link netrwTimeSep netrwDateSep
hi link netrwComma netrwComment
hi link netrwHide netrwComment
hi link netrwMarkFile Identifier
endif
" Current Syntax: {{{1
let b:current_syntax = "netrwlist"
" ---------------------------------------------------------------------
" vim: ts=8 fdm=marker