BlockDiff replaced by LineDiff

Update VisIncr


git-svn-id: https://vimsuite.svn.sourceforge.net/svnroot/vimsuite/trunk@212 eb2d0018-73a3-4aeb-bfe9-1def61c9ec69
This commit is contained in:
alterdepp 2011-09-27 13:32:16 +00:00
parent 4eea06e04a
commit ec0033810f
10 changed files with 1122 additions and 674 deletions

View File

@ -4,7 +4,7 @@ ScriptID SourceID Filename
1009 3119 srec.vim (syntax file)
475 2535 latex-suite (install in vimfiles.latex)
614 3666 C-Referenz
670 8073 visincr.vim (Visual Increment)
670 16281 visincr.vim (Visual Increment)
862 2635 cscope_quickfix.vim
51 171 cscope_macros.vim
102 16171 DirDiff.vim
@ -19,7 +19,7 @@ ScriptID SourceID Filename
1046 4249 Lusty Explorer
2043 7805 VimPdb (debugging python)
1776 7902 Vimgrep Replace
2048 7817 BlockDiff
3745 16527 LineDiff
39 8196 matchit.vim
2092 8095 reloaded.vim (matrix colorscheme)
848 14668 SrchRplcHiGrp.vim (Search/Replace on Syntax Group)

View File

@ -0,0 +1,167 @@
" Constructs a Differ object that is still unbound. To initialize the object
" with data, `Init(from, to)` needs to be invoked on that object.
function! linediff#differ#New(sign_name, sign_number)
let differ = {
\ 'original_buffer': -1,
\ 'diff_buffer': -1,
\ 'filetype': '',
\ 'from': -1,
\ 'to': -1,
\ 'sign_name': a:sign_name,
\ 'sign_number': a:sign_number,
\ 'sign_text': a:sign_number.'-',
\ 'is_blank': 1,
\ 'other_differ': {},
\
\ 'Init': function('linediff#differ#Init'),
\ 'IsBlank': function('linediff#differ#IsBlank'),
\ 'Reset': function('linediff#differ#Reset'),
\ 'Lines': function('linediff#differ#Lines'),
\ 'CreateDiffBuffer': function('linediff#differ#CreateDiffBuffer'),
\ 'SetupDiffBuffer': function('linediff#differ#SetupDiffBuffer'),
\ 'CloseDiffBuffer': function('linediff#differ#CloseDiffBuffer'),
\ 'UpdateOriginalBuffer': function('linediff#differ#UpdateOriginalBuffer'),
\ 'PossiblyUpdateOtherDiffer': function('linediff#differ#PossiblyUpdateOtherDiffer'),
\ 'SetupSigns': function('linediff#differ#SetupSigns')
\ }
exe "sign define ".differ.sign_name." text=".differ.sign_text." texthl=Search"
return differ
endfunction
" Sets up the Differ with data from the argument list and from the current
" file.
function! linediff#differ#Init(from, to) dict
let self.original_buffer = bufnr('%')
let self.filetype = &filetype
let self.from = a:from
let self.to = a:to
call self.SetupSigns()
let self.is_blank = 0
endfunction
" Returns true if the differ is blank, which means not initialized with data.
function! linediff#differ#IsBlank() dict
return self.is_blank
endfunction
" Resets the differ to the blank state. Invoke `Init(from, to)` on it later to
" make it usable again.
function! linediff#differ#Reset() dict
call self.CloseDiffBuffer()
let self.original_buffer = -1
let self.diff_buffer = -1
let self.filetype = ''
let self.from = -1
let self.to = -1
let self.other_differ = {}
exe "sign unplace ".self.sign_number."1"
exe "sign unplace ".self.sign_number."2"
let self.is_blank = 1
endfunction
" Extracts the relevant lines from the original buffer and returns them as a
" list.
function! linediff#differ#Lines() dict
return getbufline(self.original_buffer, self.from, self.to)
endfunction
" Creates the buffer used for the diffing and connects it to this differ
" object.
function! linediff#differ#CreateDiffBuffer(edit_command) dict
let lines = self.Lines()
let temp_file = tempname()
exe a:edit_command . " " . temp_file
call append(0, lines)
normal! Gdd
set nomodified
let self.diff_buffer = bufnr('%')
call self.SetupDiffBuffer()
diffthis
endfunction
" Sets up the temporary buffer's filetype and statusline.
"
" Attempts to leave the current statusline as it is, and simply add the
" relevant information in the place of the current filename. If that fails,
" replaces the whole statusline.
function! linediff#differ#SetupDiffBuffer() dict
let b:differ = self
let statusline = printf('[%s:%%{b:differ.from}-%%{b:differ.to}]', bufname(self.original_buffer))
if &statusline =~ '%f'
let statusline = substitute(&statusline, '%f', statusline, '')
endif
exe "setlocal statusline=" . escape(statusline, ' ')
exe "set filetype=" . self.filetype
setlocal bufhidden=hide
autocmd BufWrite <buffer> silent call b:differ.UpdateOriginalBuffer()
endfunction
function! linediff#differ#CloseDiffBuffer() dict
exe "bdelete ".self.diff_buffer
endfunction
function! linediff#differ#SetupSigns() dict
exe "sign unplace ".self.sign_number."1"
exe "sign unplace ".self.sign_number."2"
exe printf("sign place %d1 name=%s line=%d buffer=%d", self.sign_number, self.sign_name, self.from, self.original_buffer)
exe printf("sign place %d2 name=%s line=%d buffer=%d", self.sign_number, self.sign_name, self.to, self.original_buffer)
endfunction
" Updates the original buffer after saving the temporary one. It might also
" update the other differ's data, provided a few conditions are met. See
" linediff#differ#PossiblyUpdateOtherDiffer() for details.
function! linediff#differ#UpdateOriginalBuffer() dict
let new_lines = getbufline('%', 0, '$')
" Switch to the original buffer, delete the relevant lines, add the new
" ones, switch back to the diff buffer.
call linediff#util#SwitchBuffer(self.original_buffer)
let saved_cursor = getpos('.')
call cursor(self.from, 1)
exe "normal! ".(self.to - self.from + 1)."dd"
call append(self.from - 1, new_lines)
call setpos('.', saved_cursor)
call linediff#util#SwitchBuffer(self.diff_buffer)
" Keep the difference in lines to know how to update the other differ if
" necessary.
let line_count = self.to - self.from + 1
let new_line_count = len(new_lines)
let self.to = self.from + len(new_lines) - 1
call self.SetupDiffBuffer()
call self.SetupSigns()
call self.PossiblyUpdateOtherDiffer(new_line_count - line_count)
endfunction
" If the other differ originates from the same buffer and it's located below
" this one, we need to update its starting and ending lines, since any change
" would result in a line shift.
"
" a:delta is the change in the number of lines.
function! linediff#differ#PossiblyUpdateOtherDiffer(delta) dict
let other = self.other_differ
if self.original_buffer == other.original_buffer
\ && self.to <= other.from
\ && a:delta != 0
let other.from = other.from + a:delta
let other.to = other.to + a:delta
call other.SetupSigns()
endif
endfunction

View File

@ -0,0 +1,4 @@
" Helper method to change to a certain buffer.
function! linediff#util#SwitchBuffer(bufno)
exe "buffer ".a:bufno
endfunction

View File

