blob: 4a5379ddb07b411604a3f613bf38be546b5ae774 [file] [log] [blame]
Bram Moolenaar25c9c682019-05-05 18:13:34 +02001*if_tcl.txt* For Vim version 8.1. Last change: 2019 May 05
Bram Moolenaar071d4272004-06-13 20:20:40 +00002
3
4 VIM REFERENCE MANUAL by Ingo Wilken
5
6
7The Tcl Interface to Vim *tcl* *Tcl* *TCL*
8
91. Commands |tcl-ex-commands|
102. Tcl commands |tcl-commands|
113. Tcl variables |tcl-variables|
124. Tcl window commands |tcl-window-cmds|
135. Tcl buffer commands |tcl-buffer-cmds|
146. Miscellaneous; Output from Tcl |tcl-misc| |tcl-output|
157. Known bugs & problems |tcl-bugs|
168. Examples |tcl-examples|
Bram Moolenaara5792f52005-11-23 21:25:05 +0000179. Dynamic loading |tcl-dynamic|
Bram Moolenaar071d4272004-06-13 20:20:40 +000018
Bram Moolenaar25c9c682019-05-05 18:13:34 +020019*E280*
20{only available when Vim was compiled with the |+tcl| feature}
Bram Moolenaar071d4272004-06-13 20:20:40 +000021
22WARNING: There are probably still some bugs. Please send bug reports,
23comments, ideas etc to <Ingo.Wilken@informatik.uni-oldenburg.de>
24
25==============================================================================
261. Commands *tcl-ex-commands* *E571* *E572*
27
28 *:tcl* *:tc*
Bram Moolenaar9b451252012-08-15 17:43:31 +020029:tc[l] {cmd} Execute Tcl command {cmd}. A simple check if `:tcl`
30 is working: >
31 :tcl puts "Hello"
Bram Moolenaar071d4272004-06-13 20:20:40 +000032
33:[range]tc[l] << {endmarker}
34{script}
35{endmarker}
36 Execute Tcl script {script}.
37 Note: This command doesn't work when the Tcl feature
38 wasn't compiled in. To avoid errors, see
39 |script-here|.
40
Bram Moolenaar402d2fe2005-04-15 21:00:38 +000041{endmarker} must NOT be preceded by any white space. If {endmarker} is
Bram Moolenaar071d4272004-06-13 20:20:40 +000042omitted from after the "<<", a dot '.' must be used after {script}, like for
43the |:append| and |:insert| commands.
44This form of the |:tcl| command is mainly useful for including tcl code in Vim
45scripts.
46
47Example: >
48 function! DefineDate()
49 tcl << EOF
50 proc date {} {
51 return [clock format [clock seconds]]
52 }
53 EOF
54 endfunction
55<
Bram Moolenaarabd468e2016-09-08 22:22:43 +020056To see what version of Tcl you have: >
57 :tcl puts [info patchlevel]
58<
Bram Moolenaar071d4272004-06-13 20:20:40 +000059
60 *:tcldo* *:tcld*
61:[range]tcld[o] {cmd} Execute Tcl command {cmd} for each line in [range]
62 with the variable "line" being set to the text of each
63 line in turn, and "lnum" to the line number. Setting
64 "line" will change the text, but note that it is not
65 possible to add or delete lines using this command.
66 If {cmd} returns an error, the command is interrupted.
67 The default for [range] is the whole file: "1,$".
Bram Moolenaar25c9c682019-05-05 18:13:34 +020068 See |tcl-var-line| and |tcl-var-lnum|.
Bram Moolenaar071d4272004-06-13 20:20:40 +000069
70 *:tclfile* *:tclf*
71:tclf[ile] {file} Execute the Tcl script in {file}. This is the same as
72 ":tcl source {file}", but allows file name completion.
Bram Moolenaar071d4272004-06-13 20:20:40 +000073
74
75Note that Tcl objects (like variables) persist from one command to the next,
76just as in the Tcl shell.
77
78Executing Tcl commands is not possible in the |sandbox|.
79
80==============================================================================
812. Tcl commands *tcl-commands*
82
83Tcl code gets all of its access to vim via commands in the "::vim" namespace.
84The following commands are implemented: >
85
86 ::vim::beep # Guess.
87 ::vim::buffer {n} # Create Tcl command for one buffer.
88 ::vim::buffer list # Create Tcl commands for all buffers.
Bram Moolenaar8f3f58f2010-01-06 20:52:26 +010089 ::vim::command [-quiet] {cmd} # Execute an Ex command.
Bram Moolenaar071d4272004-06-13 20:20:40 +000090 ::vim::expr {expr} # Use Vim's expression evaluator.
91 ::vim::option {opt} # Get vim option.
92 ::vim::option {opt} {val} # Set vim option.
93 ::vim::window list # Create Tcl commands for all windows.
94
95Commands:
96 ::vim::beep *tcl-beep*
97 Honk. Does not return a result.
98
99 ::vim::buffer {n} *tcl-buffer*
100 ::vim::buffer exists {n}
101 ::vim::buffer list
102 Provides access to vim buffers. With an integer argument, creates a
103 buffer command (see |tcl-buffer-cmds|) for the buffer with that
104 number, and returns its name as the result. Invalid buffer numbers
105 result in a standard Tcl error. To test for valid buffer numbers,
106 vim's internal functions can be used: >
107 set nbufs [::vim::expr bufnr("$")]
108 set isvalid [::vim::expr "bufexists($n)"]
109< The "list" option creates a buffer command for each valid buffer, and
110 returns a list of the command names as the result.
111 Example: >
112 set bufs [::vim::buffer list]
113 foreach b $bufs { $b append end "The End!" }
114< The "exists" option checks if a buffer with the given number exists.
115 Example: >
116 if { [::vim::buffer exists $n] } { ::vim::command ":e #$n" }
117< This command might be replaced by a variable in future versions.
118 See also |tcl-var-current| for the current buffer.
119
120 ::vim::command {cmd} *tcl-command*
121 ::vim::command -quiet {cmd}
Bram Moolenaar8f3f58f2010-01-06 20:52:26 +0100122 Execute the vim (ex-mode) command {cmd}. Any Ex command that affects
Bram Moolenaar071d4272004-06-13 20:20:40 +0000123 a buffer or window uses the current buffer/current window. Does not
124 return a result other than a standard Tcl error code. After this
125 command is completed, the "::vim::current" variable is updated.
126 The "-quiet" flag suppresses any error messages from vim.
127 Examples: >
128 ::vim::command "set ts=8"
129 ::vim::command "%s/foo/bar/g"
130< To execute normal-mode commands, use "normal" (see |:normal|): >
131 set cmd "jj"
132 ::vim::command "normal $cmd"
133< See also |tcl-window-command| and |tcl-buffer-command|.
134
135 ::vim::expr {expr} *tcl-expr*
136 Evaluates the expression {expr} using vim's internal expression
137 evaluator (see |expression|). Any expression that queries a buffer
138 or window property uses the current buffer/current window. Returns
Bram Moolenaar362e1a32006-03-06 23:29:24 +0000139 the result as a string. A |List| is turned into a string by joining
140 the items and inserting line breaks.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000141 Examples: >
142 set perl_available [::vim::expr has("perl")]
143< See also |tcl-window-expr| and |tcl-buffer-expr|.
144
145 ::vim::option {opt} *tcl-option*
146 ::vim::option {opt} {value}
147 Without second argument, queries the value of a vim option. With this
148 argument, sets the vim option to {value}, and returns the previous
149 value as the result. Any options that are marked as 'local to buffer'
150 or 'local to window' affect the current buffer/current window. The
151 global value is not changed, use the ":set" command for that. For
152 boolean options, {value} should be "0" or "1", or any of the keywords
153 "on", "off" or "toggle". See |option-summary| for a list of options.
154 Example: >
155 ::vim::option ts 8
156< See also |tcl-window-option| and |tcl-buffer-option|.
157
158 ::vim::window {option} *tcl-window*
159 Provides access to vim windows. Currently only the "list" option is
Bram Moolenaar402d2fe2005-04-15 21:00:38 +0000160 implemented. This creates a window command (see |tcl-window-cmds|) for
Bram Moolenaar071d4272004-06-13 20:20:40 +0000161 each window, and returns a list of the command names as the result.
162 Example: >
163 set wins [::vim::window list]
164 foreach w $wins { $w height 4 }
165< This command might be replaced by a variable in future versions.
166 See also |tcl-var-current| for the current window.
167
168==============================================================================
1693. Tcl variables *tcl-variables*
170
171The ::vim namespace contains a few variables. These are created when the Tcl
172interpreter is called from vim and set to current values. >
173
174 ::vim::current # array containing "current" objects
175 ::vim::lbase # number of first line
176 ::vim::range # array containing current range numbers
177 line # current line as a string (:tcldo only)
178 lnum # current line number (:tcldo only)
179
180Variables:
181 ::vim::current *tcl-var-current*
182 This is an array providing access to various "current" objects
183 available in vim. The contents of this array are updated after
184 "::vim::command" is called, as this might change vim's current
185 settings (e.g., by deleting the current buffer).
186 The "buffer" element contains the name of the buffer command for the
187 current buffer. This can be used directly to invoke buffer commands
188 (see |tcl-buffer-cmds|). This element is read-only.
189 Example: >
190 $::vim::current(buffer) insert begin "Hello world"
191< The "window" element contains the name of the window command for the
192 current window. This can be used directly to invoke window commands
193 (see |tcl-window-cmds|). This element is read-only.
194 Example: >
195 $::vim::current(window) height 10
196<
197 ::vim::lbase *tcl-var-lbase*
198 This variable controls how Tcl treats line numbers. If it is set to
199 '1', then lines and columns start at 1. This way, line numbers from
200 Tcl commands and vim expressions are compatible. If this variable is
201 set to '0', then line numbers and columns start at 0 in Tcl. This is
202 useful if you want to treat a buffer as a Tcl list or a line as a Tcl
203 string and use standard Tcl commands that return an index ("lsort" or
204 "string first", for example). The default value is '1'. Currently,
205 any non-zero values is treated as '1', but your scripts should not
206 rely on this. See also |tcl-linenumbers|.
207
208 ::vim::range *tcl-var-range*
209 This is an array with three elements, "start", "begin" and "end". It
210 contains the line numbers of the start and end row of the current
211 range. "begin" is the same as "start". This variable is read-only.
212 See |tcl-examples|.
213
214 line *tcl-var-line*
215 lnum *tcl-var-lnum*
Bram Moolenaar8f3f58f2010-01-06 20:52:26 +0100216 These global variables are only available if the ":tcldo" Ex command
Bram Moolenaar071d4272004-06-13 20:20:40 +0000217 is being executed. They contain the text and line number of the
218 current line. When the Tcl command invoked by ":tcldo" is completed,
219 the current line is set to the contents of the "line" variable, unless
220 the variable was unset by the Tcl command. The "lnum" variable is
221 read-only. These variables are not in the "::vim" namespace so they
222 can be used in ":tcldo" without much typing (this might be changed in
223 future versions). See also |tcl-linenumbers|.
224
225==============================================================================
2264. Tcl window commands *tcl-window-cmds*
227
228Window commands represent vim windows. They are created by several commands:
229 ::vim::window list |tcl-window|
230 "windows" option of a buffer command |tcl-buffer-windows|
231The ::vim::current(window) variable contains the name of the window command
232for the current window. A window command is automatically deleted when the
233corresponding vim window is closed.
234
Bram Moolenaar402d2fe2005-04-15 21:00:38 +0000235Let's assume the name of the window command is stored in the Tcl variable "win",
Bram Moolenaar071d4272004-06-13 20:20:40 +0000236i.e. "$win" calls the command. The following options are available: >
237
238 $win buffer # Create Tcl command for window's buffer.
Bram Moolenaar8f3f58f2010-01-06 20:52:26 +0100239 $win command {cmd} # Execute Ex command in windows context.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000240 $win cursor # Get current cursor position.
241 $win cursor {var} # Set cursor position from array variable.
242 $win cursor {row} {col} # Set cursor position.
243 $win delcmd {cmd} # Call Tcl command when window is closed.
244 $win expr {expr} # Evaluate vim expression in windows context.
245 $win height # Report the window's height.
246 $win height {n} # Set the window's height.
247 $win option {opt} [val] # Get/Set vim option in windows context.
248
249Options:
250 $win buffer *tcl-window-buffer*
251 Creates a Tcl command for the window's buffer, and returns its name as
252 the result. The name should be stored in a variable: >
253 set buf [$win buffer]
254< $buf is now a valid Tcl command. See |tcl-buffer-cmds| for the
255 available options.
256
257 $win cursor *tcl-window-cursor*
258 $win cursor {var}
259 $win cursor {row} {col}
260 Without argument, reports the current cursor position as a string.
261 This can be converted to a Tcl array variable: >
262 array set here [$win cursor]
263< "here(row)" and "here(column)" now contain the cursor position.
264 With a single argument, the argument is interpreted as the name of a
265 Tcl array variable, which must contain two elements "row" and "column".
266 These are used to set the cursor to the new position: >
267 $win cursor here ;# not $here !
268< With two arguments, sets the cursor to the specified row and column: >
269 $win cursor $here(row) $here(column)
270< Invalid positions result in a standard Tcl error, which can be caught
271 with "catch". The row and column values depend on the "::vim::lbase"
272 variable. See |tcl-var-lbase|.
273
274 $win delcmd {cmd} *tcl-window-delcmd*
275 Registers the Tcl command {cmd} as a deletion callback for the window.
276 This command is executed (in the global scope) just before the window
277 is closed. Complex commands should be build with "list": >
278 $win delcmd [list puts vimerr "window deleted"]
279< See also |tcl-buffer-delcmd|.
280
281 $win height *tcl-window-height*
282 $win height {n}
283 Without argument, reports the window's current height. With an
284 argument, tries to set the window's height to {n}, then reports the
285 new height (which might be different from {n}).
286
287 $win command [-quiet] {cmd} *tcl-window-command*
288 $win expr {expr} *tcl-window-expr*
289 $win option {opt} [val] *tcl-window-option*
290 These are similar to "::vim::command" etc., except that everything is
291 done in the context of the window represented by $win, instead of the
292 current window. For example, setting an option that is marked 'local
293 to window' affects the window $win. Anything that affects or queries
294 a buffer uses the buffer displayed in this window (i.e. the buffer
295 that is represented by "$win buffer"). See |tcl-command|, |tcl-expr|
296 and |tcl-option| for more information.
297 Example: >
298 $win option number on
299
300==============================================================================
3015. Tcl buffer commands *tcl-buffer-cmds*
302
303Buffer commands represent vim buffers. They are created by several commands:
304 ::vim::buffer {N} |tcl-buffer|
305 ::vim::buffer list |tcl-buffer|
306 "buffer" option of a window command |tcl-window-buffer|
307The ::vim::current(buffer) variable contains the name of the buffer command
308for the current buffer. A buffer command is automatically deleted when the
309corresponding vim buffer is destroyed. Whenever the buffer's contents are
310changed, all marks in the buffer are automatically adjusted. Any changes to
311the buffer's contents made by Tcl commands can be undone with the "undo" vim
312command (see |undo|).
313
Bram Moolenaar402d2fe2005-04-15 21:00:38 +0000314Let's assume the name of the buffer command is stored in the Tcl variable "buf",
Bram Moolenaar071d4272004-06-13 20:20:40 +0000315i.e. "$buf" calls the command. The following options are available: >
316
317 $buf append {n} {str} # Append a line to buffer, after line {n}.
Bram Moolenaar8f3f58f2010-01-06 20:52:26 +0100318 $buf command {cmd} # Execute Ex command in buffers context.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000319 $buf count # Report number of lines in buffer.
320 $buf delcmd {cmd} # Call Tcl command when buffer is deleted.
321 $buf delete {n} # Delete a single line.
322 $buf delete {n} {m} # Delete several lines.
323 $buf expr {expr} # Evaluate vim expression in buffers context.
324 $buf get {n} # Get a single line as a string.
325 $buf get {n} {m} # Get several lines as a list.
326 $buf insert {n} {str} # Insert a line in buffer, as line {n}.
327 $buf last # Report line number of last line in buffer.
328 $buf mark {mark} # Report position of buffer mark.
329 $buf name # Report name of file in buffer.
330 $buf number # Report number of this buffer.
331 $buf option {opt} [val] # Get/Set vim option in buffers context.
332 $buf set {n} {text} # Replace a single line.
333 $buf set {n} {m} {list} # Replace several lines.
334 $buf windows # Create Tcl commands for buffer's windows.
335<
336 *tcl-linenumbers*
337Most buffer commands take line numbers as arguments. How Tcl treats these
338numbers depends on the "::vim::lbase" variable (see |tcl-var-lbase|). Instead
339of line numbers, several keywords can be also used: "top", "start", "begin",
340"first", "bottom", "end" and "last".
341
342Options:
343 $buf append {n} {str} *tcl-buffer-append*
344 $buf insert {n} {str} *tcl-buffer-insert*
345 Add a line to the buffer. With the "insert" option, the string
346 becomes the new line {n}, with "append" it is inserted after line {n}.
347 Example: >
348 $buf insert top "This is the beginning."
349 $buf append end "This is the end."
350< To add a list of lines to the buffer, use a loop: >
351 foreach line $list { $buf append $num $line ; incr num }
352<
353 $buf count *tcl-buffer-count*
354 Reports the total number of lines in the buffer.
355
356 $buf delcmd {cmd} *tcl-buffer-delcmd*
357 Registers the Tcl command {cmd} as a deletion callback for the buffer.
358 This command is executed (in the global scope) just before the buffer
359 is deleted. Complex commands should be build with "list": >
360 $buf delcmd [list puts vimerr "buffer [$buf number] gone"]
361< See also |tcl-window-delcmd|.
362
363 $buf delete {n} *tcl-buffer-delete*
364 $buf delete {n} {m}
365 Deletes line {n} or lines {n} through {m} from the buffer.
366 This example deletes everything except the last line: >
367 $buf delete first [expr [$buf last] - 1]
368<
369 $buf get {n} *tcl-buffer-get*
370 $buf get {n} {m}
371 Gets one or more lines from the buffer. For a single line, the result
372 is a string; for several lines, a list of strings.
373 Example: >
374 set topline [$buf get top]
375<
376 $buf last *tcl-buffer-last*
377 Reports the line number of the last line. This value depends on the
378 "::vim::lbase" variable. See |tcl-var-lbase|.
379
380 $buf mark {mark} *tcl-buffer-mark*
381 Reports the position of the named mark as a string, similar to the
382 cursor position of the "cursor" option of a window command (see
383 |tcl-window-cursor|). This can be converted to a Tcl array variable: >
384 array set mpos [$buf mark "a"]
385< "mpos(column)" and "mpos(row)" now contain the position of the mark.
386 If the mark is not set, a standard Tcl error results.
387
388 $buf name
389 Reports the name of the file in the buffer. For a buffer without a
390 file, this is an empty string.
391
392 $buf number
393 Reports the number of this buffer. See |:buffers|.
394 This example deletes a buffer from vim: >
395 ::vim::command "bdelete [$buf number]"
396<
397 $buf set {n} {string} *tcl-buffer-set*
398 $buf set {n} {m} {list}
399 Replace one or several lines in the buffer. If the list contains more
400 elements than there are lines to replace, they are inserted into the
401 buffer. If the list contains fewer elements, any unreplaced line is
402 deleted from the buffer.
403
404 $buf windows *tcl-buffer-windows*
405 Creates a window command for each window that displays this buffer, and
406 returns a list of the command names as the result.
407 Example: >
408 set winlist [$buf windows]
409 foreach win $winlist { $win height 4 }
410< See |tcl-window-cmds| for the available options.
411
412 $buf command [-quiet] {cmd} *tcl-buffer-command*
Bram Moolenaarc236c162008-07-13 17:41:49 +0000413 $buf expr {expr} *tcl-buffer-expr*
Bram Moolenaar071d4272004-06-13 20:20:40 +0000414 $buf option {opt} [val] *tcl-buffer-option*
415 These are similar to "::vim::command" etc., except that everything is
416 done in the context of the buffer represented by $buf, instead of the
417 current buffer. For example, setting an option that is marked 'local
418 to buffer' affects the buffer $buf. Anything that affects or queries
419 a window uses the first window in vim's window list that displays this
420 buffer (i.e. the first entry in the list returned by "$buf windows").
421 See |tcl-command|, |tcl-expr| and |tcl-option| for more information.
422 Example: >
423 if { [$buf option modified] } { $buf command "w" }
424
425==============================================================================
4266. Miscellaneous; Output from Tcl *tcl-misc* *tcl-output*
427
428The standard Tcl commands "exit" and "catch" are replaced by custom versions.
429"exit" terminates the current Tcl script and returns to vim, which deletes the
430Tcl interpreter. Another call to ":tcl" then creates a new Tcl interpreter.
431"exit" does NOT terminate vim! "catch" works as before, except that it does
432not prevent script termination from "exit". An exit code != 0 causes the ex
433command that invoked the Tcl script to return an error.
434
435Two new I/O streams are available in Tcl, "vimout" and "vimerr". All output
436directed to them is displayed in the vim message area, as information messages
437and error messages, respectively. The standard Tcl output streams stdout and
438stderr are mapped to vimout and vimerr, so that a normal "puts" command can be
439used to display messages in vim.
440
441==============================================================================
4427. Known bugs & problems *tcl-bugs*
443
Bram Moolenaar8f3f58f2010-01-06 20:52:26 +0100444Calling one of the Tcl Ex commands from inside Tcl (via "::vim::command") may
Bram Moolenaar071d4272004-06-13 20:20:40 +0000445have unexpected side effects. The command creates a new interpreter, which
446has the same abilities as the standard interpreter - making "::vim::command"
447available in a safe child interpreter therefore makes the child unsafe. (It
448would be trivial to block nested :tcl* calls or ensure that such calls from a
449safe interpreter create only new safe interpreters, but quite pointless -
450depending on vim's configuration, "::vim::command" may execute arbitrary code
451in any number of other scripting languages.) A call to "exit" within this new
452interpreter does not affect the old interpreter; it only terminates the new
453interpreter, then script processing continues normally in the old interpreter.
454
455Input from stdin is currently not supported.
456
457==============================================================================
4588. Examples: *tcl-examples*
459
460Here are a few small (and maybe useful) Tcl scripts.
461
462This script sorts the lines of the entire buffer (assume it contains a list
463of names or something similar):
464 set buf $::vim::current(buffer)
465 set lines [$buf get top bottom]
466 set lines [lsort -dictionary $lines]
467 $buf set top bottom $lines
468
469This script reverses the lines in the buffer. Note the use of "::vim::lbase"
470and "$buf last" to work with any line number setting.
471 set buf $::vim::current(buffer)
472 set t $::vim::lbase
473 set b [$buf last]
474 while { $t < $b } {
475 set tl [$buf get $t]
476 set bl [$buf get $b]
477 $buf set $t $bl
478 $buf set $b $tl
479 incr t
480 incr b -1
481 }
482
483This script adds a consecutive number to each line in the current range:
484 set buf $::vim::current(buffer)
485 set i $::vim::range(start)
486 set n 1
487 while { $i <= $::vim::range(end) } {
488 set line [$buf get $i]
489 $buf set $i "$n\t$line"
490 incr i ; incr n
491 }
492
Bram Moolenaar8f3f58f2010-01-06 20:52:26 +0100493The same can also be done quickly with two Ex commands, using ":tcldo":
Bram Moolenaar071d4272004-06-13 20:20:40 +0000494 :tcl set n 1
495 :[range]tcldo set line "$n\t$line" ; incr n
496
Bram Moolenaar8f3f58f2010-01-06 20:52:26 +0100497This procedure runs an Ex command on each buffer (idea stolen from Ron Aaron):
Bram Moolenaar071d4272004-06-13 20:20:40 +0000498 proc eachbuf { cmd } {
499 foreach b [::vim::buffer list] {
500 $b command $cmd
501 }
502 }
503Use it like this:
504 :tcl eachbuf %s/foo/bar/g
Bram Moolenaar402d2fe2005-04-15 21:00:38 +0000505Be careful with Tcl's string and backslash substitution, tough. If in doubt,
Bram Moolenaar8f3f58f2010-01-06 20:52:26 +0100506surround the Ex command with curly braces.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000507
508
509If you want to add some Tcl procedures permanently to vim, just place them in
510a file (e.g. "~/.vimrc.tcl" on Unix machines), and add these lines to your
511startup file (usually "~/.vimrc" on Unix):
512 if has("tcl")
513 tclfile ~/.vimrc.tcl
514 endif
515
516==============================================================================
Bram Moolenaara5792f52005-11-23 21:25:05 +00005179. Dynamic loading *tcl-dynamic*
518
Bram Moolenaar8a5115c2016-01-09 19:41:11 +0100519On MS-Windows and Unix the Tcl library can be loaded dynamically. The
520|:version| output then includes |+tcl/dyn|.
Bram Moolenaara5792f52005-11-23 21:25:05 +0000521
Bram Moolenaar8a5115c2016-01-09 19:41:11 +0100522This means that Vim will search for the Tcl DLL or shared library file only
523when needed. When you don't use the Tcl interface you don't need it, thus you
524can use Vim without this file.
525
526
527MS-Windows ~
Bram Moolenaara5792f52005-11-23 21:25:05 +0000528
529To use the Tcl interface the Tcl DLL must be in your search path. In a
Bram Moolenaare18c0b32016-03-20 21:08:34 +0100530console window type "path" to see what directories are used. The 'tcldll'
531option can be also used to specify the Tcl DLL.
Bram Moolenaara5792f52005-11-23 21:25:05 +0000532
533The name of the DLL must match the Tcl version Vim was compiled with.
Bram Moolenaarfa735342016-01-03 22:14:44 +0100534Currently the name is "tcl86.dll". That is for Tcl 8.6. To know for sure
Bram Moolenaara5792f52005-11-23 21:25:05 +0000535edit "gvim.exe" and search for "tcl\d*.dll\c".
536
Bram Moolenaar8a5115c2016-01-09 19:41:11 +0100537
538Unix ~
539
540The 'tcldll' option can be used to specify the Tcl shared library file instead
541of DYNAMIC_TCL_DLL file what was specified at compile time. The version of
542the shared library must match the Tcl version Vim was compiled with.
543
Bram Moolenaara5792f52005-11-23 21:25:05 +0000544==============================================================================
Bram Moolenaar91f84f62018-07-29 15:07:52 +0200545 vim:tw=78:ts=8:noet:ft=help:norl: