Mercurial > vim
comparison runtime/doc/if_tcl.txt @ 2033:de5a43c5eedc
Update documentation files.
author | Bram Moolenaar <bram@zimbu.org> |
---|---|
date | Wed, 06 Jan 2010 20:52:26 +0100 |
parents | 5232b9862f23 |
children | 7c8c7c95a865 |
comparison
equal
deleted
inserted
replaced
2032:592032e9e167 | 2033:de5a43c5eedc |
---|---|
1 *if_tcl.txt* For Vim version 7.2. Last change: 2008 Jun 26 | 1 *if_tcl.txt* For Vim version 7.2. Last change: 2008 Aug 16 |
2 | 2 |
3 | 3 |
4 VIM REFERENCE MANUAL by Ingo Wilken | 4 VIM REFERENCE MANUAL by Ingo Wilken |
5 | 5 |
6 | 6 |
81 The following commands are implemented: > | 81 The following commands are implemented: > |
82 | 82 |
83 ::vim::beep # Guess. | 83 ::vim::beep # Guess. |
84 ::vim::buffer {n} # Create Tcl command for one buffer. | 84 ::vim::buffer {n} # Create Tcl command for one buffer. |
85 ::vim::buffer list # Create Tcl commands for all buffers. | 85 ::vim::buffer list # Create Tcl commands for all buffers. |
86 ::vim::command [-quiet] {cmd} # Execute an ex command. | 86 ::vim::command [-quiet] {cmd} # Execute an Ex command. |
87 ::vim::expr {expr} # Use Vim's expression evaluator. | 87 ::vim::expr {expr} # Use Vim's expression evaluator. |
88 ::vim::option {opt} # Get vim option. | 88 ::vim::option {opt} # Get vim option. |
89 ::vim::option {opt} {val} # Set vim option. | 89 ::vim::option {opt} {val} # Set vim option. |
90 ::vim::window list # Create Tcl commands for all windows. | 90 ::vim::window list # Create Tcl commands for all windows. |
91 | 91 |
114 < This command might be replaced by a variable in future versions. | 114 < This command might be replaced by a variable in future versions. |
115 See also |tcl-var-current| for the current buffer. | 115 See also |tcl-var-current| for the current buffer. |
116 | 116 |
117 ::vim::command {cmd} *tcl-command* | 117 ::vim::command {cmd} *tcl-command* |
118 ::vim::command -quiet {cmd} | 118 ::vim::command -quiet {cmd} |
119 Execute the vim (ex-mode) command {cmd}. Any ex command that affects | 119 Execute the vim (ex-mode) command {cmd}. Any Ex command that affects |
120 a buffer or window uses the current buffer/current window. Does not | 120 a buffer or window uses the current buffer/current window. Does not |
121 return a result other than a standard Tcl error code. After this | 121 return a result other than a standard Tcl error code. After this |
122 command is completed, the "::vim::current" variable is updated. | 122 command is completed, the "::vim::current" variable is updated. |
123 The "-quiet" flag suppresses any error messages from vim. | 123 The "-quiet" flag suppresses any error messages from vim. |
124 Examples: > | 124 Examples: > |
208 range. "begin" is the same as "start". This variable is read-only. | 208 range. "begin" is the same as "start". This variable is read-only. |
209 See |tcl-examples|. | 209 See |tcl-examples|. |
210 | 210 |
211 line *tcl-var-line* | 211 line *tcl-var-line* |
212 lnum *tcl-var-lnum* | 212 lnum *tcl-var-lnum* |
213 These global variables are only available if the ":tcldo" ex command | 213 These global variables are only available if the ":tcldo" Ex command |
214 is being executed. They contain the text and line number of the | 214 is being executed. They contain the text and line number of the |
215 current line. When the Tcl command invoked by ":tcldo" is completed, | 215 current line. When the Tcl command invoked by ":tcldo" is completed, |
216 the current line is set to the contents of the "line" variable, unless | 216 the current line is set to the contents of the "line" variable, unless |
217 the variable was unset by the Tcl command. The "lnum" variable is | 217 the variable was unset by the Tcl command. The "lnum" variable is |
218 read-only. These variables are not in the "::vim" namespace so they | 218 read-only. These variables are not in the "::vim" namespace so they |
231 | 231 |
232 Let's assume the name of the window command is stored in the Tcl variable "win", | 232 Let's assume the name of the window command is stored in the Tcl variable "win", |
233 i.e. "$win" calls the command. The following options are available: > | 233 i.e. "$win" calls the command. The following options are available: > |
234 | 234 |
235 $win buffer # Create Tcl command for window's buffer. | 235 $win buffer # Create Tcl command for window's buffer. |
236 $win command {cmd} # Execute ex command in windows context. | 236 $win command {cmd} # Execute Ex command in windows context. |
237 $win cursor # Get current cursor position. | 237 $win cursor # Get current cursor position. |
238 $win cursor {var} # Set cursor position from array variable. | 238 $win cursor {var} # Set cursor position from array variable. |
239 $win cursor {row} {col} # Set cursor position. | 239 $win cursor {row} {col} # Set cursor position. |
240 $win delcmd {cmd} # Call Tcl command when window is closed. | 240 $win delcmd {cmd} # Call Tcl command when window is closed. |
241 $win expr {expr} # Evaluate vim expression in windows context. | 241 $win expr {expr} # Evaluate vim expression in windows context. |
310 | 310 |
311 Let's assume the name of the buffer command is stored in the Tcl variable "buf", | 311 Let's assume the name of the buffer command is stored in the Tcl variable "buf", |
312 i.e. "$buf" calls the command. The following options are available: > | 312 i.e. "$buf" calls the command. The following options are available: > |
313 | 313 |
314 $buf append {n} {str} # Append a line to buffer, after line {n}. | 314 $buf append {n} {str} # Append a line to buffer, after line {n}. |
315 $buf command {cmd} # Execute ex command in buffers context. | 315 $buf command {cmd} # Execute Ex command in buffers context. |
316 $buf count # Report number of lines in buffer. | 316 $buf count # Report number of lines in buffer. |
317 $buf delcmd {cmd} # Call Tcl command when buffer is deleted. | 317 $buf delcmd {cmd} # Call Tcl command when buffer is deleted. |
318 $buf delete {n} # Delete a single line. | 318 $buf delete {n} # Delete a single line. |
319 $buf delete {n} {m} # Delete several lines. | 319 $buf delete {n} {m} # Delete several lines. |
320 $buf expr {expr} # Evaluate vim expression in buffers context. | 320 $buf expr {expr} # Evaluate vim expression in buffers context. |
436 used to display messages in vim. | 436 used to display messages in vim. |
437 | 437 |
438 ============================================================================== | 438 ============================================================================== |
439 7. Known bugs & problems *tcl-bugs* | 439 7. Known bugs & problems *tcl-bugs* |
440 | 440 |
441 Calling one of the Tcl ex commands from inside Tcl (via "::vim::command") may | 441 Calling one of the Tcl Ex commands from inside Tcl (via "::vim::command") may |
442 have unexpected side effects. The command creates a new interpreter, which | 442 have unexpected side effects. The command creates a new interpreter, which |
443 has the same abilities as the standard interpreter - making "::vim::command" | 443 has the same abilities as the standard interpreter - making "::vim::command" |
444 available in a safe child interpreter therefore makes the child unsafe. (It | 444 available in a safe child interpreter therefore makes the child unsafe. (It |
445 would be trivial to block nested :tcl* calls or ensure that such calls from a | 445 would be trivial to block nested :tcl* calls or ensure that such calls from a |
446 safe interpreter create only new safe interpreters, but quite pointless - | 446 safe interpreter create only new safe interpreters, but quite pointless - |
485 set line [$buf get $i] | 485 set line [$buf get $i] |
486 $buf set $i "$n\t$line" | 486 $buf set $i "$n\t$line" |
487 incr i ; incr n | 487 incr i ; incr n |
488 } | 488 } |
489 | 489 |
490 The same can also be done quickly with two ex commands, using ":tcldo": | 490 The same can also be done quickly with two Ex commands, using ":tcldo": |
491 :tcl set n 1 | 491 :tcl set n 1 |
492 :[range]tcldo set line "$n\t$line" ; incr n | 492 :[range]tcldo set line "$n\t$line" ; incr n |
493 | 493 |
494 This procedure runs an ex command on each buffer (idea stolen from Ron Aaron): | 494 This procedure runs an Ex command on each buffer (idea stolen from Ron Aaron): |
495 proc eachbuf { cmd } { | 495 proc eachbuf { cmd } { |
496 foreach b [::vim::buffer list] { | 496 foreach b [::vim::buffer list] { |
497 $b command $cmd | 497 $b command $cmd |
498 } | 498 } |
499 } | 499 } |
500 Use it like this: | 500 Use it like this: |
501 :tcl eachbuf %s/foo/bar/g | 501 :tcl eachbuf %s/foo/bar/g |
502 Be careful with Tcl's string and backslash substitution, tough. If in doubt, | 502 Be careful with Tcl's string and backslash substitution, tough. If in doubt, |
503 surround the ex command with curly braces. | 503 surround the Ex command with curly braces. |
504 | 504 |
505 | 505 |
506 If you want to add some Tcl procedures permanently to vim, just place them in | 506 If you want to add some Tcl procedures permanently to vim, just place them in |
507 a file (e.g. "~/.vimrc.tcl" on Unix machines), and add these lines to your | 507 a file (e.g. "~/.vimrc.tcl" on Unix machines), and add these lines to your |
508 startup file (usually "~/.vimrc" on Unix): | 508 startup file (usually "~/.vimrc" on Unix): |