annotate runtime/doc/if_perl.txt @ 20788:072ad890c227 v8.2.0946

patch 8.2.0946: cannot use "q" to cancel a number prompt Commit: https://github.com/vim/vim/commit/eebd555733491cb55b9f30fe28772c0fd0ebacf7 Author: Bram Moolenaar <Bram@vim.org> Date: Wed Jun 10 15:45:57 2020 +0200 patch 8.2.0946: cannot use "q" to cancel a number prompt Problem: Cannot use "q" to cancel a number prompt. Solution: Recognize "q" instead of ignoring it.
author Bram Moolenaar <Bram@vim.org>
date Wed, 10 Jun 2020 16:00:05 +0200
parents 04ef2ccf2519
children 3e661b0cf500
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
18879
af69c9335223 Vim 8.2 release
Bram Moolenaar <Bram@vim.org>
parents: 18831
diff changeset
1 *if_perl.txt* For Vim version 8.2. Last change: 2019 Dec 07
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4 VIM REFERENCE MANUAL by Sven Verdoolaege
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5 and Matt Gerassimof
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7 Perl and Vim *perl* *Perl*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9 1. Editing Perl files |perl-editing|
11473
bd6ff5246c71 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 10198
diff changeset
10 2. Compiling Vim with Perl interface |perl-compiling|
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11 3. Using the Perl interface |perl-using|
557
862863033fdd updated for version 7.0158
vimboss
parents: 236
diff changeset
12 4. Dynamic loading |perl-dynamic|
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13
16553
0e473e9e70c2 patch 8.1.1280: remarks about functionality not in Vi clutters the help
Bram Moolenaar <Bram@vim.org>
parents: 15729
diff changeset
14 {only available when Vim was compiled with the |+perl| feature}
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
16 ==============================================================================
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
17 1. Editing Perl files *perl-editing*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
18
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
19 Vim syntax highlighting supports Perl and POD files. Vim assumes a file is
236
4707450c2b33 updated for version 7.0066
vimboss
parents: 22
diff changeset
20 Perl code if the filename has a .pl or .pm suffix. Vim also examines the first
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
21 line of a file, regardless of the filename suffix, to check if a file is a
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22 Perl script (see scripts.vim in Vim's syntax directory). Vim assumes a file
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
23 is POD text if the filename has a .POD suffix.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
24
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
25 To use tags with Perl, you need a recent version of Exuberant ctags. Look
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
26 here:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
27 http://ctags.sourceforge.net
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
28
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
29 Alternatively, you can use the Perl script pltags.pl, which is shipped with
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
30 Vim in the $VIMRUNTIME/tools directory. This script has currently more
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
31 features than Exuberant ctags' Perl support.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
32
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
33 ==============================================================================
11473
bd6ff5246c71 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 10198
diff changeset
34 2. Compiling Vim with Perl interface *perl-compiling*
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
35
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
36 To compile Vim with Perl interface, you need Perl 5.004 (or later). Perl must
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
37 be installed before you compile Vim. Vim's Perl interface does NOT work with
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
38 the 5.003 version that has been officially released! It will probably work
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
39 with Perl 5.003_05 and later.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
40
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
41 The Perl patches for Vim were made by:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
42 Sven Verdoolaege <skimo@breughel.ufsia.ac.be>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
43 Matt Gerassimof
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
44
14432
172f18a3a6cd Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 14421
diff changeset
45 Perl for MS-Windows (and other platforms) can be found at:
15033
f8b0f1e42f2c Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14432
diff changeset
46 http://www.perl.org/
f8b0f1e42f2c Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14432
diff changeset
47 The ActiveState one should work, Strawberry Perl is a good alternative.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
48
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
49 ==============================================================================
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
50 3. Using the Perl interface *perl-using*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
51
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
52 *:perl* *:pe*
236
4707450c2b33 updated for version 7.0066
vimboss
parents: 22
diff changeset
53 :pe[rl] {cmd} Execute Perl command {cmd}. The current package
3750
536aa8b0c934 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2577
diff changeset
54 is "main". Simple example to test if `:perl` is
536aa8b0c934 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2577
diff changeset
55 working: >
536aa8b0c934 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2577
diff changeset
56 :perl VIM::Msg("Hello")
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
57
20045
04ef2ccf2519 patch 8.2.0578: heredoc for interfaces does not support "trim"
Bram Moolenaar <Bram@vim.org>
parents: 18879
diff changeset
58 :pe[rl] << [trim] [{endmarker}]
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
59 {script}
18343
375a7ecdb351 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 17571
diff changeset
60 {endmarker}
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
61 Execute Perl script {script}.
18343
375a7ecdb351 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 17571
diff changeset
62 The {endmarker} after {script} must NOT be preceded by
375a7ecdb351 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 17571
diff changeset
63 any white space.
17571
2704c4e3e20a Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 16553
diff changeset
64
18343
375a7ecdb351 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 17571
diff changeset
65 If [endmarker] is omitted, it defaults to a dot '.'
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
66 like for the |:append| and |:insert| commands. Using
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
67 '.' helps when inside a function, because "$i;" looks
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
68 like the start of an |:insert| command to Vim.
17571
2704c4e3e20a Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 16553
diff changeset
69
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
70 This form of the |:perl| command is mainly useful for
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
71 including perl code in vim scripts.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
72 Note: This command doesn't work when the Perl feature
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
73 wasn't compiled in. To avoid errors, see
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
74 |script-here|.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
75
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
76
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
77 Example vim script: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
78
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
79 function! WhitePearl()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
80 perl << EOF
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
81 VIM::Msg("pearls are nice for necklaces");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
82 VIM::Msg("rubys for rings");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
83 VIM::Msg("pythons for bags");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
84 VIM::Msg("tcls????");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
85 EOF
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
86 endfunction
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
87 <
10153
715d6c5707b8 commit https://github.com/vim/vim/commit/abd468ed0fbcba391e7833feeaa7de3ced841455
Christian Brabandt <cb@256bit.org>
parents: 8673
diff changeset
88 To see what version of Perl you have: >
715d6c5707b8 commit https://github.com/vim/vim/commit/abd468ed0fbcba391e7833feeaa7de3ced841455
Christian Brabandt <cb@256bit.org>
parents: 8673
diff changeset
89 :perl print $^V
715d6c5707b8 commit https://github.com/vim/vim/commit/abd468ed0fbcba391e7833feeaa7de3ced841455
Christian Brabandt <cb@256bit.org>
parents: 8673
diff changeset
90 <
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
91
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
92 *:perldo* *:perld*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
93 :[range]perld[o] {cmd} Execute Perl command {cmd} for each line in the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
94 [range], with $_ being set to the text of each line in
236
4707450c2b33 updated for version 7.0066
vimboss
parents: 22
diff changeset
95 turn, without a trailing <EOL>. Setting $_ will change
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
96 the text, but note that it is not possible to add or
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
97 delete lines using this command.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
98 The default for [range] is the whole file: "1,$".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
99
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
100 Here are some things you can try: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
101
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
102 :perl $a=1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
103 :perldo $_ = reverse($_);1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
104 :perl VIM::Msg("hello")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
105 :perl $line = $curbuf->Get(42)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
106 <
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
107 *E299*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
108 Executing Perl commands in the |sandbox| is limited. ":perldo" will not be
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
109 possible at all. ":perl" will be evaluated in the Safe environment, if
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
110 possible.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
111
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
112
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
113 *perl-overview*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
114 Here is an overview of the functions that are available to Perl: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
115
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
116 :perl VIM::Msg("Text") # displays a message
12968
45987b1b77dc Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 11473
diff changeset
117 :perl VIM::Msg("Wrong!", "ErrorMsg") # displays an error message
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
118 :perl VIM::Msg("remark", "Comment") # displays a highlighted message
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
119 :perl VIM::SetOption("ai") # sets a vim option
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
120 :perl $nbuf = VIM::Buffers() # returns the number of buffers
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
121 :perl @buflist = VIM::Buffers() # returns array of all buffers
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
122 :perl $mybuf = (VIM::Buffers('qq.c'))[0] # returns buffer object for 'qq.c'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
123 :perl @winlist = VIM::Windows() # returns array of all windows
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
124 :perl $nwin = VIM::Windows() # returns the number of windows
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
125 :perl ($success, $v) = VIM::Eval('&path') # $v: option 'path', $success: 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
126 :perl ($success, $v) = VIM::Eval('&xyz') # $v: '' and $success: 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
127 :perl $v = VIM::Eval('expand("<cfile>")') # expands <cfile>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
128 :perl $curwin->SetHeight(10) # sets the window height
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
129 :perl @pos = $curwin->Cursor() # returns (row, col) array
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
130 :perl @pos = (10, 10)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
131 :perl $curwin->Cursor(@pos) # sets cursor to @pos
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
132 :perl $curwin->Cursor(10,10) # sets cursor to row 10 col 10
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
133 :perl $mybuf = $curwin->Buffer() # returns the buffer object for window
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
134 :perl $curbuf->Name() # returns buffer name
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
135 :perl $curbuf->Number() # returns buffer number
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
136 :perl $curbuf->Count() # returns the number of lines
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
137 :perl $l = $curbuf->Get(10) # returns line 10
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
138 :perl @l = $curbuf->Get(1 .. 5) # returns lines 1 through 5
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
139 :perl $curbuf->Delete(10) # deletes line 10
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
140 :perl $curbuf->Delete(10, 20) # delete lines 10 through 20
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
141 :perl $curbuf->Append(10, "Line") # appends a line
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
142 :perl $curbuf->Append(10, "Line1", "Line2", "Line3") # appends 3 lines
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
143 :perl @l = ("L1", "L2", "L3")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
144 :perl $curbuf->Append(10, @l) # appends L1, L2 and L3
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
145 :perl $curbuf->Set(10, "Line") # replaces line 10
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
146 :perl $curbuf->Set(10, "Line1", "Line2") # replaces lines 10 and 11
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
147 :perl $curbuf->Set(10, @l) # replaces 3 lines
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
148 <
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
149 *perl-Msg*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
150 VIM::Msg({msg}, {group}?)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
151 Displays the message {msg}. The optional {group}
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
152 argument specifies a highlight group for Vim to use
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
153 for the message.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
154
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
155 *perl-SetOption*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
156 VIM::SetOption({arg}) Sets a vim option. {arg} can be any argument that the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
157 ":set" command accepts. Note that this means that no
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
158 spaces are allowed in the argument! See |:set|.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
159
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
160 *perl-Buffers*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
161 VIM::Buffers([{bn}...]) With no arguments, returns a list of all the buffers
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
162 in an array context or returns the number of buffers
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
163 in a scalar context. For a list of buffer names or
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
164 numbers {bn}, returns a list of the buffers matching
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
165 {bn}, using the same rules as Vim's internal
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
166 |bufname()| function.
22
cc049b00ee70 updated for version 7.0014
vimboss
parents: 7
diff changeset
167 WARNING: the list becomes invalid when |:bwipe| is
cc049b00ee70 updated for version 7.0014
vimboss
parents: 7
diff changeset
168 used. Using it anyway may crash Vim.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
169
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
170 *perl-Windows*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
171 VIM::Windows([{wn}...]) With no arguments, returns a list of all the windows
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
172 in an array context or returns the number of windows
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
173 in a scalar context. For a list of window numbers
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
174 {wn}, returns a list of the windows with those
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
175 numbers.
22
cc049b00ee70 updated for version 7.0014
vimboss
parents: 7
diff changeset
176 WARNING: the list becomes invalid when a window is
cc049b00ee70 updated for version 7.0014
vimboss
parents: 7
diff changeset
177 closed. Using it anyway may crash Vim.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
178
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
179 *perl-DoCommand*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
180 VIM::DoCommand({cmd}) Executes Ex command {cmd}.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
181
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
182 *perl-Eval*
18831
6848b809a26e Runtime file updates.
Bram Moolenaar <Bram@vim.org>
parents: 18343
diff changeset
183 VIM::Eval({expr}) Evaluates {expr} and returns (success, value) in list
3920
c53344bacabf Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3750
diff changeset
184 context or just value in scalar context.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
185 success=1 indicates that val contains the value of
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
186 {expr}; success=0 indicates a failure to evaluate
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
187 the expression. '@x' returns the contents of register
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
188 x, '&x' returns the value of option x, 'x' returns the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
189 value of internal |variables| x, and '$x' is equivalent
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
190 to perl's $ENV{x}. All |functions| accessible from
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
191 the command-line are valid for {expr}.
714
0f9f4761ad9c updated for version 7.0216
vimboss
parents: 557
diff changeset
192 A |List| is turned into a string by joining the items
0f9f4761ad9c updated for version 7.0216
vimboss
parents: 557
diff changeset
193 and inserting line breaks.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
194
15454
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15033
diff changeset
195 *perl-Blob*
15729
fe57e4f0eac1 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 15454
diff changeset
196 VIM::Blob({expr}) Return |Blob| literal string 0zXXXX from scalar value.
15454
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15033
diff changeset
197
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
198 *perl-SetHeight*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
199 Window->SetHeight({height})
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
200 Sets the Window height to {height}, within screen
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
201 limits.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
202
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
203 *perl-GetCursor*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
204 Window->Cursor({row}?, {col}?)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
205 With no arguments, returns a (row, col) array for the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
206 current cursor position in the Window. With {row} and
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
207 {col} arguments, sets the Window's cursor position to
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
208 {row} and {col}. Note that {col} is numbered from 0,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
209 Perl-fashion, and thus is one less than the value in
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
210 Vim's ruler.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
211
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
212 Window->Buffer() *perl-Buffer*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
213 Returns the Buffer object corresponding to the given
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
214 Window.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
215
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
216 *perl-Name*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
217 Buffer->Name() Returns the filename for the Buffer.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
218
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
219 *perl-Number*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
220 Buffer->Number() Returns the number of the Buffer.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
221
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
222 *perl-Count*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
223 Buffer->Count() Returns the number of lines in the Buffer.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
224
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
225 *perl-Get*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
226 Buffer->Get({lnum}, {lnum}?, ...)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
227 Returns a text string of line {lnum} in the Buffer
236
4707450c2b33 updated for version 7.0066
vimboss
parents: 22
diff changeset
228 for each {lnum} specified. An array can be passed
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
229 with a list of {lnum}'s specified.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
230
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
231 *perl-Delete*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
232 Buffer->Delete({lnum}, {lnum}?)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
233 Deletes line {lnum} in the Buffer. With the second
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
234 {lnum}, deletes the range of lines from the first
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
235 {lnum} to the second {lnum}.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
236
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
237 *perl-Append*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
238 Buffer->Append({lnum}, {line}, {line}?, ...)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
239 Appends each {line} string after Buffer line {lnum}.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
240 The list of {line}s can be an array.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
241
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
242 *perl-Set*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
243 Buffer->Set({lnum}, {line}, {line}?, ...)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
244 Replaces one or more Buffer lines with specified
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
245 {lines}s, starting at Buffer line {lnum}. The list of
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
246 {line}s can be an array. If the arguments are
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
247 invalid, replacement does not occur.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
248
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
249 $main::curwin
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
250 The current window object.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
251
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
252 $main::curbuf
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
253 The current buffer object.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
254
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
255
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
256 *script-here*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
257 When using a script language in-line, you might want to skip this when the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
258 language isn't supported. But this mechanism doesn't work: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
259 if has('perl')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
260 perl << EOF
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
261 this will NOT work!
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
262 EOF
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
263 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
264 Instead, put the Perl/Python/Ruby/etc. command in a function and call that
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
265 function: >
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
266 if has('perl')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
267 function DefPerl()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
268 perl << EOF
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
269 this works
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
270 EOF
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
271 endfunction
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
272 call DefPerl()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
273 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
274 Note that "EOF" must be at the start of the line.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
275
557
862863033fdd updated for version 7.0158
vimboss
parents: 236
diff changeset
276 ==============================================================================
862863033fdd updated for version 7.0158
vimboss
parents: 236
diff changeset
277 4. Dynamic loading *perl-dynamic*
862863033fdd updated for version 7.0158
vimboss
parents: 236
diff changeset
278
2370
454f314d0e61 Make it possible to load Perl dynamically on Unix. (James Vega)
Bram Moolenaar <bram@vim.org>
parents: 2365
diff changeset
279 On MS-Windows and Unix the Perl library can be loaded dynamically. The
454f314d0e61 Make it possible to load Perl dynamically on Unix. (James Vega)
Bram Moolenaar <bram@vim.org>
parents: 2365
diff changeset
280 |:version| output then includes |+perl/dyn|.
557
862863033fdd updated for version 7.0158
vimboss
parents: 236
diff changeset
281
2370
454f314d0e61 Make it possible to load Perl dynamically on Unix. (James Vega)
Bram Moolenaar <bram@vim.org>
parents: 2365
diff changeset
282 This means that Vim will search for the Perl DLL or shared library file only
454f314d0e61 Make it possible to load Perl dynamically on Unix. (James Vega)
Bram Moolenaar <bram@vim.org>
parents: 2365
diff changeset
283 when needed. When you don't use the Perl interface you don't need it, thus
454f314d0e61 Make it possible to load Perl dynamically on Unix. (James Vega)
Bram Moolenaar <bram@vim.org>
parents: 2365
diff changeset
284 you can use Vim without this file.
454f314d0e61 Make it possible to load Perl dynamically on Unix. (James Vega)
Bram Moolenaar <bram@vim.org>
parents: 2365
diff changeset
285
557
862863033fdd updated for version 7.0158
vimboss
parents: 236
diff changeset
286
2370
454f314d0e61 Make it possible to load Perl dynamically on Unix. (James Vega)
Bram Moolenaar <bram@vim.org>
parents: 2365
diff changeset
287 MS-Windows ~
557
862863033fdd updated for version 7.0158
vimboss
parents: 236
diff changeset
288
2342
f6540762173d Fixes and improvements for MS-Windows build.
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
289 You can download Perl from http://www.perl.org. The one from ActiveState was
f6540762173d Fixes and improvements for MS-Windows build.
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
290 used for building Vim.
557
862863033fdd updated for version 7.0158
vimboss
parents: 236
diff changeset
291
2342
f6540762173d Fixes and improvements for MS-Windows build.
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
292 To use the Perl interface the Perl DLL must be in your search path.
f6540762173d Fixes and improvements for MS-Windows build.
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
293 If Vim reports it cannot find the perl512.dll, make sure your $PATH includes
2355
84c7eeeb09e2 Fix typos in documentation. (Dominique Pelle)
Bram Moolenaar <bram@vim.org>
parents: 2345
diff changeset
294 the directory where it is located. The Perl installer normally does that.
8673
ed7251c3e2d3 commit https://github.com/vim/vim/commit/e18c0b39815c5a746887a509c2cd9f11fadaba07
Christian Brabandt <cb@256bit.org>
parents: 7196
diff changeset
295 In a console window type "path" to see what directories are used. The
ed7251c3e2d3 commit https://github.com/vim/vim/commit/e18c0b39815c5a746887a509c2cd9f11fadaba07
Christian Brabandt <cb@256bit.org>
parents: 7196
diff changeset
296 'perldll' option can be also used to specify the Perl DLL.
557
862863033fdd updated for version 7.0158
vimboss
parents: 236
diff changeset
297
862863033fdd updated for version 7.0158
vimboss
parents: 236
diff changeset
298 The name of the DLL must match the Perl version Vim was compiled with.
2342
f6540762173d Fixes and improvements for MS-Windows build.
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
299 Currently the name is "perl512.dll". That is for Perl 5.12. To know for
557
862863033fdd updated for version 7.0158
vimboss
parents: 236
diff changeset
300 sure edit "gvim.exe" and search for "perl\d*.dll\c".
862863033fdd updated for version 7.0158
vimboss
parents: 236
diff changeset
301
7196
42717d048817 commit https://github.com/vim/vim/commit/d94464ee294a351ce7b6ba18e8bd3f24f1bef920
Christian Brabandt <cb@256bit.org>
parents: 5400
diff changeset
302
42717d048817 commit https://github.com/vim/vim/commit/d94464ee294a351ce7b6ba18e8bd3f24f1bef920
Christian Brabandt <cb@256bit.org>
parents: 5400
diff changeset
303 Unix ~
42717d048817 commit https://github.com/vim/vim/commit/d94464ee294a351ce7b6ba18e8bd3f24f1bef920
Christian Brabandt <cb@256bit.org>
parents: 5400
diff changeset
304
42717d048817 commit https://github.com/vim/vim/commit/d94464ee294a351ce7b6ba18e8bd3f24f1bef920
Christian Brabandt <cb@256bit.org>
parents: 5400
diff changeset
305 The 'perldll' option can be used to specify the Perl shared library file
42717d048817 commit https://github.com/vim/vim/commit/d94464ee294a351ce7b6ba18e8bd3f24f1bef920
Christian Brabandt <cb@256bit.org>
parents: 5400
diff changeset
306 instead of DYNAMIC_PERL_DLL file what was specified at compile time. The
42717d048817 commit https://github.com/vim/vim/commit/d94464ee294a351ce7b6ba18e8bd3f24f1bef920
Christian Brabandt <cb@256bit.org>
parents: 5400
diff changeset
307 version of the shared library must match the Perl version Vim was compiled
42717d048817 commit https://github.com/vim/vim/commit/d94464ee294a351ce7b6ba18e8bd3f24f1bef920
Christian Brabandt <cb@256bit.org>
parents: 5400
diff changeset
308 with.
42717d048817 commit https://github.com/vim/vim/commit/d94464ee294a351ce7b6ba18e8bd3f24f1bef920
Christian Brabandt <cb@256bit.org>
parents: 5400
diff changeset
309
557
862863033fdd updated for version 7.0158
vimboss
parents: 236
diff changeset
310 ==============================================================================
14421
2f7e67dd088c Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13963
diff changeset
311 vim:tw=78:ts=8:noet:ft=help:norl: