Debian Codegraph @

texmf-dist/doc/latex/proofread/proofread.vmb

raw
1 " Vimball Archiver by Charles E. Campbell, Jr., Ph.D.
2 UseVimball
3 finish
4 vis/plugin/visPlugin.vim [[[1
5 60
6 " vis.vim:
7 " Function: Perform an Ex command on a visual highlighted block (CTRL-V).
8 " Date: May 18, 2010
9 " GetLatestVimScripts: 1066 1 cecutil.vim
10 " GetLatestVimScripts: 1195 1 :AutoInstall: vis.vim
11 " Verse: For am I now seeking the favor of men, or of God? Or am I striving
12 " to please men? For if I were still pleasing men, I wouldn't be a servant
13 " of Christ. (Gal 1:10, WEB)
14
15 " ---------------------------------------------------------------------
16 " Details: {{{1
17 " Requires: Requires 6.0 or later (this script is a plugin)
18 " Requires <cecutil.vim> (see :he vis-required)
19 "
20 " Usage: Mark visual block (CTRL-V) or visual character (v),
21 " press ':B ' and enter an Ex command [cmd].
22 "
23 " ex. Use ctrl-v to visually mark the block then use
24 " :B cmd (will appear as :'<,'>B cmd )
25 "
26 " ex. Use v to visually mark the block then use
27 " :B cmd (will appear as :'<,'>B cmd )
28 "
29 " Command-line completion is supported for Ex commands.
30 "
31 " Note: There must be a space before the '!' when invoking external shell
32 " commands, eg. ':B !sort'. Otherwise an error is reported.
33 "
34 " Author: Charles E. Campbell <[email protected]> - NOSPAM
35 " Based on idea of Stefan Roemer <[email protected]>
36 "
37 " ------------------------------------------------------------------------------
38 " Initialization: {{{1
39 " Exit quickly when <Vis.vim> has already been loaded or
40 " when 'compatible' is set
41 if &cp
42 finish
43 endif
44 let s:keepcpo= &cpo
45 set cpo&vim
46
47 " ------------------------------------------------------------------------------
48 " Public Interface: {{{1
49 " -range : VisBlockCmd operates on the range itself
50 " -com=command : Ex command and arguments
51 " -nargs=+ : arguments may be supplied, up to any quantity
52 com! -range -nargs=+ -com=command B sil <line1>,<line2>call vis#VisBlockCmd(<q-args>)
53 com! -range -nargs=* -com=expression S sil <line1>,<line2>call vis#VisBlockSearch(<q-args>)
54
55 " Suggested by Hari --
56 if exists("g:vis_WantSlashSlash") && g:vis_WantSlashSlash
57 vn // <esc>/<c-r>=vis#VisBlockSearch()<cr>
58 endif
59 vn ?? <esc>?<c-r>=vis#VisBlockSearch()<cr>
60
61 let &cpo= s:keepcpo
62 unlet s:keepcpo
63 " ---------------------------------------------------------------------
64 " Modelines: {{{1
65 " vim: fdm=marker
66 vis/autoload/vis.vim [[[1
67 339
68 " vis.vim:
69 " Function: Perform an Ex command on a visual highlighted block (CTRL-V).
70 " Version: 21f NOT RELEASED
71 " Date: Sep 08, 2016
72 " GetLatestVimScripts: 1066 1 cecutil.vim
73 " GetLatestVimScripts: 1195 1 :AutoInstall: vis.vim
74 " Verse: For am I now seeking the favor of men, or of God? Or am I striving
75 " to please men? For if I were still pleasing men, I wouldn't be a servant
76 " of Christ. (Gal 1:10, WEB)
77 "
78 " Author: Charles E. Campbell <[email protected]> - NOSPAM
79 " Based on idea of Stefan Roemer <[email protected]>
80 "
81 " ------------------------------------------------------------------------------
82 " Initialization: {{{1
83 " Exit quickly when <Vis.vim> has already been loaded or
84 " when 'compatible' is set
85 if &cp || exists("g:loaded_vis")
86 finish
87 endif
88 let s:keepcpo = &cpo
89 let g:loaded_vis = "v21fNR"
90 set cpo&vim
91 "DechoTabOn
92
93 " ---------------------------------------------------------------------
94 " Support Functions: {{{1
95 " ------------------------------------------------------------------------------
96 " vis#VisBlockCmd: {{{2
97 fun! vis#VisBlockCmd(cmd) range
98 " call Dfunc("vis#VisBlockCmd(cmd<".a:cmd.">")
99
100 " retain and re-use same visual mode
101 sil! keepj norm `<
102 let curposn = SaveWinPosn(0)
103 let vmode = visualmode()
104 " call Decho("vmode<".vmode.">")
105
106 call s:SaveUserSettings()
107
108 if vmode == 'V'
109 " call Decho("handling V mode")
110 " call Decho("cmd<".a:cmd.">")
111 exe "keepj '<,'>".a:cmd
112
113 else " handle v and ctrl-v
114 " call Decho("handling v or ctrl-v mode")
115 " Initialize so (begcol < endcol) for non-v modes
116 let begcol = s:VirtcolM1("<")
117 let endcol = s:VirtcolM1(">")
118 if vmode != 'v'
119 if begcol > endcol
120 let begcol = s:VirtcolM1(">")
121 let endcol = s:VirtcolM1("<")
122 endif
123 endif
124
125 " Initialize so that begline<endline
126 let begline = a:firstline
127 let endline = a:lastline
128 if begline > endline
129 let begline = a:lastline
130 let endline = a:firstline
131 endif
132 " call Decho('beg['.begline.','.begcol.'] end['.endline.','.endcol.']')
133
134 " =======================
135 " Modify Selected Region:
136 " =======================
137 " 1. delete selected region into register "a
138 " call Decho("1. delete selected region into register a")
139 sil! keepj norm! gv"ad
140 " call Decho("1. reg-A<".@a.">")
141 " call Recho("Step#1: deleted selected region into register")|redraw!|sleep 3 " Decho
142
143 " 2. put cut-out text at end-of-file
144 " call Decho("2. put cut-out text at end-of-file")
145 keepj $
146 keepj pu_
147 let lastline= line("$")
148 sil! keepj norm! "aP
149 " call Decho("2. reg-A<".@a.">")
150 " call Recho("Step#2: put text at end-of-file")|redraw!|sleep 3 " Decho
151
152 " 3. apply command to those lines
153 let curline = line(".")
154 ka
155 keepj $
156 " call Decho("3. apply command<".a:cmd."> to those lines (curline=".line(".").")")
157 exe "keepj ". curline.',$'.a:cmd
158 " call Recho("Step#3: apply command")|redraw!|sleep 3 " Decho
159
160 " 4. Prepend the "empty_chr" since "ad on empty lines inserts blanks
161 if exists("g:vis_empty_character")
162 let empty_chr= g:vis_empty_character
163 else
164 let empty_chr= (&enc == "euc-jp")? "\<Char-0x01>" : "\<Char-0xff>"
165 endif
166 " if the command removes the text, then don't do anything with the
167 " non-existent text (for example, :B !true under unix)
168 if curline <= line("$")
169 exe "keepj sil! ". curline.',$s/^/'.empty_chr.'/'
170 " call Recho("Step#3a: prepend empty-character")|redraw!|sleep 3 " Decho
171
172 " 5. visual-block select the modified text in those lines
173 " call Decho("5. visual-block select modified text at end-of-file")
174 exe "keepj ".lastline
175 exe "keepj norm! 0".vmode."G$\"ad"
176 " call Decho("5. reg-A<".@a.">")
177 " call Recho("Step#5: select modified text")|redraw!|sleep 3 " Decho
178
179 " 6. delete excess lines
180 " call Decho("6. delete excess lines")
181 exe "sil! keepj ".lastline.',$d'
182 " call Recho("Step#6: delete excess lines")|redraw!|sleep 3 " Decho
183
184 " 7. put modified text back into file
185 " call Decho("7. put modifed text back into file (beginning=".begline.".".begcol.")")
186 exe "keepj ".begline
187 if begcol > 1
188 exe 'sil! keepj norm! '.begcol."\<bar>\"ap"
189 elseif begcol == 1
190 norm! 0"ap
191 else
192 norm! 0"aP
193 endif
194 " call Recho("Step#7: put modified text back")|redraw!|sleep 3 " Decho
195 endif
196
197 " 8. attempt to restore gv -- this is limited, it will
198 " select the same size region in the same place as before,
199 " not necessarily the changed region
200 " call Decho("8. restore gv")
201 let begcol= begcol+1
202 let endcol= endcol+1
203 exe "sil keepj ".begline
204 exe 'sil keepj norm! '.begcol."\<bar>".vmode
205 exe "sil keepj ".endline
206 exe 'sil keepj norm! '.endcol."\<bar>\<esc>"
207 exe "sil keepj ".begline
208 exe 'sil keepj norm! '.begcol."\<bar>"
209 " call Recho("Step#8: restore gv")|redraw!|sleep 3 " Decho
210
211 " 9. Remove empty-character from text
212 " call Decho("9. remove empty-character from lines ".begline." to ".endline)
213 exe "sil! keepj ".begline.','.endline.'s/'.empty_chr.'//e'
214 " call Recho("Step#9: remove empty-character")|redraw!|sleep 3 " Decho
215 endif
216
217 " restore a-priori condition
218 call s:RestoreUserSettings()
219 call RestoreWinPosn(curposn)
220
221 " call Dret("vis#VisBlockCmd")
222 endfun
223
224 " ------------------------------------------------------------------------------
225 " vis#VisBlockSearch: {{{2
226 fun! vis#VisBlockSearch(...) range
227 " call Dfunc("vis#VisBlockSearch() a:0=".a:0." lines[".a:firstline.",".a:lastline."]")
228 let keepic= &ic
229 set noic
230
231 if a:0 >= 1 && strlen(a:1) > 0
232 let pattern = a:1
233 let s:pattern = pattern
234 " call Decho("a:0=".a:0.": pattern<".pattern.">")
235 elseif exists("s:pattern")
236 let pattern= s:pattern
237 else
238 let pattern = @/
239 let s:pattern = pattern
240 endif
241 let vmode= visualmode()
242
243 " collect search restrictions
244 let firstline = line("'<")
245 let lastline = line("'>")
246 let firstcolm1 = s:VirtcolM1("<")
247 let lastcolm1 = s:VirtcolM1(">")
248 " call Decho("1: firstline=".firstline." lastline=".lastline." firstcolm1=".firstcolm1." lastcolm1=".lastcolm1)
249
250 if(firstline > lastline)
251 let firstline = line("'>")
252 let lastline = line("'<")
253 if a:0 >= 1
254 keepj norm! `>
255 endif
256 else
257 if a:0 >= 1
258 keepj norm! `<
259 endif
260 endif
261 " call Decho("2: firstline=".firstline." lastline=".lastline." firstcolm1=".firstcolm1." lastcolm1=".lastcolm1)
262
263 if vmode != 'v'
264 if firstcolm1 > lastcolm1
265 let tmp = firstcolm1
266 let firstcolm1 = lastcolm1
267 let lastcolm1 = tmp
268 endif
269 endif
270 " call Decho("3: firstline=".firstline." lastline=".lastline." firstcolm1=".firstcolm1." lastcolm1=".lastcolm1)
271
272 let firstlinem1 = firstline - 1
273 let lastlinep1 = lastline + 1
274 let firstcol = firstcolm1 + 1
275 let lastcol = lastcolm1 + 1
276 let lastcolp1 = lastcol + 1
277 " call Decho("4: firstline=".firstline." lastline=".lastline." firstcolm1=".firstcolm1." lastcolp1=".lastcolp1)
278
279 " construct search string
280 if vmode == 'V'
281 let srch= '\%(\%>'.firstlinem1.'l\%<'.lastlinep1.'l\)\&'
282 " call Decho("V srch: ".srch)
283 elseif vmode == 'v'
284 if firstline == lastline || firstline == lastlinep1
285 let srch= '\%(\%'.firstline.'l\%>'.firstcolm1.'v\%<'.lastcolp1.'v\)\&'
286 else
287 let srch= '\%(\%(\%'.firstline.'l\%>'.firstcolm1.'v\)\|\%(\%'.lastline.'l\%<'.lastcolp1.'v\)\|\%(\%>'.firstline.'l\%<'.lastline.'l\)\)\&'
288 endif
289 " call Decho("v srch: ".srch)
290 else
291 let srch= '\%(\%>'.firstlinem1.'l\%>'.firstcolm1.'v\%<'.lastlinep1.'l\%<'.lastcolp1.'v\)\&'
292 " call Decho("^v srch: ".srch)
293 endif
294
295 " perform search
296 if a:0 <= 1
297 " call Decho("Search forward: <".srch.pattern.">")
298 call search(srch.pattern)
299 let @/= srch.pattern
300
301 elseif a:0 == 2
302 " call Decho("Search backward: <".srch.pattern.">")
303 call search(srch.pattern,a:2)
304 let @/= srch.pattern
305 endif
306
307 " restore ignorecase
308 let &ic= keepic
309
310 " call Dret("vis#VisBlockSearch <".srch.">")
311 return srch
312 endfun
313
314 " ------------------------------------------------------------------------------
315 " s:VirtcolM1: usually a virtcol(mark)-1, but due to tabs this can be different {{{2
316 fun! s:VirtcolM1(mark)
317 " call Dfunc('s:VirtcolM1("'.a:mark.'")')
318
319 if virtcol("'".a:mark) <= 1
320 " call Dret("s:VirtcolM1 0")
321 return 0
322 endif
323
324 if &ve == "block"
325 " Works around a ve=all vs ve=block difference with virtcol().
326 " Since s:SaveUserSettings() changes ve to ve=all, this small
327 " ve override only affects vis#VisBlockSearch().
328 set ve=all
329 " call Decho("temporarily setting ve=all")
330 endif
331
332 " call Decho("exe norm! `".a:mark."h")
333 exe "keepj norm! `".a:mark."h"
334
335 let vekeep = &ve
336 let vc = virtcol(".")
337 let &ve = vekeep
338
339 " call Dret("s:VirtcolM1 ".vc)
340 return vc
341 endfun
342
343 " ---------------------------------------------------------------------
344 " s:SaveUserSettings: save options which otherwise may interfere {{{2
345 fun! s:SaveUserSettings()
346 " call Dfunc("s:SaveUserSettings()")
347 let s:keep_lz = &lz
348 let s:keep_fen = &fen
349 let s:keep_fo = &fo
350 let s:keep_ic = &ic
351 let s:keep_magic = &magic
352 let s:keep_sol = &sol
353 let s:keep_ve = &ve
354 let s:keep_ww = &ww
355 let s:keep_cedit = &cedit
356 set lz magic nofen noic nosol ww= fo=nroql2 cedit&
357 " determine whether or not "ragged right" is in effect for the selected region
358 let raggedright= 0
359 norm! `>
360 let rrcol = col(".")
361 while line(".") >= line("'<")
362 " call Decho(".line#".line(".").": col(.)=".col('.')." rrcol=".rrcol)
363 if col(".") != rrcol
364 let raggedright = 1
365 break
366 endif
367 if line(".") == 1
368 break
369 endif
370 norm! k
371 endwhile
372 if raggedright
373 " call Decho("ragged right: set ve=all")
374 set ve=all
375 else
376 " call Decho("smooth right: set ve=")
377 set ve=
378 endif
379
380 " Save any contents in register a
381 let s:rega= @a
382
383 " call Dret("s:SaveUserSettings")
384 endfun
385
386 " ---------------------------------------------------------------------
387 " s:RestoreUserSettings: restore register a and options {{{2
388 fun! s:RestoreUserSettings()
389 " call Dfunc("s:RestoreUserSettings()")
390 let @a = s:rega
391 let &cedit = s:keep_cedit
392 let &fen = s:keep_fen
393 let &fo = s:keep_fo
394 let &ic = s:keep_ic
395 let &lz = s:keep_lz
396 let &sol = s:keep_sol
397 let &ve = s:keep_ve
398 let &ww = s:keep_ww
399 " call Dret("s:RestoreUserSettings")
400 endfun
401
402 let &cpo= s:keepcpo
403 unlet s:keepcpo
404 " ------------------------------------------------------------------------------
405 " Modelines: {{{1
406 " vim: fdm=marker
407 vis/plugin/cecutil.vim [[[1
408 600
409 " cecutil.vim : save/restore window position
410 " save/restore mark position
411 " save/restore selected user maps
412 " Author: Charles E. Campbell
413 " Version: 18j NOT RELEASED
414 " Date: Aug 13, 2016
415 "
416 " Saving Restoring Destroying Marks: {{{1
417 " call SaveMark(markname) let savemark= SaveMark(markname)
418 " call RestoreMark(markname) call RestoreMark(savemark)
419 " call DestroyMark(markname)
420 " commands: SM RM DM
421 "
422 " Saving Restoring Destroying Window Position: {{{1
423 " call SaveWinPosn() let winposn= SaveWinPosn()
424 " call RestoreWinPosn() call RestoreWinPosn(winposn)
425 " \swp : save current window/buffer's position
426 " \rwp : restore current window/buffer's previous position
427 " commands: SWP RWP
428 "
429 " Saving And Restoring User Maps: {{{1
430 " call SaveUserMaps(mapmode,maplead,mapchx,suffix)
431 " call RestoreUserMaps(suffix)
432 "
433 " GetLatestVimScripts: 1066 1 :AutoInstall: cecutil.vim
434 "
435 " You believe that God is one. You do well. The demons also {{{1
436 " believe, and shudder. But do you want to know, vain man, that
437 " faith apart from works is dead? (James 2:19,20 WEB)
438 "redraw!|call inputsave()|call input("Press <cr> to continue")|call inputrestore()
439
440 " ---------------------------------------------------------------------
441 " Load Once: {{{1
442 if &cp || exists("g:loaded_cecutil")
443 finish
444 endif
445 let g:loaded_cecutil = "v18jNR"
446 let s:keepcpo = &cpo
447 set cpo&vim
448 "if exists("g:loaded_Decho") " Decho
449 " DechoRemOn
450 "endif " Decho
451
452 " =======================
453 " Public Interface: {{{1
454 " =======================
455
456 " ---------------------------------------------------------------------
457 " Map Interface: {{{2
458 if !hasmapto('<Plug>SaveWinPosn')
459 map <unique> <Leader>swp <Plug>SaveWinPosn
460 endif
461 if !hasmapto('<Plug>RestoreWinPosn')
462 map <unique> <Leader>rwp <Plug>RestoreWinPosn
463 endif
464 nmap <silent> <Plug>SaveWinPosn :call SaveWinPosn()<CR>
465 nmap <silent> <Plug>RestoreWinPosn :call RestoreWinPosn()<CR>
466
467 " ---------------------------------------------------------------------
468 " Command Interface: {{{2
469 com! -bar -nargs=0 SWP call SaveWinPosn()
470 com! -bar -nargs=? RWP call RestoreWinPosn(<args>)
471 com! -bar -nargs=1 SM call SaveMark(<q-args>)
472 com! -bar -nargs=1 RM call RestoreMark(<q-args>)
473 com! -bar -nargs=1 DM call DestroyMark(<q-args>)
474
475 com! -bar -nargs=1 WLR call s:WinLineRestore(<q-args>)
476
477 if v:version < 630
478 let s:modifier= "sil! "
479 else
480 let s:modifier= "sil! keepj "
481 endif
482
483 " ===============
484 " Functions: {{{1
485 " ===============
486
487 " ---------------------------------------------------------------------
488 " SaveWinPosn: {{{2
489 " let winposn= SaveWinPosn() will save window position in winposn variable
490 " call SaveWinPosn() will save window position in b:cecutil_winposn{b:cecutil_iwinposn}
491 " let winposn= SaveWinPosn(0) will *only* save window position in winposn variable (no stacking done)
492 fun! SaveWinPosn(...)
493 let savedposn= winsaveview()
494 if a:0 == 0
495 if !exists("b:cecutil_iwinposn")
496 let b:cecutil_iwinposn= 1
497 else
498 let b:cecutil_iwinposn= b:cecutil_iwinposn + 1
499 endif
500 " echomsg "Decho: saving posn to SWP stack"
501 let b:cecutil_winposn{b:cecutil_iwinposn}= savedposn
502 endif
503 return savedposn
504 "" echomsg "Decho: SaveWinPosn() a:0=".a:0
505 " if line("$") == 1 && getline(1) == ""
506 "" echomsg "Decho: SaveWinPosn : empty buffer"
507 " return ""
508 " endif
509 " let so_keep = &l:so
510 " let siso_keep = &siso
511 " let ss_keep = &l:ss
512 " setlocal so=0 siso=0 ss=0
513
514 " let swline = line(".") " save-window line in file
515 " let swcol = col(".") " save-window column in file
516 " if swcol >= col("$")
517 " let swcol= swcol + virtcol(".") - virtcol("$") " adjust for virtual edit (cursor past end-of-line)
518 " endif
519 " let swwline = winline() - 1 " save-window window line
520 " let swwcol = virtcol(".") - wincol() " save-window window column
521 " let savedposn = ""
522 "" echomsg "Decho: sw[".swline.",".swcol."] sww[".swwline.",".swwcol."]"
523 " let savedposn = "call GoWinbufnr(".winbufnr(0).")"
524 " let savedposn = savedposn."|".s:modifier.swline
525 " let savedposn = savedposn."|".s:modifier."norm! 0z\<cr>"
526 " if swwline > 0
527 " let savedposn= savedposn.":".s:modifier."call s:WinLineRestore(".(swwline+1).")\<cr>"
528 " endif
529 " if swwcol > 0
530 " let savedposn= savedposn.":".s:modifier."norm! 0".swwcol."zl\<cr>"
531 " endif
532 " let savedposn = savedposn.":".s:modifier."call cursor(".swline.",".swcol.")\<cr>"
533
534 " " save window position in
535 " " b:cecutil_winposn_{iwinposn} (stack)
536 " " only when SaveWinPosn() is used
537 " if a:0 == 0
538 " if !exists("b:cecutil_iwinposn")
539 " let b:cecutil_iwinposn= 1
540 " else
541 " let b:cecutil_iwinposn= b:cecutil_iwinposn + 1
542 " endif
543 "" echomsg "Decho: saving posn to SWP stack"
544 " let b:cecutil_winposn{b:cecutil_iwinposn}= savedposn
545 " endif
546
547 " let &l:so = so_keep
548 " let &siso = siso_keep
549 " let &l:ss = ss_keep
550
551 "" if exists("b:cecutil_iwinposn") " Decho
552 "" echomsg "Decho: b:cecutil_winpos{".b:cecutil_iwinposn."}[".b:cecutil_winposn{b:cecutil_iwinposn}."]"
553 "" else " Decho
554 "" echomsg "Decho: b:cecutil_iwinposn doesn't exist"
555 "" endif " Decho
556 "" echomsg "Decho: SaveWinPosn [".savedposn."]"
557 " return savedposn
558 endfun
559
560 " ---------------------------------------------------------------------
561 " RestoreWinPosn: {{{2
562 " call RestoreWinPosn()
563 " call RestoreWinPosn(winposn)
564 fun! RestoreWinPosn(...)
565 if line("$") == 1 && getline(1) == ""
566 return ""
567 endif
568 if a:0 == 0 || type(a:1) != 4
569 " use saved window position in b:cecutil_winposn{b:cecutil_iwinposn} if it exists
570 if exists("b:cecutil_iwinposn") && exists("b:cecutil_winposn{b:cecutil_iwinposn}")
571 try
572 call winrestview(b:cecutil_winposn{b:cecutil_iwinposn})
573 catch /^Vim\%((\a\+)\)\=:E749/
574 " ignore empty buffer error messages
575 endtry
576 " normally drop top-of-stack by one
577 " but while new top-of-stack doesn't exist
578 " drop top-of-stack index by one again
579 if b:cecutil_iwinposn >= 1
580 unlet b:cecutil_winposn{b:cecutil_iwinposn}
581 let b:cecutil_iwinposn= b:cecutil_iwinposn - 1
582 while b:cecutil_iwinposn >= 1 && !exists("b:cecutil_winposn{b:cecutil_iwinposn}")
583 let b:cecutil_iwinposn= b:cecutil_iwinposn - 1
584 endwhile
585 if b:cecutil_iwinposn < 1
586 unlet b:cecutil_iwinposn
587 endif
588 endif
589 else
590 echohl WarningMsg
591 echomsg "***warning*** need to SaveWinPosn first!"
592 echohl None
593 endif
594
595 else " handle input argument
596 " echomsg "Decho: using input a:1<".a:1.">"
597 " use window position passed to this function
598 call winrestview(a:1)
599 " remove a:1 pattern from b:cecutil_winposn{b:cecutil_iwinposn} stack
600 if exists("b:cecutil_iwinposn")
601 let jwinposn= b:cecutil_iwinposn
602 while jwinposn >= 1 " search for a:1 in iwinposn..1
603 if exists("b:cecutil_winposn{jwinposn}") " if it exists
604 if a:1 == b:cecutil_winposn{jwinposn} " and the pattern matches
605 unlet b:cecutil_winposn{jwinposn} " unlet it
606 if jwinposn == b:cecutil_iwinposn " if at top-of-stack
607 let b:cecutil_iwinposn= b:cecutil_iwinposn - 1 " drop stacktop by one
608 endif
609 endif
610 endif
611 let jwinposn= jwinposn - 1
612 endwhile
613 endif
614 endif
615
616 "" echomsg "Decho: RestoreWinPosn() a:0=".a:0
617 "" echomsg "Decho: getline(1)<".getline(1).">"
618 "" echomsg "Decho: line(.)=".line(".")
619 " if line("$") == 1 && getline(1) == ""
620 "" echomsg "Decho: RestoreWinPosn : empty buffer"
621 " return ""
622 " endif
623 " let so_keep = &l:so
624 " let siso_keep = &l:siso
625 " let ss_keep = &l:ss
626 " setlocal so=0 siso=0 ss=0
627
628 " if a:0 == 0 || a:1 == ""
629 " " use saved window position in b:cecutil_winposn{b:cecutil_iwinposn} if it exists
630 " if exists("b:cecutil_iwinposn") && exists("b:cecutil_winposn{b:cecutil_iwinposn}")
631 "" echomsg "Decho: using stack b:cecutil_winposn{".b:cecutil_iwinposn."}<".b:cecutil_winposn{b:cecutil_iwinposn}.">"
632 " try
633 " exe s:modifier.b:cecutil_winposn{b:cecutil_iwinposn}
634 " catch /^Vim\%((\a\+)\)\=:E749/
635 " " ignore empty buffer error messages
636 " endtry
637 " " normally drop top-of-stack by one
638 " " but while new top-of-stack doesn't exist
639 " " drop top-of-stack index by one again
640 " if b:cecutil_iwinposn >= 1
641 " unlet b:cecutil_winposn{b:cecutil_iwinposn}
642 " let b:cecutil_iwinposn= b:cecutil_iwinposn - 1
643 " while b:cecutil_iwinposn >= 1 && !exists("b:cecutil_winposn{b:cecutil_iwinposn}")
644 " let b:cecutil_iwinposn= b:cecutil_iwinposn - 1
645 " endwhile
646 " if b:cecutil_iwinposn < 1
647 " unlet b:cecutil_iwinposn
648 " endif
649 " endif
650 " else
651 " echohl WarningMsg
652 " echomsg "***warning*** need to SaveWinPosn first!"
653 " echohl None
654 " endif
655
656 " else " handle input argument
657 "" echomsg "Decho: using input a:1<".a:1.">"
658 " " use window position passed to this function
659 " exe a:1
660 " " remove a:1 pattern from b:cecutil_winposn{b:cecutil_iwinposn} stack
661 " if exists("b:cecutil_iwinposn")
662 " let jwinposn= b:cecutil_iwinposn
663 " while jwinposn >= 1 " search for a:1 in iwinposn..1
664 " if exists("b:cecutil_winposn{jwinposn}") " if it exists
665 " if a:1 == b:cecutil_winposn{jwinposn} " and the pattern matches
666 " unlet b:cecutil_winposn{jwinposn} " unlet it
667 " if jwinposn == b:cecutil_iwinposn " if at top-of-stack
668 " let b:cecutil_iwinposn= b:cecutil_iwinposn - 1 " drop stacktop by one
669 " endif
670 " endif
671 " endif
672 " let jwinposn= jwinposn - 1
673 " endwhile
674 " endif
675 " endif
676
677 " " Seems to be something odd: vertical motions after RWP
678 " " cause jump to first column. The following fixes that.
679 " " Note: was using wincol()>1, but with signs, a cursor
680 " " at column 1 yields wincol()==3. Beeping ensued.
681 " let vekeep= &ve
682 " set ve=all
683 " if virtcol('.') > 1
684 " exe s:modifier."norm! hl"
685 " elseif virtcol(".") < virtcol("$")
686 " exe s:modifier."norm! lh"
687 " endif
688 " let &ve= vekeep
689
690 " let &l:so = so_keep
691 " let &l:siso = siso_keep
692 " let &l:ss = ss_keep
693
694 "" echomsg "Decho: RestoreWinPosn"
695 endfun
696
697 " ---------------------------------------------------------------------
698 " s:WinLineRestore: {{{2
699 fun! s:WinLineRestore(swwline)
700 " echomsg "Decho: s:WinLineRestore(swwline=".a:swwline.")"
701 while winline() < a:swwline
702 let curwinline= winline()
703 exe s:modifier."norm! \<c-y>"
704 if curwinline == winline()
705 break
706 endif
707 endwhile
708 " echomsg "Decho: s:WinLineRestore"
709 endfun
710
711 " ---------------------------------------------------------------------
712 " GoWinbufnr: go to window holding given buffer (by number) {{{2
713 " Prefers current window; if its buffer number doesn't match,
714 " then will try from topleft to bottom right
715 fun! GoWinbufnr(bufnum)
716 " call Dfunc("GoWinbufnr(".a:bufnum.")")
717 if winbufnr(0) == a:bufnum
718 " call Dret("GoWinbufnr : winbufnr(0)==a:bufnum")
719 return
720 endif
721 winc t
722 let first=1
723 while winbufnr(0) != a:bufnum && (first || winnr() != 1)
724 winc w
725 let first= 0
726 endwhile
727 " call Dret("GoWinbufnr")
728 endfun
729
730 " ---------------------------------------------------------------------
731 " SaveMark: sets up a string saving a mark position. {{{2
732 " For example, SaveMark("a")
733 " Also sets up a global variable, g:savemark_{markname}
734 fun! SaveMark(markname)
735 " call Dfunc("SaveMark(markname<".string(a:markname).">)")
736 let markname= a:markname
737 if strpart(markname,0,1) !~ '\a'
738 let markname= strpart(markname,1,1)
739 endif
740 " call Decho("markname=".string(markname))
741
742 let lzkeep = &lz
743 set lz
744
745 if 1 <= line("'".markname) && line("'".markname) <= line("$")
746 let winposn = SaveWinPosn(0)
747 exe s:modifier."norm! `".markname
748 let savemark = SaveWinPosn(0)
749 let g:savemark_{markname} = savemark
750 let savemark = markname.string(savemark)
751 call RestoreWinPosn(winposn)
752 else
753 let g:savemark_{markname} = ""
754 let savemark = ""
755 endif
756
757 let &lz= lzkeep
758
759 " call Dret("SaveMark : savemark<".savemark.">")
760 return savemark
761 endfun
762
763 " ---------------------------------------------------------------------
764 " RestoreMark: {{{2
765 " call RestoreMark("a") -or- call RestoreMark(savemark)
766 fun! RestoreMark(markname)
767 " call Dfunc("RestoreMark(markname<".a:markname.">)")
768
769 if strlen(a:markname) <= 0
770 " call Dret("RestoreMark : no such mark")
771 return
772 endif
773 let markname= strpart(a:markname,0,1)
774 if markname !~ '\a'
775 " handles 'a -> a styles
776 let markname= strpart(a:markname,1,1)
777 endif
778 " call Decho("markname=".markname." strlen(a:markname)=".strlen(a:markname))
779
780 let lzkeep = &lz
781 set lz
782 let winposn = SaveWinPosn(0)
783
784 if strlen(a:markname) <= 2
785 if exists("g:savemark_{markname}")
786 " use global variable g:savemark_{markname}
787 " call Decho("use savemark list")
788 call RestoreWinPosn(g:savemark_{markname})
789 exe "norm! m".markname
790 endif
791 else
792 " markname is a savemark command (string)
793 " call Decho("use savemark command")
794 let markcmd= strpart(a:markname,1)
795 call RestoreWinPosn(markcmd)
796 exe "norm! m".markname
797 endif
798
799 call RestoreWinPosn(winposn)
800 let &lz = lzkeep
801
802 " call Dret("RestoreMark")
803 endfun
804
805 " ---------------------------------------------------------------------
806 " DestroyMark: {{{2
807 " call DestroyMark("a") -- destroys mark
808 fun! DestroyMark(markname)
809 " call Dfunc("DestroyMark(markname<".a:markname.">)")
810
811 " save options and set to standard values
812 let reportkeep= &report
813 let lzkeep = &lz
814 set lz report=10000
815
816 let markname= strpart(a:markname,0,1)
817 if markname !~ '\a'
818 " handles 'a -> a styles
819 let markname= strpart(a:markname,1,1)
820 endif
821 " call Decho("markname=".markname)
822
823 let curmod = &mod
824 let winposn = SaveWinPosn(0)
825 1
826 let lineone = getline(".")
827 exe "k".markname
828 d
829 put! =lineone
830 let &mod = curmod
831 call RestoreWinPosn(winposn)
832
833 " restore options to user settings
834 let &report = reportkeep
835 let &lz = lzkeep
836
837 " call Dret("DestroyMark")
838 endfun
839
840 " ---------------------------------------------------------------------
841 " QArgSplitter: to avoid \ processing by <f-args>, <q-args> is needed. {{{2
842 " However, <q-args> doesn't split at all, so this one returns a list
843 " with splits at all whitespace (only!), plus a leading length-of-list.
844 " The resulting list: qarglist[0] corresponds to a:0
845 " qarglist[i] corresponds to a:{i}
846 fun! QArgSplitter(qarg)
847 " call Dfunc("QArgSplitter(qarg<".a:qarg.">)")
848 let qarglist = split(a:qarg)
849 let qarglistlen = len(qarglist)
850 let qarglist = insert(qarglist,qarglistlen)
851 " call Dret("QArgSplitter ".string(qarglist))
852 return qarglist
853 endfun
854
855 " ---------------------------------------------------------------------
856 " ListWinPosn: {{{2
857 "fun! ListWinPosn() " Decho
858 " if !exists("b:cecutil_iwinposn") || b:cecutil_iwinposn == 0 " Decho
859 " call Decho("nothing on SWP stack") " Decho
860 " else " Decho
861 " let jwinposn= b:cecutil_iwinposn " Decho
862 " while jwinposn >= 1 " Decho
863 " if exists("b:cecutil_winposn{jwinposn}") " Decho
864 " call Decho("winposn{".jwinposn."}<".b:cecutil_winposn{jwinposn}.">") " Decho
865 " else " Decho
866 " call Decho("winposn{".jwinposn."} -- doesn't exist") " Decho
867 " endif " Decho
868 " let jwinposn= jwinposn - 1 " Decho
869 " endwhile " Decho
870 " endif " Decho
871 "endfun " Decho
872 "com! -nargs=0 LWP call ListWinPosn() " Decho
873
874 " ---------------------------------------------------------------------
875 " SaveUserMaps: this function sets up a script-variable (s:restoremap) {{{2
876 " which can be used to restore user maps later with
877 " call RestoreUserMaps()
878 "
879 " mapmode - see :help maparg for details (n v o i c l "")
880 " ex. "n" = Normal
881 " The letters "b" and "u" are optional prefixes;
882 " The "u" means that the map will also be unmapped
883 " The "b" means that the map has a <buffer> qualifier
884 " ex. "un" = Normal + unmapping
885 " ex. "bn" = Normal + <buffer>
886 " ex. "bun" = Normal + <buffer> + unmapping
887 " ex. "ubn" = Normal + <buffer> + unmapping
888 " maplead - see mapchx
889 " mapchx - "<something>" handled as a single map item.
890 " ex. "<left>"
891 " - "string" a string of single letters which are actually
892 " multiple two-letter maps (using the maplead:
893 " maplead . each_character_in_string)
894 " ex. maplead="\" and mapchx="abc" saves user mappings for
895 " \a, \b, and \c
896 " Of course, if maplead is "", then for mapchx="abc",
897 " mappings for a, b, and c are saved.
898 " - :something handled as a single map item, w/o the ":"
899 " ex. mapchx= ":abc" will save a mapping for "abc"
900 " suffix - a string unique to your plugin
901 " ex. suffix= "DrawIt"
902 fun! SaveUserMaps(mapmode,maplead,mapchx,suffix)
903 " call Dfunc("SaveUserMaps(mapmode<".a:mapmode."> maplead<".a:maplead."> mapchx<".a:mapchx."> suffix<".a:suffix.">)")
904
905 if !exists("s:restoremap_{a:suffix}")
906 " initialize restoremap_suffix to null string
907 let s:restoremap_{a:suffix}= ""
908 endif
909
910 " set up dounmap: if 1, then save and unmap (a:mapmode leads with a "u")
911 " if 0, save only
912 let mapmode = a:mapmode
913 let dounmap = 0
914 let dobuffer = ""
915 while mapmode =~# '^[bu]'
916 if mapmode =~# '^u'
917 let dounmap = 1
918 let mapmode = strpart(a:mapmode,1)
919 elseif mapmode =~# '^b'
920 let dobuffer = "<buffer> "
921 let mapmode = strpart(a:mapmode,1)
922 endif
923 endwhile
924 " call Decho("dounmap=".dounmap." dobuffer<".dobuffer.">")
925
926 " save single map :...something...
927 if strpart(a:mapchx,0,1) == ':'
928 " call Decho("save single map :...something...")
929 let amap= strpart(a:mapchx,1)
930 if amap == "|" || amap == "\<c-v>"
931 let amap= "\<c-v>".amap
932 endif
933 let amap = a:maplead.amap
934 let s:restoremap_{a:suffix} = s:restoremap_{a:suffix}."|:sil! ".mapmode."unmap ".dobuffer.amap
935 if maparg(amap,mapmode) != ""
936 let maprhs = substitute(maparg(amap,mapmode),'|','<bar>','ge')
937 let s:restoremap_{a:suffix} = s:restoremap_{a:suffix}."|:".mapmode."map ".dobuffer.amap." ".maprhs
938 endif
939 if dounmap
940 exe "sil! ".mapmode."unmap ".dobuffer.amap
941 endif
942
943 " save single map <something>
944 elseif strpart(a:mapchx,0,1) == '<'
945 " call Decho("save single map <something>")
946 let amap = a:mapchx
947 if amap == "|" || amap == "\<c-v>"
948 let amap= "\<c-v>".amap
949 " call Decho("amap[[".amap."]]")
950 endif
951 let s:restoremap_{a:suffix} = s:restoremap_{a:suffix}."|sil! ".mapmode."unmap ".dobuffer.amap
952 if maparg(a:mapchx,mapmode) != ""
953 let maprhs = substitute(maparg(amap,mapmode),'|','<bar>','ge')
954 let s:restoremap_{a:suffix} = s:restoremap_{a:suffix}."|".mapmode."map ".dobuffer.amap." ".maprhs
955 endif
956 if dounmap
957 exe "sil! ".mapmode."unmap ".dobuffer.amap
958 endif
959
960 " save multiple maps
961 else
962 " call Decho("save multiple maps")
963 let i= 1
964 while i <= strlen(a:mapchx)
965 let amap= a:maplead.strpart(a:mapchx,i-1,1)
966 if amap == "|" || amap == "\<c-v>"
967 let amap= "\<c-v>".amap
968 endif
969 let s:restoremap_{a:suffix} = s:restoremap_{a:suffix}."|sil! ".mapmode."unmap ".dobuffer.amap
970 if maparg(amap,mapmode) != ""
971 let maprhs = substitute(maparg(amap,mapmode),'|','<bar>','ge')
972 let s:restoremap_{a:suffix} = s:restoremap_{a:suffix}."|".mapmode."map ".dobuffer.amap." ".maprhs
973 endif
974 if dounmap
975 exe "sil! ".mapmode."unmap ".dobuffer.amap
976 endif
977 let i= i + 1
978 endwhile
979 endif
980 " call Dret("SaveUserMaps : s:restoremap_".a:suffix.": ".s:restoremap_{a:suffix})
981 endfun
982
983 " ---------------------------------------------------------------------
984 " RestoreUserMaps: {{{2
985 " Used to restore user maps saved by SaveUserMaps()
986 fun! RestoreUserMaps(suffix)
987 " call Dfunc("RestoreUserMaps(suffix<".a:suffix.">)")
988 if exists("s:restoremap_{a:suffix}")
989 let s:restoremap_{a:suffix}= substitute(s:restoremap_{a:suffix},'|\s*$','','e')
990 if s:restoremap_{a:suffix} != ""
991 " call Decho("exe ".s:restoremap_{a:suffix})
992 exe "sil! ".s:restoremap_{a:suffix}
993 endif
994 unlet s:restoremap_{a:suffix}
995 endif
996 " call Dret("RestoreUserMaps")
997 endfun
998
999 " ==============
1000 " Restore: {{{1
1001 " ==============
1002 let &cpo= s:keepcpo
1003 unlet s:keepcpo
1004
1005 " ================
1006 " Modelines: {{{1
1007 " ================
1008 " vim: ts=4 fdm=marker
1009 vis/doc/vis.txt [[[1
1010 247
1011 *vis.txt* The Visual Block Tool Sep 07, 2016
1012
1013 Author: Charles E. Campbell <[email protected]>
1014 (remove NOSPAM from Campbell's email first)
1015 Copyright: (c) 2004-2016 by Charles E. Campbell *vis-copyright*
1016 The VIM LICENSE applies to vis.vim and vis.txt
1017 (see |copyright|) except use "vis" instead of "Vim"
1018 No warranty, express or implied. Use At-Your-Own-Risk.
1019
1020
1021 ==============================================================================
1022 1. Contents *vis* *vis-contents* *vis.vim*
1023
1024 1. Contents......................: |vis-contents|
1025 2. Visual Block Manual...........: |vis-manual|
1026 3. Visual Block Search...........: |vis-srch|
1027 4. Required......................: |vis-required|
1028 5. Sorting Examples..............: |vis-sort|
1029 6. History.......................: |vis-history|
1030
1031
1032 ==============================================================================
1033 2. Visual Block Manual *visman* *vismanual* *vis-manual* *v_:B*
1034
1035 Performs an arbitrary Ex command on a visual highlighted block.
1036
1037 Mark visual block (CTRL-V) or visual character (v),
1038 press ':B ' and enter an Ex command [cmd].
1039
1040 ex. Use ctrl-v to visually mark the block then use
1041 :B cmd (will appear as :'<,'>B cmd )
1042
1043 ex. Use v to visually mark the block then use
1044 :B cmd (will appear as :'<,'>B cmd )
1045
1046 Command-line completion is supported for Ex commands.
1047
1048 There must be a space before the '!' when invoking external shell
1049 commands, eg. ':B !sort'. Otherwise an error is reported.
1050
1051 The script works by deleting the selected region into register "a.
1052 The register "a itself is first saved and later restored. The text is
1053 then put at the end-of-file, modified by the user command, and then
1054 deleted back into register "a. Any excess lines are removed, and the
1055 modified text is then put back into the text at its original
1056 location.
1057
1058 Popular uses for this command include: >
1059
1060 :B s/pattern/output/
1061 :B left
1062 :B right
1063 <
1064 1: apply a substitute command to just the selected visual block,
1065 2: left justify the selected block, and
1066 3: right justify the selected block, respectively.
1067
1068 The concept for this plugin is originally Stefan Roemer's
1069 <[email protected]>; however, both the implementation
1070 and methods used internally have completely changed since Roemer's
1071 version.
1072
1073 *g:vis_empty_character* : this character should not appear in your
1074 text. By default: users of euc-jp will get a 0x01, otherwise
1075 it wil be a 0xff. Used to prevent an empty result in the
1076 moving back the modified text operation, which otherwise results
1077 in an unwanted extra blank space being inserted.
1078
1079
1080 ==============================================================================
1081 3. Visual Block Search *vis-search* *vis-srch* *vis-S*
1082
1083 Visual block search provides two ways to get visual-selection
1084 based searches. Both these methods work well with :set hls
1085 and searching may be repeated with the n or N commands.
1086
1087 Using // and ?? after a visual selection (the // is only available
1088 if you have g:vis_WantSlashSlash=1 in your <.vimrc> file):
1089 >
1090 ex. select region via V, v, or ctrl-v
1091 //pattern
1092 <
1093 You'll actually get a long leader string of commands to restrict
1094 searches to the requested visual block first. You may then enter
1095 the pattern afterwards. For example, using "v" to select this
1096 paragraph, you'll see something like: >
1097
1098 /\%(\%(\%80l\%>12v\)\|\%(\%83l\%<53v\)\|\%(\%>80l\%<83l\)\)\&
1099 <
1100 You may enter whatever pattern you want after the \&, and the
1101 pattern search will be restricted to the requested region.
1102
1103 The "S" command in visual mode:
1104 >
1105 ex. select region via V, v, or ctrl-v
1106 :S pattern
1107 <
1108 The ":S pattern" will appear as ":'<,'>S pattern". This
1109 command will move the cursor to the next instance of the
1110 pattern, restricted to the visually selected block.
1111
1112 An "R" command was contemplated, but I currently see no way to
1113 get it to continue to search backwards with n and N commands.
1114
1115
1116 ==============================================================================
1117 4. Required *vis-required*
1118
1119 The latest <vis.vim> (v20f or later) now requires vim 7.0 (or later),
1120 as it has been split into plugin/ and an autoload/ sections for
1121 on-demand loading.
1122
1123 Starting with version 11, <vis.vim> required <cecutil.vim>. It uses
1124 the SaveWinPosn() and RestoreWinPosn() functions therein. You may get
1125 <cecutil.vim> from
1126
1127 http://www.drchip.org/astronaut/vim/index.html#CECUTIL
1128
1129
1130 ==============================================================================
1131 5. Sorting Examples *vis-sort*
1132
1133 Assume we start with the following three lines: >
1134
1135 one two three
1136 four five six
1137 seven eight nine
1138 <
1139 Example 1: Use visual-block mode to select the center three
1140 words: ctrl-v select two/five/eight, then :'<,'>sort: >
1141
1142 four five six
1143 one two three
1144 seven eight nine
1145 <
1146 Note that the visual-block is ignored, other than as a way to
1147 select the three lines. The resulting sorting is done on the
1148 three words "one/four/seven".
1149
1150 (this example presumed that you're using vim 7.0; if you're using
1151 an earlier version vim, try :'<,\> !sort instead)
1152
1153 Example 2: Using vis.vim's B command:
1154 Again, use visual-block mode to select the center
1155 three words: ctrl-v select two/five/eight, then :'<,'>B sort: >
1156
1157 one eight three
1158 four five six
1159 seven two nine
1160 <
1161 This operation sorts the selected three words (two/five/eight),
1162 leaving all characters outside the visual block alone.
1163
1164 (this example presumed that you're using vim 7.0; if you're using
1165 an earlier version vim, try :'<,\> !sort instead)
1166
1167 Example 3: Using vissort.vim's Vissort() function
1168 Use visual block mode to select the center three words;
1169 ctrl-v select two/five/eight, then :'<,'>Vissort: >
1170
1171 seven eight nine
1172 four five six
1173 one two three
1174 <
1175 This time, the entire lines are sorted, but the sorting is done
1176 based on the visual-block selected region (ie. two/five/eight).
1177
1178
1179 ==============================================================================
1180 6. History *vis-history* {{{1
1181
1182 v21 : Apr 01, 2013 - visual block and ragged right detection; there was
1183 a conflict between using ve= and ve=all
1184 (internally); one was good for ragged right and
1185 the other for smooth right visual block selections.
1186 I found a way to detect ragged right vs smooth right
1187 and so vis.vim now works properly in both
1188 situations.
1189 Apr 02, 2013 - The detection method above hung when on line 1.
1190 Fixed.
1191 Jan 15, 2015 - Small adjustment to prevent a leading space from
1192 being inserted.
1193 Feb 10, 2016 - (Stefan Siegal) provided a patch making
1194 visPlugin.vim restore cpo
1195 Sep 07, 2016 - addressed an empty-string bug : if the block
1196 command causes an empty string to appear in the
1197 modified text, vim would insert a blank rather than
1198 do nothing. Fixed by prepending an
1199 "empty-character" and then removing it
1200 v20 : May 20, 2009 - cecutil bugfix
1201 May 19, 2010 - split into plugin/ and autoload/ for faster
1202 loading and on-demand loading.
1203 Mar 18, 2013 - (Gary Johnson) pointed out that changing
1204 cedit to <Esc> caused problems with visincr;
1205 the cedit setting is now bypassed in vis, too.
1206 Mar 29, 2013 - Fixed a problem with vis#VisBlockCmd() where it
1207 missed substitutes due to a short last line.
1208 s:SaveUserSettings() now makes ve=all instead of
1209 ve= (see |'ve'|)
1210 v19 : Jan 06, 2006 - small modification included to allow AlignMaps
1211 maps to work (visual select, :B norm \somemap)
1212 - cecutil updated to use keepjumps
1213 Jan 24, 2006 - works around formatoption setting
1214 Jan 25, 2006 - uses SaveWinPosn(0) to avoid SWP stack use
1215 v18 : Jul 11, 2005 - vis.vim now works around a virtcol() behavior
1216 difference between ve=all vs ve=block
1217 v17 : Apr 25, 2005 - vis.vim now uses cecutil (SaveWinPosn, etc) so the
1218 tarball now includes a copy of cecutil.vim
1219 v16 : Feb 02, 2005 - fixed a bug with visual-block + S ; the first line
1220 was being omitted in the search
1221 Mar 01, 2005 - <q-args> used instead of '<args>'
1222 Apr 13, 2005 - :'<,'>S plus v had a bug with one or two line
1223 selections (tnx to Vigil for pointing this out)
1224 Apr 14, 2005 - set ignorecase caused visual-block searching
1225 to confuse visual modes "v" and "V"
1226 v15 : Feb 01, 2005 - includes some additions to the help
1227 v14 : Sep 28, 2004 - visual-block based searching now supported. One
1228 do this either with :'<,'>S pattern or with a / or ?
1229 Jan 31, 2005 - fixed help file
1230 v13 : Jul 16, 2004 - folding commands added to source
1231 - GetLatestVimScript hook added for automatic updating
1232 v12 : Jun 14, 2004 - bugfix (folding interfered)
1233 v11 : May 18, 2004 - Included calls to SaveWinPosn() and RestoreWinPosn()
1234 to prevent unwanted movement of the cursor and window.
1235 As a result, <vis.vim> now requires <cecutil.vim>
1236 (see |vis-required|).
1237 v10 : Feb 11, 2003 - bugfix (ignorecase option interfered with v)
1238 v9 : Sep 10, 2002 - bugfix (left Decho on, now commented out)
1239 v8 : Sep 09, 2002 - bugfix (first column problem)
1240 v7 : Sep 05, 2002 - bugfix (was forcing begcol<endcol for "v" mode)
1241 v6 : Jun 25, 2002 - bugfix (VirtcolM1 instead of virtcol()-1)
1242 v5 : Jun 21, 2002 - now supports character-visual mode (v) and
1243 linewise-visual mode (V)
1244 v4 : Jun 20, 2002 - saves sol, sets nosol, restores sol
1245 - bugfix: 0 inserted: 0\<c-v>G$\"ad
1246 - Fixed double-loading (was commented
1247 out for debugging purposes)
1248 v3 : Jun 20, 2002 - saves ve, unsets ve, restores ve
1249 v2 : June 19, 2002 - Charles Campbell's <vis.vim>
1250 v? June 19, 2002 Complete rewrite - <vis.vim> is now immune to
1251 the presence of tabs and is considerably faster.
1252 v1 Epoch - Stefan Roemer <[email protected]>
1253 wrote the original <vis.vim>.
1254
1255 ==============================================================================
1256 Modelines: {{{1
1257 vim:tw=78:ts=8:ft=help:fdm=marker
1258 proofread/syntax/proofread.vim [[[1
1259 17
1260 " escape sequences for package proofread.sty
1261 map <Esc>d s\del{}<Esc>hp
1262 map <Esc>y s\yel[]{}<Esc>PF[li
1263 map <Esc>a a\add{}<Esc>i
1264 map <Esc>i i\add{}<Esc>i
1265 map <Esc>r s\rep{}{}<Esc>2F{plla
1266 map <Esc>c a\com{}<Esc>i
1267 map <Esc>n /\\\(add\\|del\\|com\\|hilite\\|rep\\|yel\)<Enter>//e<Enter>h
1268 map <Esc>u ?\\\(\(\(hilite\\|yel\)\(\[\_[^\]]*\]\)\{0,1}\)\\|\(rep{\_[^}]\{-}}\)\\|\(com\\|del\\|add\)\){\_.\{-}}<Enter>m`v//e<Enter>:B !proofread undo<Enter>0f→xXx``
1269 map <Esc>h ?\\\(\(\(hilite\\|yel\)\(\[\_[^\]]*\]\)\{0,1}\)\\|\(rep{\_[^}]\{-}}\)\\|\(com\\|del\\|add\)\){\_.\{-}}<Enter>m`v//e<Enter>:B !proofread honor<Enter>0f→xXx``
1270
1271 " ?\\\(\(\(hilite\\|yel\)\(\[\_[^\]]*\]\)\{0,1}\)\\|\(rep{\_[^}]*}\)\\|\(com\\|del\\|add\)\){\_[^}]*} ^ ^ ^
1272 " < < <--hilite/yel-> <--[.....]----> > <--\rep{...}--> <--com/del/add---> ><--{...}--> | | |
1273 " | |_______________________________________| | save position remove ruby scripts' marker back to position
1274 " |____________________________________________________________________________________|
1275
1276 set syntax=tex
1277 ../bin/proofread [[[1
1278 20
1279 #!/usr/bin/env ruby
1280 # coding: utf-8
1281 buffer = STDIN.readlines.map { |v| v.strip }.join('→')
1282 if ARGV[0] == 'undo'
1283 print buffer.
1284 sub(/\\del{(.*)}/, '\1').
1285 sub(/\\com{.*}/, '').
1286 sub(/\\add{.*}/, '').
1287 sub(/\\rep{(.*)}{.*}/, '\1').
1288 sub(/\\(yel|hilite)(\[.*\])*{(.*)}/, '\3').
1289 tr('→', "\n")
1290 else
1291 print buffer.
1292 sub(/\\del{(.*)}/, '').
1293 sub(/\\com{.*}/, '').
1294 sub(/\\add{(.*)}/, '\1').
1295 sub(/\\rep{.*}{(.*)}/, '\1').
1296 sub(/\\(yel|hilite)(\[.*\])*{(.*)}/, '\3').
1297 tr('→', "\n")
1298 end