runtime(doc): update formatting and syntax

closes: #15800

Signed-off-by: Milly <milly.ca@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
Milly
2024-10-05 17:16:18 +02:00
committed by Christian Brabandt
parent af449f69c7
commit 89872f58a9
15 changed files with 65 additions and 59 deletions

View File

@ -1,4 +1,4 @@
*if_tcl.txt* For Vim version 9.1. Last change: 2022 Jan 08
*if_tcl.txt* For Vim version 9.1. Last change: 2024 Oct 05
VIM REFERENCE MANUAL by Ingo Wilken
@ -461,14 +461,14 @@ Input from stdin is currently not supported.
Here are a few small (and maybe useful) Tcl scripts.
This script sorts the lines of the entire buffer (assume it contains a list
of names or something similar):
of names or something similar): >
set buf $::vim::current(buffer)
set lines [$buf get top bottom]
set lines [lsort -dictionary $lines]
$buf set top bottom $lines
This script reverses the lines in the buffer. Note the use of "::vim::lbase"
and "$buf last" to work with any line number setting.
and "$buf last" to work with any line number setting: >
set buf $::vim::current(buffer)
set t $::vim::lbase
set b [$buf last]
@ -481,7 +481,7 @@ and "$buf last" to work with any line number setting.
incr b -1
}
This script adds a consecutive number to each line in the current range:
This script adds a consecutive number to each line in the current range: >
set buf $::vim::current(buffer)
set i $::vim::range(start)
set n 1
@ -491,17 +491,17 @@ This script adds a consecutive number to each line in the current range:
incr i ; incr n
}
The same can also be done quickly with two Ex commands, using ":tcldo":
The same can also be done quickly with two Ex commands, using ":tcldo": >
:tcl set n 1
:[range]tcldo set line "$n\t$line" ; incr n
This procedure runs an Ex command on each buffer (idea stolen from Ron Aaron):
This procedure runs an Ex command on each buffer (idea stolen from Ron Aaron): >
proc eachbuf { cmd } {
foreach b [::vim::buffer list] {
$b command $cmd
}
}
Use it like this:
Use it like this: >
:tcl eachbuf %s/foo/bar/g
Be careful with Tcl's string and backslash substitution, tough. If in doubt,
surround the Ex command with curly braces.
@ -509,7 +509,7 @@ surround the Ex command with curly braces.
If you want to add some Tcl procedures permanently to vim, just place them in
a file (e.g. "~/.vimrc.tcl" on Unix machines), and add these lines to your
startup file (usually "~/.vimrc" on Unix):
startup file (usually "~/.vimrc" on Unix): >
if has("tcl")
tclfile ~/.vimrc.tcl
endif