@ -1,7 +1,7 @@
" visincr.vim: Visual-block incremented lists
" Author: Charles E. Campbell, Jr. Ph.D.
" Date: Dec 19, 2007
" Version: 19
" Date: Aug 16, 2011
" Version: 20
"
" Visincr assumes that a block of numbers selected by a
" ctrl-v (visual block) has been selected for incrementing.
@ -25,8 +25,14 @@
if &cp || exists("g:loaded_visincr")
finish
endif
let s:keepcpo = &cpo
let g:loaded_visincr = "v19"
let g:loaded_visincr = "v20"
if v:version < 700
echohl WarningMsg
echo "***warning*** this version of visincr needs vim 7.0"
echohl Normal
finish
endif
let s:keepcpo= &cpo
set cpo&vim
" ---------------------------------------------------------------------
@ -41,28 +47,32 @@ let s:IM = 6
let s:IA = 7
let s:IX = 8
let s:IIX = 9
let s:IO = 10
let s:IIO = 11
let s:IR = 12
let s:IIR = 13
let s:IPOW = 14
let s:IIPOW = 15
let s:RI = 16
let s:RII = 17
let s:RIMDY = 18
let s:RIYMD = 19
let s:RIDMY = 20
let s:RID = 21
let s:RIM = 22
let s:RIA = 23
let s:RIX = 24
let s:RIIX = 25
let s:RIO = 26
let s:RIIO = 27
let s:RIR = 28
let s:RIIR = 29
let s:RIPOW = 30
let s:RIIPOW = 31
let s:IB = 10
let s:IIB = 11
let s:IO = 12
let s:IIO = 13
let s:IR = 14
let s:IIR = 15
let s:IPOW = 16
let s:IIPOW = 17
let s:RI = 18
let s:RII = 19
let s:RIMDY = 20
let s:RIYMD = 21
let s:RIDMY = 22
let s:RID = 23
let s:RIM = 24
let s:RIA = 25
let s:RIX = 26
let s:RIIX = 27
let s:RIB = 28
let s:RIIB = 29
let s:RIO = 30
let s:RIIO = 31
let s:RIR = 32
let s:RIIR = 33
let s:RIPOW = 34
let s:RIIPOW = 35
" ------------------------------------------------------------------------------
" Options: {{{1
@ -104,8 +114,11 @@ fun! visincr#VisBlockIncr(method,...)
" get increment (default=1; except for power increments, that's default=2) {{{3
if a:0 > 0
let incr= a:1
" call Decho("incr<".incr.">")
if method == s:IX || method == s:IIX
let incr= s:Hex2Dec(incr)
elseif method == s:IB || method == s:IIB
let incr= s:Bin2Dec(incr)
elseif method == s:IO || method == s:IIO
let incr= s:Oct2Dec(incr)
endif
@ -123,6 +136,9 @@ fun! visincr#VisBlockIncr(method,...)
let leftcol = virtcol("'>")
let rghtcol = virtcol("'<")
endif
if &selection == "exclusive"
let rghtcol= rghtcol - 1
endif
let width= rghtcol - leftcol + 1
" call Decho("width= [rghtcol=".rghtcol."]-[leftcol=".leftcol."]+1=".width)
@ -168,6 +184,25 @@ fun! visincr#VisBlockIncr(method,...)
endif
" call Decho(":IM restricted<".restrict.">")
elseif a:method == s:RIB
let restrict= '\%'.col(".").'c[01]'
" call Decho(":IB restricted<".restrict.">")
elseif a:method == s:RIIB
let restrict= '\%'.col(".").'c\s\{,'.width.'}[01]'
" call Decho(":IIB restricted<".restrict.">")
elseif a:method == s:RIO
let restrict= '\%'.col(".").'c\o'
" call Decho(":IO restricted<".restrict.">")
elseif a:method == s:RIIO
let restrict= '\%'.col(".").'c\s\{,'.width.'}\o'
" call Decho(":IIB restricted<".restrict.">")
elseif a:method == s:RIX
let restrict= '\%'.col(".").'c\x'
" call Decho(":IX restricted<".restrict.">")
elseif a:method == s:RIIX
let restrict= '\%'.col(".").'c\s\{,'.width.'}\x'
" call Decho(":IIX restricted<".restrict.">")
elseif a:method == s:RIPOW
let restrict= '\%'.col(".").'c\d'
" call Decho(":RIPOW restricted<".restrict.">")
@ -448,7 +483,7 @@ fun! visincr#VisBlockIncr(method,...)
let l = y1
while l <= y2
if exists("restrict") && getline(".") !~ restrict
norm! j
silent! norm! j
let l= l + 1
continue
endif
@ -491,7 +526,7 @@ fun! visincr#VisBlockIncr(method,...)
return
endif " IMDY IYMD IDMY ID IM
" I II IX IIX IO IIO IR IIR IPOW IIPOW: {{{3
" I II IX IIX IB IIB IO IIO IR IIR IPOW IIPOW: {{{3
" construct a line from the first line that only has the number in it
let rml = rghtcol - leftcol
let rmlp1 = rml + 1
@ -523,6 +558,8 @@ fun! visincr#VisBlockIncr(method,...)
" call Decho("handle visblock not at far left")
if method == s:IX || method == s:IIX
let pat = '^\(.\{-}\)\%'.leftcol.'v\([0-9a-fA-F \t]\{1,'.rmlp1.'}\).*$'
elseif method == s:IB || method == s:IIB
let pat = '^\(.\{-}\)\%'.leftcol.'v\([01 \t]\{1,'.rmlp1.'}\).*$'
elseif method == s:IO || method == s:IIO
let pat = '^\(.\{-}\)\%'.leftcol.'v\([0-7 \t]\{1,'.rmlp1.'}\).*$'
elseif method == s:IR || method == s:IIR
@ -543,11 +580,13 @@ fun! visincr#VisBlockIncr(method,...)
let cntlen = strlen(cnt)
let cnt = substitute(cnt,'\s','',"ge")
let ocnt = cnt
" call Decho("cntlen=".cntlen." cnt=".cnt." ocnt=".ocnt." (before I*[XOR] subs)")
" call Decho("cntlen=".cntlen." cnt=".cnt." ocnt=".ocnt." (before I*[BXOR] subs)")
" elide leading zeros
if method == s:IX || method == s:IIX
let cnt= substitute(cnt,'^0*\([1-9a-fA-F]\|0$\)','\1',"ge")
elseif method == s:IB || method == s:IIB
let cnt= substitute(cnt,'^0*\(1\|0$\)','\1',"ge")
elseif method == s:IO || method == s:IIO
let cnt= substitute(cnt,'^0*\([1-7]\|0$\)','\1',"ge")
elseif method == s:IR || method == s:IIR
@ -569,6 +608,8 @@ fun! visincr#VisBlockIncr(method,...)
" determine how much incrementing is needed {{{3
if method == s:IX || method == s:IIX
let maxcnt= s:Dec2Hex(s:Hex2Dec(cnt) + incr*(y2 - y1))
elseif method == s:IB || method == s:IIB
let maxcnt= s:Dec2Bin(s:Bin2Dec(cnt) + incr*(y2 - y1))
elseif method == s:IO || method == s:IIO
let maxcnt= s:Dec2Oct(s:Oct2Dec(cnt) + incr*(y2 - y1))
elseif method == s:IR || method == s:IIR
@ -616,7 +657,7 @@ fun! visincr#VisBlockIncr(method,...)
" call Decho("----- while [l=".l."] <= [y2=".y2."]: cnt=".cnt)
if exists("restrict") && getline(".") !~ restrict
" call Decho("skipping <".getline(".")."> (restrict)")
norm! j
silent! norm! j
let l= l + 1
continue
endif
@ -650,7 +691,7 @@ fun! visincr#VisBlockIncr(method,...)
" back up to left-of-block (plus optional left-hand-side modeling) (left-justification support) {{{3
norm! 0
if method == s:I || method == s:IO || method == s:IX || method == s:IR || method == s:IPOW
if method == s:I || method == s:IB || method == s:IO || method == s:IX || method == s:IR || method == s:IPOW
let bkup= leftcol
" call Decho("bkup= [leftcol=".leftcol."] (due to method)")
elseif maxcntlen > 0
@ -685,6 +726,8 @@ fun! visincr#VisBlockIncr(method,...)
endif
if method == s:IX || method == s:IIX
let cnt= s:Dec2Hex(s:Hex2Dec(cnt) + incr)
elseif method == s:IB || method == s:IIB
let cnt= s:Dec2Bin(s:Bin2Dec(cnt) + incr)
elseif method == s:IO || method == s:IIO
let cnt= s:Dec2Oct(s:Oct2Dec(cnt) + incr)
elseif method == s:IR || method == s:IIR
@ -834,6 +877,63 @@ fun! s:Dec2Oct(b10)
return oct
endfun
" ------------------------------------------------------------------------------
" Bin2Dec: convert binary to decimal {{{2
fun! s:Bin2Dec(bin)
" call Dfunc("Bin2Dec(bin=".a:bin.")")
if a:bin >= 0
let n = a:bin
let neg= 0
else
let n = strpart(a:bin,1)
let neg = 1
endif
let b10 = 0
while n != ""
let bindigit= strpart(n,0,1)
if bindigit =~ '[01]'
let bindigit= char2nr(bindigit) - char2nr('0')
" call Decho("bindigit=".bindigit)
else
break
endif
let b10= 2*b10 + bindigit
let n = strpart(n,1)
endwhile
if neg
let b10= -b10
endif
" call Dret("Bin2Dec ".b10)
return b10
endfun
" ---------------------------------------------------------------------
" Dec2Bin: convert decimal to binary {{{2
fun! s:Dec2Bin(b10)
" call Dfunc("Dec2Bin(b10=".a:b10.")")
if a:b10 >= 0
let b10 = a:b10
let neg = 0
else
let b10 = -a:b10
let neg = 1
endif
let bin = ""
while b10
let bin = '01'[b10 % 2] . bin
let b10 = b10 / 2
endwhile
if neg
let bin= "-".bin
endif
" call Dret("Dec2Bin ".bin)
return bin
endfun
" ------------------------------------------------------------------------------
" Roman Numeral Support: {{{2
let s:d2r= [ [ 1000000 , 'M)' ],[900000 , 'CM)' ], [500000 , 'D)' ], [400000 , 'CD)' ], [100000 , 'C)' ], [90000 , 'XC)' ], [50000 , 'L)' ], [40000 , 'XL)' ], [10000 , 'X)' ], [9000 , 'IX)'], [5000 , 'V)'], [1000 , 'M' ], [900 , 'CM'], [500 , 'D'], [400 , 'CD'], [100 , 'C'], [90 , 'XC'], [50 , 'L'], [40 , 'XL'], [10 , 'X'], [9 , 'IX'], [5 , 'V'], [4 , 'IV'], [1 , 'I'] ]

