1- *if_tcl.txt* For Vim version 9.1. Last change: 2022 Jan 08
1+ *if_tcl.txt* For Vim version 9.1. Last change: 2024 Oct 05
22
33
44 VIM REFERENCE MANUAL by Ingo Wilken
@@ -461,14 +461,14 @@ Input from stdin is currently not supported.
461461Here are a few small (and maybe useful) Tcl scripts.
462462
463463This script sorts the lines of the entire buffer (assume it contains a list
464- of names or something similar):
464+ of names or something similar): >
465465 set buf $::vim::current(buffer)
466466 set lines [$buf get top bottom]
467467 set lines [lsort -dictionary $lines]
468468 $buf set top bottom $lines
469469
470470 This script reverses the lines in the buffer. Note the use of "::vim::lbase"
471- and "$buf last" to work with any line number setting.
471+ and "$buf last" to work with any line number setting: >
472472 set buf $::vim::current(buffer)
473473 set t $::vim::lbase
474474 set b [$buf last]
@@ -481,7 +481,7 @@ and "$buf last" to work with any line number setting.
481481 incr b -1
482482 }
483483
484- This script adds a consecutive number to each line in the current range:
484+ This script adds a consecutive number to each line in the current range: >
485485 set buf $::vim::current(buffer)
486486 set i $::vim::range(start)
487487 set n 1
@@ -491,25 +491,25 @@ This script adds a consecutive number to each line in the current range:
491491 incr i ; incr n
492492 }
493493
494- The same can also be done quickly with two Ex commands, using ":tcldo":
494+ The same can also be done quickly with two Ex commands, using ":tcldo": >
495495 :tcl set n 1
496496 :[range]tcldo set line "$n\t$line" ; incr n
497497
498- This procedure runs an Ex command on each buffer (idea stolen from Ron Aaron):
498+ This procedure runs an Ex command on each buffer (idea stolen from Ron Aaron): >
499499 proc eachbuf { cmd } {
500500 foreach b [::vim::buffer list] {
501501 $b command $cmd
502502 }
503503 }
504- Use it like this:
504+ Use it like this: >
505505 :tcl eachbuf %s/foo/bar/g
506506 Be careful with Tcl's string and backslash substitution, tough. If in doubt,
507507surround the Ex command with curly braces.
508508
509509
510510If you want to add some Tcl procedures permanently to vim, just place them in
511511a file (e.g. "~/.vimrc.tcl" on Unix machines), and add these lines to your
512- startup file (usually "~/.vimrc" on Unix):
512+ startup file (usually "~/.vimrc" on Unix): >
513513 if has("tcl")
514514 tclfile ~/.vimrc.tcl
515515 endif
0 commit comments