~ubuntu-branches/ubuntu/maverick/vim/maverick

« back to all changes in this revision

Viewing changes to runtime/doc/if_tcl.txt

  • Committer: Bazaar Package Importer
  • Author(s): Steve Langasek
  • Date: 2009-05-04 11:13:42 UTC
  • mfrom: (1.1.8 upstream) (0.1.2 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090504111342-60miqybsixdpc345
Tags: 2:7.2.148-2ubuntu1
* Merge from Debian unstable, remaining changes:
  - debian/runtime/vimrc: "syntax on" is a sane default for non-tiny vim.
  - runtime/syntax/debcontrol.vim:
    + Add "metapackages" to the list of valid sections.
  - runtime/syntax/grub.vim:
    + Add Ubuntu-specific 'quiet' keyword.
  - Drop vim-lesstif package and lesstif2-dev build-dependency.
  - Enable Python interpreter on basic builds.
  - Disable autoindent, line-wrapping, and backup files by default.
* Dropped changes, merged in Debian:
  - Add jaunty, karmic to the list of valid suites.
  - runtime/syntax/debsources.vim:
    + Add "jaunty" to debsourcesDistrKeyword
  - Create a .pot file for translations.
* Drop gutsy from the list of valid distro series, it's been EOLed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
4
                  VIM REFERENCE MANUAL    by Ingo Wilken
83
83
        ::vim::beep                     # Guess.
84
84
        ::vim::buffer {n}               # Create Tcl command for one buffer.
85
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
87
        ::vim::expr {expr}              # Use Vim's expression evaluator.
88
88
        ::vim::option {opt}             # Get vim option.
89
89
        ::vim::option {opt} {val}       # Set vim option.
116
116
 
117
117
        ::vim::command {cmd}                            *tcl-command*
118
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
120
        a buffer or window uses the current buffer/current window.  Does not
121
121
        return a result other than a standard Tcl error code.  After this
122
122
        command is completed, the "::vim::current" variable is updated.
210
210
 
211
211
        line                                            *tcl-var-line*
212
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
214
        is being executed.  They contain the text and line number of the
215
215
        current line.  When the Tcl command invoked by ":tcldo" is completed,
216
216
        the current line is set to the contents of the "line" variable, unless
233
233
i.e. "$win" calls the command.  The following options are available: >
234
234
 
235
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
237
        $win cursor             # Get current cursor position.
238
238
        $win cursor {var}       # Set cursor position from array variable.
239
239
        $win cursor {row} {col} # Set cursor position.
312
312
i.e. "$buf" calls the command.  The following options are available: >
313
313
 
314
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
316
        $buf count              # Report number of lines in buffer.
317
317
        $buf delcmd {cmd}       # Call Tcl command when buffer is deleted.
318
318
        $buf delete {n}         # Delete a single line.
438
438
==============================================================================
439
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
442
have unexpected side effects.  The command creates a new interpreter, which
443
443
has the same abilities as the standard interpreter - making "::vim::command"
444
444
available in a safe child interpreter therefore makes the child unsafe.  (It
487
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
491
        :tcl set n 1
492
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
495
        proc eachbuf { cmd } {
496
496
                foreach b [::vim::buffer list] {
497
497
                        $b command $cmd
500
500
Use it like this:
501
501
        :tcl eachbuf %s/foo/bar/g
502
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
506
If you want to add some Tcl procedures permanently to vim, just place them in