124
vimfiles/doc/linediff.txt Normal file
View File

@ -0,0 +1,124 @@
==============================================================================
CONTENTS *linediff* *linediff-contents*
Installation...........................: |linediff-installation|
Usage..................................: |linediff-usage|
Commands...............................: |linediff-commands|
Internals..............................: |linediff-internals|
Issues.................................: |linediff-issues|
==============================================================================
INSTALLATION *linediff-installation*
There are several ways to install the plugin. The recommended one is by using
Tim Pope's pathogen (http://www.vim.org/scripts/script.php?script_id=2332). In
that case, you can clone the plugin's git repository like so:
>
git clone git://github.com/AndrewRadev/linediff.vim.git ~/.vim/bundle/linediff
<
If your vim configuration is under git version control, you could also set up
the repository as a submodule, which would allow you to update more easily.
The command is (provided you're in ~/.vim):
>
git submodule add git://github.com/AndrewRadev/linediff.vim.git bundle/linediff
<
Another way is to simply copy all the essential directories inside the ~.vim/
directory: plugin, autoload, doc.
==============================================================================
USAGE *linediff-usage*
The plugin provides a simple command, |:Linediff|, which is used to diff two
separate blocks of text.
A simple example:
def one
two
end
def two
three
end
If we mark the first three lines, starting from "def one", in visual mode, and
execute the |:Linediff| command, the signs "1-" will be placed at the start
and at the end of the visual mode's range. Doing the same thing on the bottom
half of the code, starting from "def two", will result in the signs "2-"
placed there. After that, a new tab will be opened with the two blocks of code
in vertical splits, diffed against each other.
The two buffers are temporary, but when any one of them is saved, its original
buffer is updated. Note that this doesn't save the original buffer, just
performs the change. Saving is something you should do later.
Executing the command |:LinediffReset| will delete the temporary buffers and
remove the signs.
Executing a new |:Linediff| will do the same as |:LinediffReset|, but will
also initiate a new diff process.
The statuslines of the two temporary buffers will be changed to contain:
- The original buffer
- The starting line of the selected segment
- The ending line of the selected segment
If you're using a custom statusline and it contains "%f" (the current file's
name), that token will simply be substituted by the above data. Otherwise, the
entire statusline will be set to a custom one.
==============================================================================
COMMANDS *linediff-commands*
*:Linediff*
:Linediff The main interface of the plugin. Needs to be executed on a
range of lines, which will be marked with a sign. On the
selection of the second such range, the command will open a
tab with the two ranges in vertically split windows and
perform a diff on them. Saving one of the two buffers will
automatically update the original buffer the text was taken
from.
When executed for a third time, a new line diff is
initiated, and the current process is reset, much like the
effect of |LinediffReset| would be.
*:LinediffReset*
:LinediffReset Removes the signs denoting the diffed regions and deletes
the temporary buffers, used for the diff. The original
buffers are untouched by this, which means that any updates
to them, performed by the diff process will remain.
==============================================================================
INTERNALS *linediff-internals*
When a block of text is diffed with the plugin, a "Differ" object is
initialized with its relevant data. The differ contains information about the
buffer number, filetype, start and end lines of the text, and a few other
things. Almost all functions the plugin uses are scoped to this object in
order to keep the interface simple. They're located under
"autoload/linediff/differ.vim" and should be fairly understandable.
Functions that are general-purpose utilities are placed in
"autoload/linediff/util.vim".
The two differ objects that are required for the two diff buffers are linked
to each other out of necessity. If they originate from a single buffer,
updating one would move the lines of the other, so that one would have to be
updated as well. Apart from that, they have no interaction.
==============================================================================
ISSUES *linediff-issues*
You shouldn't linediff two pieces of text that overlap. Not that anything
horribly bad will happen, it just won't work as you'd hope to. I don't feel
like it's a very important use case, but if someone requests sensible
behaviour in that case, I should be able to get it working.
To report any issues or offer suggestions, use the bugtracker of the github
project at http://github.com/AndrewRadev/linediff.vim/issues
vim:tw=78:sw=4:ft=help:norl:

View File

@ -13,8 +13,10 @@
:Hexplore pi_netrw.txt /*:Hexplore*
:I visincr.txt /*:I*
:IA visincr.txt /*:IA*
:IB visincr.txt /*:IB*
:ID visincr.txt /*:ID*
:II visincr.txt /*:II*
:IIB visincr.txt /*:IIB*
:IIO visincr.txt /*:IIO*
:IIR visincr.txt /*:IIR*
:IIX visincr.txt /*:IIX*
@ -25,6 +27,8 @@
:IX visincr.txt /*:IX*
:LP LogiPat.txt /*:LP*
:LPF LogiPat.txt /*:LPF*
:Linediff linediff.txt /*:Linediff*
:LinediffReset linediff.txt /*:LinediffReset*
:LogiPat LogiPat.txt /*:LogiPat*
:MatchDebug matchit.txt /*:MatchDebug*
:MkVimball pi_vimball.txt /*:MkVimball*
@ -1595,6 +1599,7 @@ g:tcommentSyntaxMap tcomment.txt /*g:tcommentSyntaxMap*
g:vimball_home pi_vimball.txt /*g:vimball_home*
g:vimball_mkdir pi_vimball.txt /*g:vimball_mkdir*
g:visincr_datedivset visincr.txt /*g:visincr_datedivset*
g:visincr_longcmd visincr.txt /*g:visincr_longcmd*
getlatestvimscripts-install pi_getscript.txt /*getlatestvimscripts-install*
getscript pi_getscript.txt /*getscript*
getscript-autoinstall pi_getscript.txt /*getscript-autoinstall*
@ -1627,6 +1632,13 @@ gundo_preview_height gundo.txt /*gundo_preview_height*
gundo_right gundo.txt /*gundo_right*
gundo_width gundo.txt /*gundo_width*
http pi_netrw.txt /*http*
linediff linediff.txt /*linediff*
linediff-commands linediff.txt /*linediff-commands*
linediff-contents linediff.txt /*linediff-contents*
linediff-installation linediff.txt /*linediff-installation*
linediff-internals linediff.txt /*linediff-internals*
linediff-issues linediff.txt /*linediff-issues*
linediff-usage linediff.txt /*linediff-usage*
local_markfilelist pi_netrw.txt /*local_markfilelist*
logipat LogiPat.txt /*logipat*
logipat-arg LogiPat.txt /*logipat-arg*
@ -1904,13 +1916,14 @@ vimball-history pi_vimball.txt /*vimball-history*
vimball-intro pi_vimball.txt /*vimball-intro*
vimball-manual pi_vimball.txt /*vimball-manual*
vimball-windows pi_vimball.txt /*vimball-windows*
viscinr-I visincr.txt /*viscinr-I*
viscinr-contents visincr.txt /*viscinr-contents*
visincr visincr.txt /*visincr*
visincr-I visincr.txt /*visincr-I*
visincr-IA visincr.txt /*visincr-IA*
visincr-IB visincr.txt /*visincr-IB*
visincr-ID visincr.txt /*visincr-ID*
visincr-IDMY visincr.txt /*visincr-IDMY*
visincr-II visincr.txt /*visincr-II*
visincr-IIB visincr.txt /*visincr-IIB*
visincr-IIO visincr.txt /*visincr-IIO*
visincr-IIPOW visincr.txt /*visincr-IIPOW*
visincr-IIR visincr.txt /*visincr-IIR*
@ -1932,6 +1945,7 @@ visincr-RIMDY visincr.txt /*visincr-RIMDY*
visincr-RIPOW visincr.txt /*visincr-RIPOW*
visincr-RIYMD visincr.txt /*visincr-RIYMD*
visincr-calutil visincr.txt /*visincr-calutil*
visincr-contents visincr.txt /*visincr-contents*
visincr-copyright visincr.txt /*visincr-copyright*
visincr-decrease visincr.txt /*visincr-decrease*
visincr-decrement visincr.txt /*visincr-decrement*

View File

@ -1,40 +1,42 @@
*visincr.txt* The Visual Incrementing Tool Oct 17, 2007
*visincr.txt* The Visual Incrementing Tool Aug 16, 2011
Author: Charles E. Campbell, Jr. <NdrchipO@ScampbellPfamily.AbizM>
(remove NOSPAM from Campbell's email before using)
Copyright: (c) 2004-2007 by Charles E. Campbell, Jr. *visincr-copyright*
Copyright: (c) 2004-2011 by Charles E. Campbell, Jr. *visincr-copyright*
The VIM LICENSE applies to visincr.vim and visincr.txt
(see |copyright|) except use "visincr" instead of "Vim"
No warranty, express or implied. Use At-Your-Own-Risk.
==============================================================================
1. Contents *visincr* *viscinr-contents*
1. Contents *visincr* *visincr-contents*
1. Contents ....................: |visincr|
2. Quick Usage .................: |visincr-usage|
3. Increasing/Decreasing Lists..: |viscinr-increase| |viscinr-decrease|
:I [#] ...................: |visincr-I|
:II [# [zfill]] ...........: |visincr-II|
:IO [#] ...................: |visincr-IO|
:IIO [# [zfill]] ...........: |visincr-IIO|
:IX [#] ...................: |visincr-IX|
:IIX [# [zfill]] ...........: |visincr-IIX|
:IYMD [# [zfill]] ...........: |visincr-IYMD|
:IMDY [# [zfill]] ...........: |visincr-IMDY|
:IDMY [# [zfill]] ...........: |visincr-IDMY|
:IA [#] ...................: |visincr-IA|
:ID [#] ...................: |visincr-ID|
:IM [#] ...................: |visincr-IM|
:IPOW [#] ...................: |visincr-IPOW|
3. Increasing/Decreasing Lists..: |visincr-increase| |visincr-decrease|
:I [#] ..................: |visincr-I|
:II [# [zfill]] ..........: |visincr-II|
:IB [#] ..................: |visincr-IB|
:IIB [# [zfill]] ..........: |visincr-IIB|
:IO [#] ..................: |visincr-IO|
:IIO [# [zfill]] ..........: |visincr-IIO|
:IX [#] ..................: |visincr-IX|
:IIX [# [zfill]] ..........: |visincr-IIX|
:IYMD [# [zfill]] ..........: |visincr-IYMD|
:IMDY [# [zfill]] ..........: |visincr-IMDY|
:IDMY [# [zfill]] ..........: |visincr-IDMY|
:IA [#] ..................: |visincr-IA|
:ID [#] ..................: |visincr-ID|
:IM [#] ..................: |visincr-IM|
:IPOW [#] ..................: |visincr-IPOW|
:IIPOW [#] ..................: |visincr-IIPOW|
4. Examples.....................: |visincr-examples|
:I ..........................: |ex-viscinr-I|
:II .........................: |ex-viscinr-II|
:IMDY .......................: |ex-viscinr-IMDY|
:IYMD .......................: |ex-viscinr-IYMD|
:IDMY .......................: |ex-viscinr-IDMY|
:IA .........................: |ex-viscinr-IA|
:ID .........................: |ex-viscinr-ID|
:I ..........................: |ex-visincr-I|
:II .........................: |ex-visincr-II|
:IMDY .......................: |ex-visincr-IMDY|
:IYMD .......................: |ex-visincr-IYMD|
:IDMY .......................: |ex-visincr-IDMY|
:IA .........................: |ex-visincr-IA|
:ID .........................: |ex-visincr-ID|
5. Options .....................: |visincr-options|
6. History .....................: |visincr-history|
@ -43,92 +45,99 @@ Copyright: (c) 2004-2007 by Charles E. Campbell, Jr. *visincr-copyright*
Use ctrl-v to visually select a column of numbers. Then
:I [#] will use the first line's number as a starting point
default increment (#) is 1
will justify left (pad right)
For more see |visincr-I|
QUICK DECIMAL INCREMENTING
:I [#] will use the first line's number as a starting point
default increment (#) is 1
will justify left (pad right)
For more see |visincr-I|
:II [# [zfill]]
will use the first line's number as a starting point
default increment (#) is 1
default zfill is a blank (ex. :II 1 0)
will justify right (pad left)
For more see |visincr-II|
:II [# [zfill]]
will use the first line's number as a starting point
default increment (#) is 1
default zfill is a blank (ex. :II 1 0)
will justify right (pad left)
For more see |visincr-II|
ORIG I II
+---+ +----+ +----+
| 8 | | 8 | | 8 |
| 8 | | 9 | | 9 |
| 8 | | 10 | | 10 |
| 8 | | 11 | | 11 |
+---+ +----+ +----+
ORIG I II
+---+ +----+ +----+
| 8 | | 8 | | 8 |
| 8 | | 9 | | 9 |
| 8 | | 10 | | 10 |
| 8 | | 11 | | 11 |
+---+ +----+ +----+
QUICK OCTAL AND HEXADECIMAL INCREMENTING
For octal and hexadecimal incrementing, use the variants
(the increment is also octal or hexadecimal, respectively)
:IO [#] :IX [#]
:IIO [# [zfil]] :IIX [# [zfill]]
:IO [#] :IX [#]
:IIO [# [zfil]] :IIX [# [zfill]]
ORIG IO IIO
+---+ +----+ +----+
| 6 | | 6 | | 6 |
| 6 | | 7 | | 7 |
| 6 | | 10 | | 10 |
| 6 | | 11 | | 11 |
+---+ +----+ +----+
ORIG IO IIO
+---+ +----+ +----+
| 6 | | 6 | | 6 |
| 6 | | 7 | | 7 |
| 6 | | 10 | | 10 |
| 6 | | 11 | | 11 |
+---+ +----+ +----+
ORIG IX IIX
+---+ +----+ +----+
| 9 | | 9 | | 9 |
| 9 | | a | | a |
| 9 | | b | | b |
| 9 | | c | | c |
| 9 | | d | | d |
| 9 | | e | | e |
| 9 | | f | | f |
| 9 | | 10 | | 10 |
| 9 | | 11 | | 11 |
+---+ +----+ +----+
ORIG IX IIX
+---+ +----+ +----+
| 9 | | 9 | | 9 |
| 9 | | a | | a |
| 9 | | b | | b |
| 9 | | c | | c |
| 9 | | d | | d |
| 9 | | e | | e |
| 9 | | f | | f |
| 9 | | 10 | | 10 |
| 9 | | 11 | | 11 |
+---+ +----+ +----+
QUICK DATE INCREMENTING
The following three commands need <calutil.vim> to do
their work:
The following three commands need <calutil.vim> to do
their work:
:IYMD [#] Increment year/month/day dates (by optional # days)
:IMDY [#] Increment month/day/year dates (by optional # days)
:IDMY [#] Increment day/month/year dates (by optional # days)
For more: see |visincr-IYMD|, |visincr-IMDY|, and |visincr-IDMY|
(these options require the calutil.vim plugin; please see
|visincr-calutil|)
:IYMD [#] Increment year/month/day dates (by optional # days)
:IMDY [#] Increment month/day/year dates (by optional # days)
:IDMY [#] Increment day/month/year dates (by optional # days)
:ID Increment days by name (Monday, Tuesday, etc). If only
three or fewer letters are highlighted, then only
three-letter abbreviations will be used.
For more: see |visincr-ID|
For more: see |visincr-IYMD|, |visincr-IMDY|, and |visincr-IDMY|
(these calendar-based options require the calutil.vim plugin;
please see |visincr-calutil| on where to get it)
:IA Increment alphabetic lists
For more: see |visincr-IA|
:ID Increment days by name (Monday, Tuesday, etc). If only
three or fewer letters are highlighted, then only
three-letter abbreviations will be used.
For more: see |visincr-ID|
:IM Increment months by name (January, February, etc).
Like ID, if three or fewer letters are highlighted,
then only three-letter abbreviations will be used.
For more: see |visincr-IM|
:IA Increment alphabetic lists
For more: see |visincr-IA|
:IM Increment months by name (January, February, etc).
Like ID, if three or fewer letters are highlighted,
then only three-letter abbreviations will be used.
For more: see |visincr-IM|
QUICK RESTRICTED INCREMENTING
*:RI* :*RII* :*RIMDY* *:RIDMY* *:RID* *:RM* *visincr-restrict*
:RI RII RIYMD RIMDY RIDMY RID RM
Restricted variants of the above commands - requires
that the visual block on the current line start with
an appropriate pattern (ie. a number for :I, a
dayname for :ID, a monthname for :IM, etc).
For more, see
:RI RII RIYMD RIMDY RIDMY RID RM
Restricted variants of the above commands - requires
that the visual block on the current line start with
an appropriate pattern (ie. a number for :I, a
dayname for :ID, a monthname for :IM, etc).
For more, see
Restricted left-justified incrementing......|visincr-RI|
Restricted right-justified incrementing.....|visincr-RII|
Restricted year/month/day incrementing......|visincr-RIYMD|
Restricted month/day/year incrementing......|visincr-RIMDY|
Restricted day/month/year incrementing......|visincr-RIDMY|
Restricted dayname incrementing.............|visincr-RID|
Restricted monthname incrementing...........|visincr-M|
Restricted left-justified incrementing......|visincr-RI|
Restricted right-justified incrementing.....|visincr-RII|
Restricted year/month/day incrementing......|visincr-RIYMD|
Restricted month/day/year incrementing......|visincr-RIMDY|
Restricted day/month/year incrementing......|visincr-RIDMY|
Restricted dayname incrementing.............|visincr-RID|
Restricted monthname incrementing...........|visincr-M|
==============================================================================
@ -138,171 +147,173 @@ Copyright: (c) 2004-2007 by Charles E. Campbell, Jr. *visincr-copyright*
The visincr plugin facilitates making a column of increasing or decreasing
numbers, dates, or daynames.
LEFT JUSTIFIED INCREMENTING *:I* *viscinr-I*
LEFT JUSTIFIED INCREMENTING *:I* *visincr-I*
:I [#] Will use the first line's number as a starting point to build
a column of increasing numbers (or decreasing numbers if the
increment is negative).
increment is negative).
Default increment: 1
Justification : left (will pad on the right)
Default increment: 1
Justification : left (will pad on the right)
The IX variant supports hexadecimal incrementing.
The IX variant supports hexadecimal incrementing.
*visincr-RI*
The restricted version (:RI) applies number incrementing only
to those lines in the visual block that begin with a number.
The restricted version (:RI) applies number incrementing only
to those lines in the visual block that begin with a number.
See |visincr-raggedright| for a discussion on ragged-right
handling.
See |visincr-raggedright| for a discussion on ragged-right
handling.
*:IX* *visincr-IX* *:IO* *visincr-IO*
The following two commands are variants of :I : >
:IO [#] left justified octal incrementing
:IX [#] left justified hexadecimal incrementing
< The increments are in octal or hexadecimal for their
respective commands.
*:IB* *visincr-IB* *:IO* *visincr-IO* *:IX* *visincr-IX*
:IB [#] left justified binary incrementing
:IO [#] left justified octal incrementing
:IX [#] left justified hexadecimal incrementing
The commands above are variants of :I. The increments are
in binary, octal, or hexadecimal for their respective commands.
*:IR* *visincr-IR* *:IIR* *visincr-IIR*
These commands do left (IR) and right (IIR) justified
Roman numeral enumeration. The increment for these
commands is in the usual arabic numerals (ie. decimal)
as Roman numerals don't support negative numbers.
These commands do left (IR) and right (IIR) justified
Roman numeral enumeration. The increment for these
commands is in the usual arabic numerals (ie. decimal)
as Roman numerals don't support negative numbers.
RIGHT JUSTIFIED INCREMENTING *:II* *visincr-II*
RIGHT JUSTIFIED INCREMENTING *:II* *visincr-II*
:II [# [zfill]] Will use the first line's number as a starting point
to build a column of increasing numbers (or decreasing numbers
if the increment is negative).
to build a column of increasing numbers (or decreasing numbers
if the increment is negative).
Default increment: 1
Justification : right (will pad on the left)
Zfill : left padding will be done with the given
character, typically a zero.
Default increment: 1
Justification : right (will pad on the left)
Zfill : left padding will be done with the given
character, typically a zero.
*:IIX* *visincr-IIX* *:IIO* *visincr-IIO*
The following two commands are variants of :II :
*:IIB* *visincr-IIB* *:IIO* *visincr-IIO* *:IIX* *visincr-IIX*
:IIB [# [zfill]] Does right-justified binary incrementing
:IIO [# [zfill]] right justified octal incrementing
:IIX [# [zfill]] right justified hexadecimal incrementing
These commands above are variants of :II. Note that the
increments are specified in binary, octal, or hexadecimal,
respectively.
*visincr-RII*
The restricted version (:RII) applies number incrementing only
to those lines in the visual block that begin with zero or more
spaces and end with a number.
The restricted version (:RII) applies number incrementing only
to those lines in the visual block that begin with zero or more
spaces and end with a number.
RAGGED RIGHT HANDLING FOR I AND II *visincr-raggedright*
For :I and :II:
RAGGED RIGHT HANDLING FOR I AND II *visincr-raggedright*
For :I, :II, and variants:
If the visual block is ragged on the right-hand side (as can
easily happen when the "$" is used to select the
right-hand-side), the block will have spaces appended to
straighten it out. If the string length of the count exceeds
the visual-block, then additional spaces will be inserted as
needed. Leading tabs are handled by using virtual column
calculations.
If the visual block is ragged on the right-hand side (as can
easily happen when the "$" is used to select the
right-hand-side), the block will have spaces appended to
straighten it out. If the string length of the count exceeds
the visual-block, then additional spaces will be inserted as
needed. Leading tabs are handled by using virtual column
calculations.
DATE INCREMENTING
DATE INCREMENTING
:IYMD [# [zfill]] year/month/day *IYMD* *visincr-IYMD*
:IMDY [# [zfill]] month/day/year *IMDY* *visincr-IMDY*
:IDMY [# [zfill]] day/month/year *IDMY* *visincr-IDMY*
Will use the starting line's date to construct an increasing
or decreasing list of dates, depending on the sign of the
number. (these options need |visincr-calutil|)
Will use the starting line's date to construct an increasing
or decreasing list of dates, depending on the sign of the
number. (these options need |visincr-calutil|)
Default increment: 1 (in days)
Default increment: 1 (in days)
*visincr-RIYMD* *visincr-RIMDY* *visincr-RIDMY*
Restricted versions (:RIYMD, :RIMDY, :RIDMY) applies number
incrementing only to those lines in the visual block that
begin with a date (#/#/#).
Restricted versions (:RIYMD, :RIMDY, :RIDMY) applies number
incrementing only to those lines in the visual block that
begin with a date (#/#/#).
zfill: since dates include both single and double digits,
to line up the single digits must be padded. By default,
visincr will pad the single-digits in dates with zeros.
However, one may get blank padding by using a backslash
and then a space: >
zfill: since dates include both single and double digits,
to line up the single digits must be padded. By default,
visincr will pad the single-digits in dates with zeros.
However, one may get blank padding by using a backslash
and then a space: >
:IYMD 1 \
^(space here)
< Of course, one may use any charcter for such padding.
< Of course, one may use any charcter for such padding.
By default, English daynames and monthnames are used.
However, one may use whatever daynames and monthnames
one wishes by placing lines such as >
By default, English daynames and monthnames are used.
However, one may use whatever daynames and monthnames
one wishes by placing lines such as >
let g:visincr_dow = "Mandag,Tirsdag,Onsdag,Torsdag,Fredag,Lørdag,Søndag"
let g:visincr_month= "Janvier,Février,Mars,Avril,Mai,Juin,Juillet,Août,Septembre,Octobre,Novembre,Décembre"
< in your <.vimrc> initialization file. The two variables
(dow=day-of-week) should be set to a comma-delimited set of
words.
< in your <.vimrc> initialization file. The two variables
(dow=day-of-week) should be set to a comma-delimited set of
words.
*g:visincr_datedivset*
By default, the date dividers are: given by: >
By default, the date dividers are: given by: >
let g:visincr_datedivset= '[-./_:~,+*^]\='
< You may change the set in your <.vimrc>. The separator actually
used is the first one found in your date column. A date
divider is no longer strictly required (note that \= in the
date divider set). For :IMDY and :IDMY and no date dividers,
the year may be 2 or 4 digits. For :IYMD, the year must be
four digits if there are no date dividers.
< You may change the set in your <.vimrc>. The separator actually
used is the first one found in your date column. A date
divider is no longer strictly required (note that \= in the
date divider set). For :IMDY and :IDMY and no date dividers,
the year may be 2 or 4 digits. For :IYMD, the year must be
four digits if there are no date dividers.
SINGLE DIGIT DAYS OR MONTHS *visincr-leaddate*
SINGLE DIGIT DAYS OR MONTHS *visincr-leaddate*
Single digit days or months are converted into two characters
by use of
Single digit days or months are converted into two characters
by use of
>
g:visincr_leaddate
<
which, by default, is '0'. If you prefer blanks, simply put
which, by default, is '0'. If you prefer blanks, simply put
>
let g:visincr_leaddate= ' '
<
into your <.vimrc> file.
into your <.vimrc> file.
CALUTIL NEEDED FOR DATE INCREMENTING *visincr-calutil*
For :IYMD, :IMDY, and IDMY:
CALUTIL NEEDED FOR DATE INCREMENTING *visincr-calutil*
For :IYMD, :IMDY, and IDMY:
These options utilize the <calutil.vim> plugin, available as
"Calendar Utilities" at the following url on the web:
These options utilize the <calutil.vim> plugin, available as
"Calendar Utilities" at the following url on the web:
http://mysite.verizon.net/astronaut/vim/index.html#VimFuncs
http://mysite.verizon.net/astronaut/vim/index.html#VimFuncs
ALPHABETIC INCREMENTING *:IA* *visincr-IA*
:IA Will produce an increasing/decreasing list of alphabetic
characters.
ALPHABETIC INCREMENTING *:IA* *visincr-IA*
:IA Will produce an increasing/decreasing list of alphabetic
characters.
DAYNAME INCREMENTING *:ID* *visincr-ID* *visincr-RID*
:ID [#] Will produce an increasing/decreasing list of daynames.
Three-letter daynames will be used if the first day on the
first line is a three letter dayname; otherwise, full names
will be used.
DAYNAME INCREMENTING *:ID* *visincr-ID* *visincr-RID*
:ID [#] Will produce an increasing/decreasing list of daynames.
Three-letter daynames will be used if the first day on the
first line is a three letter dayname; otherwise, full names
will be used.
Restricted version (:RID) applies number incrementing only
to those lines in the visual block that begin with a dayname
(mon tue wed thu fri sat).
Restricted version (:RID) applies number incrementing only
to those lines in the visual block that begin with a dayname
(mon tue wed thu fri sat).
MONTHNAME INCREMENTING *:IM* *visincr-IM* *visincr-RIM*
MONTHNAME INCREMENTING *:IM* *visincr-IM* *visincr-RIM*
:IM [#] will produce an increasing/decreasing list of monthnames.
Monthnames may be three-letter versions (jan feb etc) or
fully-spelled out monthnames.
Monthnames may be three-letter versions (jan feb etc) or
fully-spelled out monthnames.
Restricted version (:RIM) applies number incrementing only
to those lines in the visual block that begin with a
monthname (jan feb mar etc).
Restricted version (:RIM) applies number incrementing only
to those lines in the visual block that begin with a
monthname (jan feb mar etc).
POWER INCREMENTING *:IPOW* *visincr-IPOW* *visincr-IIPOW*
*:RIPOW* *visincr-RIPOW* *visincr-RIIPOW*
POWER INCREMENTING *:IPOW* *visincr-IPOW* *visincr-IIPOW*
*:RIPOW* *visincr-RIPOW* *visincr-RIIPOW*
:IPOW [#] will produce an increasing/decreasing list of powers times
the starting point. The multiplier(divisor)'s default value
is 2.
the starting point. The multiplier(divisor)'s default value
is 2.
Restricted versions (:RIPOW and :RIIPOW) applies only
to those lines in the visual block that begin with
a number.
Restricted versions (:RIPOW and :RIIPOW) applies only
to those lines in the visual block that begin with
a number.
==============================================================================
4. Examples: *visincr-examples*
LEFT JUSTIFIED INCREMENTING EXAMPLES
LEFT JUSTIFIED INCREMENTING EXAMPLES
:I :I 2 *ex-visincr-I*
Use ctrl-V to Use ctrl-V to
Original Select, :I Original Select, :I 2
@ -321,7 +332,7 @@ numbers, dates, or daynames.
8 5 8 -1
8 4 8 -4
RIGHT JUSTIFIED INCREMENTING EXAMPLES
RIGHT JUSTIFIED INCREMENTING EXAMPLES
:II :II 2 *ex-visincr-II*
Use ctrl-V to Use ctrl-V to
Original Select, :II Original Select, :II 2
@ -340,15 +351,15 @@ numbers, dates, or daynames.
8 5 8 -1
8 4 8 -4
DATE INCREMENTING EXAMPLES
DATE INCREMENTING EXAMPLES
:IMDY *ex-visincr-IMDY*
Use ctrl-V to Use ctrl-V to
Original Select, :IMDY Original Select, :IMDY 7
06/10/03 6/10/03 06/10/03 6/10/03
06/10/03 6/11/03 06/10/03 6/11/03
06/10/03 6/12/03 06/10/03 6/12/03
06/10/03 6/13/03 06/10/03 6/13/03
06/10/03 6/14/03 06/10/03 6/14/03
06/10/03 6/10/03 06/10/03 06/10/03
06/10/03 6/11/03 06/10/03 06/17/03
06/10/03 6/12/03 06/10/03 06/24/03
06/10/03 6/13/03 06/10/03 07/01/03
06/10/03 6/14/03 06/10/03 07/08/03
:IYMD *ex-visincr-IYMD*
@ -371,7 +382,7 @@ numbers, dates, or daynames.
10/06/03 14/06/03 10/06/03 8/07/03
ALPHABETIC INCREMENTING EXAMPLES
ALPHABETIC INCREMENTING EXAMPLES
:IA *ex-visincr-IA*
Use ctrl-V to Use ctrl-V to
Original Select, :IA Original Select, :IA 2
@ -380,7 +391,7 @@ numbers, dates, or daynames.
a) c) A) E)
a) d) A) G)
DAYNAME INCREMENTING EXAMPLES
DAYNAME INCREMENTING EXAMPLES
:ID *ex-visincr-ID*
Use ctrl-V to Use ctrl-V to
Original Select, :ID Original Select, :ID 2
@ -400,7 +411,7 @@ numbers, dates, or daynames.
Sunday Wednesday Sunday Wednesday
Sunday Thursday Sunday Thursday
MONTHNAME INCREMENTING EXAMPLES
MONTHNAME INCREMENTING EXAMPLES
:IM *ex-visincr-IM*
Use ctrl-V to Use ctrl-V to
Original Select, :IM Original Select, :IM 2
@ -429,13 +440,37 @@ numbers, dates, or daynames.
let g:visincr_month="January,February,March,April,May,June,July,August,September,October,November,December"
let g:visincr_datedivset= '[-./]'
<
Controls respectively the day of week (ID), name of month (IM),
and dividers used by IMDY, IYMD, IDMY.
Respectively controls
the day of week (ID),
name of month (IM), and
dividers used by IMDY, IYMD, IDMY.
*g:visincr_longcmd*
If this variable exists, then "long" commands are provided rather than the
normal ones; that is, all commands will be preceded with "VI_".
In other words, VI_I, VI_II, VI_IMDY, etc., commands are provided.
Put >
let g:visincr_longcmd= 1
< in your .vimrc (for it to take effect the variable must be set prior to
loading visincrPlugin.vim). Doing this reduces (does not eliminate) the
possibility of command naming conflicts with other plugins.
==============================================================================
6. History: *visincr-history* {{{1
v20: 07/01/08 : Fixed IIO and IIX commands when they're given
two arguments (ex. :IIX 1 0).
07/01/08 * Fixed a problem when |'selection'| is
"exclusive" as happens with mswin.vim usage.
06/18/09 * Included :IB and :IIB for binary incrementing
* Included support for restricted incrementing:
:RIB, :RIIB, :RIO, :RIIO, :RIX, and :RIIX
08/16/11 * |g:visincr_longcmd| provided to reduce command
naming conflicts amongst plugins.
v19: 12/19/07 : neglected to include calutil on the upload to
vim.sf.net, so a new version was made that
included it.
v18: 02/13/07 : included IPOW and variants
02/15/07 * date dividers are no longer required
10/17/07 * calutil.vim and calutil.txt included, and they
@ -451,8 +486,8 @@ numbers, dates, or daynames.
03/25/06 * Visincr converted to use Vim 7.0's autoloading
06/12/06 * Visincr will now direct users trying to do a
calendrical incrementing operation (IMDY, IYMD,
IDMY) but missing calutil.vim to the help on
where to get it (|visincr-calutil|).
IDMY) but missing calutil.vim to the help on
where to get it (|visincr-calutil|).
06/12/06 * :IO and :IIO implemented to support octal
incrementing
v13: 03/15/06 : a zfill of '' or "" now stands for an empty zfill

View File

@ -1,102 +0,0 @@
" Vim BlockDiff-Plugin
"
" Author: Timo Teifel
" Email: timo dot teifel at teifel dot net
" Version: 1.1
" Date: 23 Oct 2007
" Licence: GPL v2.0
"
" Usage:
" - Select first block
" - Depending on the configuration, select:
" - Menu Tools->BlockDiff-> This\ is\ Block\ 1
" - Popup-Menu -> This\ is\ Block\ 1
" - :BlockDiff1
" - ,d1
" - select second block (may be in another file, but in the same
" Vim window)
" - Menu Tools->BlockDiff-> This\ is\ Block\ 2,\ start\ diff
" - Popup-Menu -> This\ is\ Block\ 2,\ start\ diff
" - :BlockDiff2
" - ,d2
" - Script opens a new tab, splits it and shows the diff between
" the two blocks.
" - Close the tab when done
"
" History:
" V1.0: Initial upload
" V1.1: Added commands and inclusion guard, Thanks to Ingo Karkat
" Avoid installing twice or when in compatible mode
if exists('g:loaded_blockdiff') || (v:version < 700)
finish
endif
let g:loaded_blockdiff = 1
let s:save_cpo = &cpo
set cpo&vim
" ---------- Configuration ----------------------------------------------------
" uncomment one or more of these blocks:
" Create menu entry:
vmenu 40.352.10 &Tools.Bloc&kDiff.This\ is\ Block\ &1 :call BlockDiff_GetBlock1()<CR>
vmenu 40.352.20 &Tools.Bloc&kDiff.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>
" Commands
command! -range BlockDiff1 :<line1>,<line2>call BlockDiff_GetBlock1()
command! -range BlockDiff2 :<line1>,<line2>call BlockDiff_GetBlock2()
" ---------- 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

@ -0,0 +1,51 @@
if exists("g:loaded_linediff") || &cp
finish
endif
let g:loaded_linediff = '0.1.0' " version number
let s:keepcpo = &cpo
set cpo&vim
" Initialized lazily to avoid executing the autoload file before it's really
" needed.
"
" TODO Experiment to see if this matters at all.
"
function! s:Init()
if !exists('s:differ_one')
let s:differ_one = linediff#differ#New('linediff_one', 1)
let s:differ_two = linediff#differ#New('linediff_two', 2)
endif
endfunction
command! -range Linediff call s:Linediff(<line1>, <line2>)
function! s:Linediff(from, to)
call s:Init()
if s:differ_one.IsBlank()
call s:differ_one.Init(a:from, a:to)
elseif s:differ_two.IsBlank()
call s:differ_two.Init(a:from, a:to)
call s:PerformDiff(s:differ_one, s:differ_two)
else
call s:differ_one.Reset()
call s:differ_two.Reset()
call s:Linediff(a:from, a:to)
endif
endfunction
command! LinediffReset call s:LinediffReset()
function! s:LinediffReset()
call s:differ_one.Reset()
call s:differ_two.Reset()
endfunction
function! s:PerformDiff(one, two)
call a:one.CreateDiffBuffer("tabedit")
call a:two.CreateDiffBuffer("rightbelow vsplit")
let a:one.other_differ = a:two
let a:two.other_differ = a:one
endfunction

View File

@ -1,6 +1,6 @@
" visincrPlugin.vim: Visual-block incremented lists
" Author: Charles E. Campbell, Jr. Ph.D.
" Date: Jul 18, 2006
" Date: Aug 16, 2011
" Public Interface Only
"
" (James 2:19,20 WEB) You believe that God is one. You do well!
@ -13,7 +13,7 @@
if &cp || exists("g:loaded_visincrPlugin")
finish
endif
let g:loaded_visincrPlugin = "v19"
let g:loaded_visincrPlugin = "v20"
let s:keepcpo = &cpo
set cpo&vim
@ -29,57 +29,112 @@ let s:IM = 6
let s:IA = 7
let s:IX = 8
let s:IIX = 9
let s:IO = 10
let s:IIO = 11
let s:IR = 12
let s:IIR = 13
let s:IPOW = 14
let s:IIPOW = 15
let s:RI = 16
let s:RII = 17
let s:RIMDY = 18
let s:RIYMD = 19
let s:RIDMY = 20
let s:RID = 21
let s:RIM = 22
let s:RIA = 23
let s:RIX = 24
let s:RIIX = 25
let s:RIO = 26
let s:RIIO = 27
let s:RIR = 28
let s:RIIR = 29
let s:RIPOW = 30
let s:RIIPOW = 31
let s:IB = 10
let s:IIB = 11
let s:IO = 12
let s:IIO = 13
let s:IR = 14
let s:IIR = 15
let s:IPOW = 16
let s:IIPOW = 17
let s:RI = 18
let s:RII = 19
let s:RIMDY = 20
let s:RIYMD = 21
let s:RIDMY = 22
let s:RID = 23
let s:RIM = 24
let s:RIA = 25
let s:RIX = 26
let s:RIIX = 27
let s:RIB = 28
let s:RIIB = 29
let s:RIO = 30
let s:RIIO = 31
let s:RIR = 32
let s:RIIR = 33
let s:RIPOW = 34
let s:RIIPOW = 35
" ------------------------------------------------------------------------------
" Public Interface: {{{1
com! -ra -complete=expression -na=? I call visincr#VisBlockIncr(s:I , <f-args>)
com! -ra -complete=expression -na=* II call visincr#VisBlockIncr(s:II , <f-args>)
com! -ra -complete=expression -na=* IMDY call visincr#VisBlockIncr(s:IMDY , <f-args>)
com! -ra -complete=expression -na=* IYMD call visincr#VisBlockIncr(s:IYMD , <f-args>)
com! -ra -complete=expression -na=* IDMY call visincr#VisBlockIncr(s:IDMY , <f-args>)
com! -ra -complete=expression -na=? ID call visincr#VisBlockIncr(s:ID , <f-args>)
com! -ra -complete=expression -na=? IM call visincr#VisBlockIncr(s:IM , <f-args>)
com! -ra -complete=expression -na=? IA call visincr#VisBlockIncr(s:IA , <f-args>)
com! -ra -complete=expression -na=? IX call visincr#VisBlockIncr(s:IX , <f-args>)
com! -ra -complete=expression -na=? IIX call visincr#VisBlockIncr(s:IIX , <f-args>)
com! -ra -complete=expression -na=? IO call visincr#VisBlockIncr(s:IO , <f-args>)
com! -ra -complete=expression -na=? IIO call visincr#VisBlockIncr(s:IIO , <f-args>)
com! -ra -complete=expression -na=? IR call visincr#VisBlockIncr(s:IR , <f-args>)
com! -ra -complete=expression -na=? IIR call visincr#VisBlockIncr(s:IIR , <f-args>)
com! -ra -complete=expression -na=? IPOW call visincr#VisBlockIncr(s:IPOW , <f-args>)
com! -ra -complete=expression -na=? IIPOW call visincr#VisBlockIncr(s:IIPOW , <f-args>)
if !exists("g:visincr_longcmd")
com! -ra -complete=expression -na=? I call visincr#VisBlockIncr(s:I , <f-args>)
com! -ra -complete=expression -na=* II call visincr#VisBlockIncr(s:II , <f-args>)
com! -ra -complete=expression -na=* IMDY call visincr#VisBlockIncr(s:IMDY , <f-args>)
com! -ra -complete=expression -na=* IYMD call visincr#VisBlockIncr(s:IYMD , <f-args>)
com! -ra -complete=expression -na=* IDMY call visincr#VisBlockIncr(s:IDMY , <f-args>)
com! -ra -complete=expression -na=? ID call visincr#VisBlockIncr(s:ID , <f-args>)
com! -ra -complete=expression -na=? IM call visincr#VisBlockIncr(s:IM , <f-args>)
com! -ra -complete=expression -na=? IA call visincr#VisBlockIncr(s:IA , <f-args>)
com! -ra -complete=expression -na=? IX call visincr#VisBlockIncr(s:IX , <f-args>)
com! -ra -complete=expression -na=* IIX call visincr#VisBlockIncr(s:IIX , <f-args>)
com! -ra -complete=expression -na=? IB call visincr#VisBlockIncr(s:IB , <f-args>)
com! -ra -complete=expression -na=* IIB call visincr#VisBlockIncr(s:IIB , <f-args>)
com! -ra -complete=expression -na=? IO call visincr#VisBlockIncr(s:IO , <f-args>)
com! -ra -complete=expression -na=* IIO call visincr#VisBlockIncr(s:IIO , <f-args>)
com! -ra -complete=expression -na=? IR call visincr#VisBlockIncr(s:IR , <f-args>)
com! -ra -complete=expression -na=* IIR call visincr#VisBlockIncr(s:IIR , <f-args>)
com! -ra -complete=expression -na=? IPOW call visincr#VisBlockIncr(s:IPOW , <f-args>)
com! -ra -complete=expression -na=* IIPOW call visincr#VisBlockIncr(s:IIPOW , <f-args>)
com! -ra -complete=expression -na=? RI call visincr#VisBlockIncr(s:RI , <f-args>)
com! -ra -complete=expression -na=* RII call visincr#VisBlockIncr(s:RII , <f-args>)
com! -ra -complete=expression -na=* RIMDY call visincr#VisBlockIncr(s:RIMDY , <f-args>)
com! -ra -complete=expression -na=* RIYMD call visincr#VisBlockIncr(s:RIYMD , <f-args>)
com! -ra -complete=expression -na=* RIDMY call visincr#VisBlockIncr(s:RIDMY , <f-args>)
com! -ra -complete=expression -na=? RID call visincr#VisBlockIncr(s:RID , <f-args>)
com! -ra -complete=expression -na=? RIM call visincr#VisBlockIncr(s:RIM , <f-args>)
com! -ra -complete=expression -na=? RIPOW call visincr#VisBlockIncr(s:RIPOW , <f-args>)
com! -ra -complete=expression -na=* RIIPOW call visincr#VisBlockIncr(s:RIIPOW , <f-args>)
com! -ra -complete=expression -na=? RI call visincr#VisBlockIncr(s:RI , <f-args>)
com! -ra -complete=expression -na=* RII call visincr#VisBlockIncr(s:RII , <f-args>)
com! -ra -complete=expression -na=* RIMDY call visincr#VisBlockIncr(s:RIMDY , <f-args>)
com! -ra -complete=expression -na=* RIYMD call visincr#VisBlockIncr(s:RIYMD , <f-args>)
com! -ra -complete=expression -na=* RIDMY call visincr#VisBlockIncr(s:RIDMY , <f-args>)
com! -ra -complete=expression -na=? RID call visincr#VisBlockIncr(s:RID , <f-args>)
com! -ra -complete=expression -na=? RIA call visincr#VisBlockIncr(s:RIA , <f-args>)
com! -ra -complete=expression -na=? RIX call visincr#VisBlockIncr(s:RIX , <f-args>)
com! -ra -complete=expression -na=? RIIX call visincr#VisBlockIncr(s:RIIX , <f-args>)
com! -ra -complete=expression -na=? RIB call visincr#VisBlockIncr(s:RIB , <f-args>)
com! -ra -complete=expression -na=? RIIB call visincr#VisBlockIncr(s:RIIB , <f-args>)
com! -ra -complete=expression -na=? RIO call visincr#VisOlockIncr(s:RIO , <f-args>)
com! -ra -complete=expression -na=? RIIO call visincr#VisOlockIncr(s:RIIO , <f-args>)
com! -ra -complete=expression -na=? RIR call visincr#VisRlockIncr(s:RIR , <f-args>)
com! -ra -complete=expression -na=? RIIR call visincr#VisRlockIncr(s:RIIR , <f-args>)
com! -ra -complete=expression -na=? RIM call visincr#VisBlockIncr(s:RIM , <f-args>)
com! -ra -complete=expression -na=? RIPOW call visincr#VisBlockIncr(s:RIPOW , <f-args>)
com! -ra -complete=expression -na=* RIIPOW call visincr#VisBlockIncr(s:RIIPOW , <f-args>)
else
com! -ra -complete=expression -na=? VI_I call visincr#VisBlockIncr(s:I , <f-args>)
com! -ra -complete=expression -na=* VI_II call visincr#VisBlockIncr(s:II , <f-args>)
com! -ra -complete=expression -na=* VI_IMDY call visincr#VisBlockIncr(s:IMDY , <f-args>)
com! -ra -complete=expression -na=* VI_IYMD call visincr#VisBlockIncr(s:IYMD , <f-args>)
com! -ra -complete=expression -na=* VI_IDMY call visincr#VisBlockIncr(s:IDMY , <f-args>)
com! -ra -complete=expression -na=? VI_ID call visincr#VisBlockIncr(s:ID , <f-args>)
com! -ra -complete=expression -na=? VI_IM call visincr#VisBlockIncr(s:IM , <f-args>)
com! -ra -complete=expression -na=? VI_IA call visincr#VisBlockIncr(s:IA , <f-args>)
com! -ra -complete=expression -na=? VI_IX call visincr#VisBlockIncr(s:IX , <f-args>)
com! -ra -complete=expression -na=* VI_IIX call visincr#VisBlockIncr(s:IIX , <f-args>)
com! -ra -complete=expression -na=? VI_IB call visincr#VisBlockIncr(s:IB , <f-args>)
com! -ra -complete=expression -na=* VI_IIB call visincr#VisBlockIncr(s:IIB , <f-args>)
com! -ra -complete=expression -na=? VI_IO call visincr#VisBlockIncr(s:IO , <f-args>)
com! -ra -complete=expression -na=* VI_IIO call visincr#VisBlockIncr(s:IIO , <f-args>)
com! -ra -complete=expression -na=? VI_IR call visincr#VisBlockIncr(s:IR , <f-args>)
com! -ra -complete=expression -na=* VI_IIR call visincr#VisBlockIncr(s:IIR , <f-args>)
com! -ra -complete=expression -na=? VI_IPOW call visincr#VisBlockIncr(s:IPOW , <f-args>)
com! -ra -complete=expression -na=* VI_IIPOW call visincr#VisBlockIncr(s:IIPOW , <f-args>)
com! -ra -complete=expression -na=? VI_RI call visincr#VisBlockIncr(s:RI , <f-args>)
com! -ra -complete=expression -na=* VI_RII call visincr#VisBlockIncr(s:RII , <f-args>)
com! -ra -complete=expression -na=* VI_RIMDY call visincr#VisBlockIncr(s:RIMDY , <f-args>)
com! -ra -complete=expression -na=* VI_RIYMD call visincr#VisBlockIncr(s:RIYMD , <f-args>)
com! -ra -complete=expression -na=* VI_RIDMY call visincr#VisBlockIncr(s:RIDMY , <f-args>)
com! -ra -complete=expression -na=? VI_RID call visincr#VisBlockIncr(s:RID , <f-args>)
com! -ra -complete=expression -na=? VI_RIA call visincr#VisBlockIncr(s:RIA , <f-args>)
com! -ra -complete=expression -na=? VI_RIX call visincr#VisBlockIncr(s:RIX , <f-args>)
com! -ra -complete=expression -na=? VI_RIIX call visincr#VisBlockIncr(s:RIIX , <f-args>)
com! -ra -complete=expression -na=? VI_RIB call visincr#VisBlockIncr(s:RIB , <f-args>)
com! -ra -complete=expression -na=? VI_RIIB call visincr#VisBlockIncr(s:RIIB , <f-args>)
com! -ra -complete=expression -na=? VI_RIO call visincr#VisOlockIncr(s:RIO , <f-args>)
com! -ra -complete=expression -na=? VI_RIIO call visincr#VisOlockIncr(s:RIIO , <f-args>)
com! -ra -complete=expression -na=? VI_RIR call visincr#VisRlockIncr(s:RIR , <f-args>)
com! -ra -complete=expression -na=? VI_RIIR call visincr#VisRlockIncr(s:RIIR , <f-args>)
com! -ra -complete=expression -na=? VI_RIM call visincr#VisBlockIncr(s:RIM , <f-args>)
com! -ra -complete=expression -na=? VI_RIPOW call visincr#VisBlockIncr(s:RIPOW , <f-args>)
com! -ra -complete=expression -na=* VI_RIIPOW call visincr#VisBlockIncr(s:RIIPOW , <f-args>)
endif
" ---------------------------------------------------------------------
" Restoration And Modelines: {{{1