Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 2b2c8d7d14
Fetching contributors…

Cannot retrieve contributors at this time

2482 lines (1899 sloc) 106.207 kb
*perlsupport.txt* Perl Support July 2 2009
Perl Support *perl-support* *perlsupport*
Plugin version 4.4
for Vim version 7.0 and above
Fritz Mehner <mehner@fh-swf.de>
Perl Support implements a Perl-IDE for Vim/gVim. It is written to considerably
speed up writing code in a consistent style. This is done by inserting
complete statements, comments, idioms, code snippets, templates, and POD
documentation. Reading perldoc is integrated. Syntax checking, running a
script, running perltidy, running perlcritics, starting a debugger and a
profiler can be done with a keystroke.
1. Usage with GUI |perlsupport-usage-gvim|
1.1 Menu 'Comments' |perlsupport-comments|
1.1.1 Append aligned comments |perlsupport-aligned-comm|
1.1.2 Adjust end-of-line comments |perlsupport-comm-realign|
1.1.3 Toggle comments |perlsupport-comm-toggle|
1.1.4 Comment out a block of code |perlsupport-comm-block|
1.1.5 Uncomment a block of code |perlsupport-uncomm-block|
1.1.6 KEYWORD + comment |perlsupport-comm-keywords|
1.2 Menu 'Statements' |perlsupport-statements|
1.2.1 Normal mode, insert mode |perlsupport-stat-norm-ins|
1.2.2 Visual mode |perlsupport-stat-visual|
1.3 Menu 'Idioms' |perlsupport-idioms|
1.3.1 Stub subroutine |perlsupport-stub-sub|
1.3.2 Opening files |perlsupport-open-files|
1.4 Menu 'Snippets' |perlsupport-snippets-menu|
1.4.1 Code Snippets |perlsupport-snippets-menu|
1.4.2 Code Templates |perlsupport-templates-menu|
1.5 Menu 'Regex' |perlsupport-regex|
1.5.1 Compose regular expressions |perlsupport-regex-compose|
1.5.2 Explain regular expression |perlsupport-regex-explain|
1.5.3 Match |perlsupport-regex-match|
1.5.3.1 Visual mode |perlsupport-regex-visual-mode|
1.5.3.2 Multiline strings |perlsupport-regex-match-multiline|
1.5.3.3 Modifier g |perlsupport-regex-modifier-g|
1.5.3.4 Normal mode |perlsupport-regex-normal-mode|
1.5.4 Match multiple |perlsupport-regex-match-multiple|
1.5.5 Submenu 'CharCls' |perlsupport-regex-charcls|
1.5.6 Submenu 'Unicode property' |perlsupport-regex-unicodeprop|
1.5.7 Submenu 'extended Regex' |perlsupport-regex-ext|
1.6 Menu 'File-Tests' |perlsupport-filetests|
1.7 Menu 'Spec-Var' |perlsupport-specvar|
1.8 Menu 'POD' |perlsupport-pod|
1.8.1 Menu 'invisible POD' |perlsupport-pod-invisible|
1.8.2 Run podchecker |perlsupport-podchecker|
1.9 Menu 'Run' |perlsupport-run|
1.9.1 Run script |perlsupport-run-script|
1.9.2 Check syntax |perlsupport-syntax-check|
1.9.3 Command line arguments |perlsupport-cmdline-args|
1.9.4 Perl command line switches |perlsupport-perl-switches|
1.9.5 Debug |perlsupport-run-debug|
1.9.6 Read perldoc |perlsupport-perldoc|
1.9.7 Generate Perl module list |perlsupport-module-list-generation|
1.9.8 Show installed Perl modules |perlsupport-module-list|
1.9.9 Run perltidy |perlsupport-perltidy|
1.9.10 Profiler |perlsupport-profiler|
1.9.11 Run perlcritic |perlsupport-perlcritic|
1.9.12 Save buffer with timestamp |perlsupport-timestamp|
1.9.13 Hardcopy |perlsupport-hardcopy|
1.9.14 Settings |perlsupport-settings|
1.9.15 Xterm size |perlsupport-xterm|
1.9.16 Change Output Destination |perlsupport-output|
1.10 Help |perlsupport-help|
2. Usage without GUI |perlsupport-mappings|
3. Function Keys |perlsupport-function-keys|
4. Customization and configuration |perlsupport-customization|
4.1 Files |perlsupport-custom-files|
4.2 Global variables |perlsupport-custom-variables|
4.3 The root menu |perlsupport-custom-root|
4.4 Navigate through PODs |perlsupport-custom-navigate|
4.5 Tabulator width |perlsupport-custom-tab|
4.6 System-wide installation |perlsupport-system-wide|
5. Template files and tags |perlsupport-templates|
5.1 Template files |perlsupport-templates-files|
5.2 Macros |perlsupport-templates-macros|
5.2.1 Formats for date and time |perlsupport-templates-date|
5.3 Templates |perlsupport-templates-names|
5.3.1 Template names |perlsupport-templates-names|
5.3.2 Template definition |perlsupport-templates-definition|
5.3.3 Template expansion |perlsupport-templates-expansion|
5.3.4 The macros <+text+> etc. |perlsupport-templates-jump|
5.3.5 Command Ctrl-j |perlsupport-Ctrl-j|
5.4 Switching between template sets |perlsupport-templates-sets|
6 Perl::Tags |perlsupport-perltags|
7. Perl Dictionary |perlsupport-dictionary|
8. Optional Dependencies |perlsupport-dependencies|
9. Compiling Vim |perlsupport-compile-vim|
10. Folding |perlsupport-folding|
11. Additional Mappings |perlsupport-ad-mappings|
12. Autoloading |perlsupport-autoload|
13. MS-Windows particularities |perlsupport-windows|
14. Troubleshooting |perlsupport-troubleshooting|
15. Release Notes / Change Log |perlsupport-release-notes|
16. Credits |perlsupport-credits|
How to add this help file to vim's help |add-local-help|
==============================================================================
1. USAGE WITH GUI (gVim) *perlsupport-usage-gvim*
==============================================================================
Nearly all menu entries insert code snippets or comments. All these stuff is
taken from template files and can be changed by the user to meet his
requirements (see|perlsupport-templates|).
If the root menu 'Perl' is not visible call it with the item
"Load Perl Support" from the standard Tools-menu.
The item "Unload Perl Support" can be used to unload the Perl root menu.
See also |perlsupport-custom-root|.
------------------------------------------------------------------------------
1.1 MENU 'Comments' *perlsupport-comments*
------------------------------------------------------------------------------
1.1.1 APPEND ALIGNED COMMENTS TO CONSECUTIVE LINES *perlsupport-aligned-comm*
--------------------------------------------------
In NORMAL MODE the menu item
'Line End Comm.'
will append a comment to the current line.
In VISUAL MODE this item will append aligned comments to all marked lines.
Marking the 3 lines
my $x11 = 11;
my $x1111 = 1111;
my $x11111111 = 11111111;
and choosing 'Line End Comm.' will yield
my $x11 = 11; # |
my $x1111 = 1111; #
my $x11111111 = 11111111; #
The cursor position above is marked by '|' . Empty lines will be ignored.
The default starting column is 49 ( = (multiple of 2,4, or 8) + 1 ). This can
be changed by setting a global variable in the file .vimrc , e.g. :
let g:Perl_LineEndCommColDefault = 45
The starting column can also be set by the menu item 'Comments->Set End Comm.
Col.' . Just position the cursor in an arbitrary column (column number is
shown in the Vim status line) and choose this menu item. This setting is
buffer related.
If the cursor was at the end of a line you will be asked for a column number
because this position is most likely not the desired starting column.
Your choice will be confirmed.
1.1.2 ADJUST END-OF-LINE COMMENTS *perlsupport-comm-realign*
----------------------------------
After some copy/paste/change actions comments may be misaligned:
my $x11 = 11; # comment 1
my $x111 = 1111; # comment 2
my $x1111 = 11111111; # comment 3
Realignment can be achieved with the menu item 'adjust end-of-line com.' In
normal mode the comment (if any) in the current line will be aligned to the
end-of-line comment column (see above) if possible. In visual mode the
comments in the marked block will be aligned:
my $x11 = 11; # comment 1
my $x111 = 1111; # comment 2
my $x1111 = 11111111; # comment 3
The realignment function tries to interpret hash signs inside match and search
operators not as a start of a comment. This may not be perfect.
1.1.3 TOGGLE COMMENTS *perlsupport-comm-toggle*
----------------------
The comment sign # can be set or removed at the beginning of the current line
or for a marked block. A single line needs not to be marked.
A marked block
my $x11 = 11;
#my $x1111 = 1111;
# print "\n";
#print "\n";
will be changed into (and vice versa)
#my $x11 = 11;
#
my $x1111 = 1111;
print "\n";
print "\n";
Whitespaces in front of the hash sign will be preserved.
1.1.4 COMMENT OUT A BLOCK OF CODE *perlsupport-comm-block*
---------------------------------
In normal mode the menu item 'comment block' inserts an empty POD block which
can be used like a C preprocessor directive for conditional compilation.
Statements inside will not be executed by the Perl interpreter. This is
usually done to temporarily block out some code.
=begin BlockComment # BlockCommentNo_1
=end BlockComment # BlockCommentNo_1
=cut
In visual mode a block of code like
print "x11 = $x11\n";
print "x22 = $x22\n";
will be surrounded by the above construct:
=begin BlockComment # BlockCommentNo_2
print "x11 = $x11\n";
print "x22 = $x22\n";
=end BlockComment # BlockCommentNo_2
=cut
The label names like BlockCommentNo_2 are automatically inserted into the
comments. The trailing numbers are automatically incremented if you apply the
command again. These numbers can be changed by the user (both!). The next
number will be one above the highest number found in the current buffer. The
empty lines between the POD statements are necessary.
A corresponding label can be found by searching with the vim star command (*).
All labels can be found with a global search like :g/BlockCommentNo_/ or
:g/BlockCommentNo_\d\+/.
1.1.5 UNCOMMENT A BLOCK OF CODE *perlsupport-uncomm-block*
-------------------------------
The menu item 'uncomment block' removes such a construct if the cursor is in
the middle of such a block or on the line with '=begin ...'. Nested constructs
will be untouched.
1.1.6 KEYWORD+comment *perlsupport-comm-keywords*
---------------------
Insert preliminary end-of-line comments to document (and find again) places
where work will be resumed shortly, like
# :TODO:12.05.2004:Mn: <your comment>
Usually not meant for the final documentation.
------------------------------------------------------------------------------
1.2 MENU 'Statements' *perlsupport-statements*
------------------------------------------------------------------------------
1.2.1 NORMAL MODE, INSERT MODE. *perlsupport-stat-norm-ins*
--------------------------------
An empty statement will be inserted and properly indented. The item 'if{}'
will insert an if-statement:
if ( ) {
}
1.2.2 VISUAL MODE. *perlsupport-stat-visual*
-------------------
The highlighted area
xxxxx
xxxxx
can be surrounded by one of the following statements ( '|'
marks the cursor position after insertion):
+----------------------------------------------------------+
| |
| do { |
| xxxxx |
| xxxxx |
| } |
| while ( | ); # ----- end do-while ----- |
| |
+--------------------------+-------------------------------+
| | |
| for ( my $|; ; ) { | foreach my $| ( ) { |
| xxxxx | xxxxx |
| xxxxx | xxxxx |
| } | } |
| | |
+--------------------------+-------------------------------+
| | |
| if ( | ) { | if ( | ) { |
| xxxxx | xxxxx |
| xxxxx | xxxxx |
| } | } |
| | else { |
| | } |
| | |
+--------------------------+-------------------------------+
| | |
| unless ( | ) { | unless ( | ) { |
| xxxxx | xxxxx |
| xxxxx | xxxxx |
| } | } |
| | else { |
| | } |
| | |
+--------------------------+-------------------------------+
| | |
| until ( | ) { | while ( | ) { |
| xxxxx | xxxxx |
| xxxxx | xxxxx |
| } | } |
| | |
+--------------------------+-------------------------------+
| | |
| { | elsif ( | ) { |
| xxxxx | xxxxx |
| xxxxx | xxxxx |
| } | } |
| | |
+--------------------------+-------------------------------+
| | |
| else { | |
| xxxxx | |
| xxxxx | |
| } | |
| | |
+--------------------------+-------------------------------+
The whole statement will be indented after insertion.
The foreach loop uses a lexical iterator variable becaues Perl does this
anyway.
------------------------------------------------------------------------------
1.3 MENU 'Idioms' *perlsupport-idioms*
------------------------------------------------------------------------------
1.3.1 STUB SUBROUTINE *perlsupport-stub-sub*
----------------------
In normal mode the item 'subroutine' asks for a subroutine name and creates a
stub subroutine with one parameter:
sub xxx {
my ($par1) = @_;
return ;
} # ---------- end of subroutine xxx ----------
In visual mode with a few lines marked this item will enclose these lines in
a subroutine and generate a call to this subroutine. The lines
print "x11 = $x11\n";
print "x22 = $x22\n";
print "x33 = $x33\n";
will be changed into
sub abc {
my ($par1) = @_;
print "x11 = $x11\n";
print "x22 = $x22\n";
print "x33 = $x33\n";
return ;
} # ---------- end of subroutine abc ----------
The further adaption is left to the user.
1.3.2 OPENING FILES *perlsupport-open-files*
--------------------
All declarations beginning with 'my' and the multi-line statements (subroutine,
open input file / output file / pipe) will be inserted below the current line.
Everything else will be inserted at the cursor position.
The entries 'open input file', 'open output file' and 'open pipe' ask for the
name of a file handle. The following lines will be inserted:
my $INFILE_file_name = ''; # input file name
open my $INFILE, '<', $INFILE_file_name
or die "$0 : failed to open input file $INFILE_file_name : $!\n";
close $INFILE
or warn "$0 : failed to close input file $INFILE_file_name : $!\n";
The menu items and hotkeys for opening a file or a pipe have a visual mode.
When a block is selected the code for opening a file/pipe will be inserted
above this block, the close statement will be inserted below.
------------------------------------------------------------------------------
1.4 MENU 'Snippets' *perlsupport-snippets-menu*
------------------------------------------------------------------------------
1.4.1 Code Snippets
--------------------
Code snippets are pieces of code which are kept in separate files in a special
directory. File names are used to identify the snippets. The default snippet
is ( $HOME/.vim/codesnippets-perl is the default). Snippets are managed with
the 3 entries
Perl -> Statements -> read code snippet
Perl -> Statements -> write code snippet
Perl -> Statements -> edit code snippet
from the Snippets submenu.
Creating a new snippet:
-----------------------
When nothing is marked, "write code snippet" will write the whole buffer
to a snippet file. Otherwise the marked area will be written to a file.
Insert a snippet:
-----------------
Select the appropriate file from the snippet directory ("read code snippet").
The inserted lines will be indented.
Indentation / no indentation
----------------------------
Code snippets are normally indented after insertion. To suppress indentation
add the file extension "ni" or "noindent" to the snippet file name, e.g.
parameter_handling.pl.noindent
There are some snippets belonging to this plugin package. These are examples.
Add your own.
Snippet browser
---------------
Under a GUI a file requester will be put up. Without GUI the filename will be
read from the command line. You can change this behavior by setting a global
variable in your ~/.vimrc :
let g:Perl_GuiSnippetBrowser = 'commandline'
The default value is 'gui'.
1.4.2 Code Templates *perlsupport-templates-menu*
---------------------
Nearly all menu entries insert code snippets or comments. All these stuff is
taken from template files and can be changed by the user to meet his
requirements (see|perlsupport-templates|on how to use the template system).
The menu item 'edit local templates' opens the main template file in a local
plugin installation. This is usually the file
'~/.vim/perl-support/templates/Templates'. There may be dependent files
loaded from the main file. Now change whatever file you want, save it, and
click on the menu item 'reread templates' to read in the file(s) and to
rebuild the internal representation of the templates.
The menu item 'edit global templates' opens the main template file in a
system-wide plugin installation (see |perlsupport-system-wide|). This is
usually the file '$VIM./vimfiles/perl-support/templates/Templates'.
Template browser
----------------
Under a GUI a file requester will be put up. Without GUI the filename will be
read from the command line. You can change this behavior by setting a global
variable in your ~/.vimrc :
let g:Perl_GuiTemplateBrowser = 'explorer'
The default value is 'gui'. 'explorer' will start the file explorer
(see help|:Explore|). To use the commandline asign 'commandline'.
------------------------------------------------------------------------------
1.5 MENU 'Regex' *perlsupport-regex*
------------------------------------------------------------------------------
1.5.1 COMPOSE REGULAR EXPRESSIONS *perlsupport-regex-compose*
----------------------------------
In NORMAL and INSERT MODE the shown items will be inserted at the cursor
position.
In VISUAL MODE the following entries and all entries from the 'extended Regex'
submenu will surround a marked area 'xxx' like this:
() : (xxx)
(|) : (xxx|)
[] : [xxx]
{} : {xxx}
{,} : {xxx,}
1.5.2 EXPLAIN REGULAR EXPRESSION *perlsupport-regex-explain*
---------------------------------
If the Perl module YAPE::Regex::Explain is installed a regular expression
can be explained to you.
Just mark the expression (v-mode) and use the menu entry 'explain Regex' or
the hotkey '\xe'.
You also can pick up a complete line containing a regular expression with the
menu entry 'pick up regex' in normal mode. In this case leading and trailing
whitespaces will be removed.
Flags for the operator m/// can be picked up using the menu entry 'pick up
flags'.
The regular expression will now be explained in a new buffer called
'REGEX-EXPLAIN'. This buffer is not related to a file and will not be
written, but the content can be printed with the hardcopy entry in the
Run-menu. A regular expression can span several lines.
In order to use this feature you need a Vim binary with Perl interface
compiled in (see |perl|) and YAPE::Regex::Explain must be installed, of
course.
1.5.3 MATCH *perlsupport-regex-match*
------------
If you have a Vim binary with Perl interface compiled in (see |perl|) you can
test regular expressions very easily. This can be done in two ways.
1.5.3.1 VISUAL MODE *perlsupport-regex-visual-mode*
Pick up a regular expression by selecting the appropriate
string (v-mode; e.g. inside the m// operator) and use the menu entry 'pick up
regex'. Pick up flags the same way with 'pick up flags'. Now pick up a string
as target with 'pick up string' and select the menu entry 'match'. The regular
expression, the target and the match are shown in a new window called
REGEX-TEST:
REGEXP = m{([\w\s]+)(jumped)(.{1,6})([\w\s]+)}
STRING [ 0, 53] = ### The quick brown fox jumped over the lazy dog. ###
prematch [ 0, 3] = ###
MATCH [ 3, 45] = | The quick brown fox jumped over the lazy dog|
postmatch [ 48, 5] = . ###
$1 [ 3, 21] = | The quick brown fox |
$2 [ 24, 6] = jumped
$3 [ 30, 6] = | over |
$4 [ 36, 12] = the lazy dog
In addition the match will be highlighted in most cases. The match is done as
$string =~ m{(?flags:$regexp)}
by the Perl interface. For the flags see|perlsupport-regex-flags|).
The brackets after a match object contain the starting position (starting
with 0) and the length of the object. Objects starting or ending with one or
more spaces are enclosed in vertical bars.
Multiline regular expressions (like the string inside the braces below) are
allowed. They work properly if the flag 'x' is set.
regexp = m{ \d+
/ # a/b
\d+
}x
The most-recently-closed capturing parenthesis submatch ($^N) will be
displayed if it differs from the last parenthesized submatch ($+).
REGEXP = m{(a|b)((a|b)(a|b))}
STRING [ 0, 3] = aba
MATCH [ 0, 3] = aba
$1 [ 0, 1] = a
$2 [ 1, 2] = ba
$3 [ 1, 1] = b
$4 [ 2, 1] = a
$^N [ 2] = ba
1.5.3.2 MULTILINE STRINGS *perlsupport-regex-match-multiline*
Multiline strings are also allowed. The regular expression '(\n+)$' matches
consecutive linefeeds at the end of a string or inside a string when used with
the flag 'm'. The string in the following example consists of the 6 lines
from 'aaaa' to 'eeee'. The second, third, and fourth line contains 1 to 3
tabulators each (tab width is 2). The fifth line line is empty:
aaaa
bb bb
cc cc
dd dd
eeee
With the flag 'm' matching gives the following visualization:
REGEXP = m{(\n+)$}m
lines : 6 = |1.. |2... |3.... |4..... |6..
STRING [ 0, 32] = aaaa$bb~bb$cc~~cc$dd~~~dd$$eeee$
prematch [ 0, 25] = aaaa$bb~bb$cc~~cc$dd~~~dd
MATCH [ 25, 1] = $
postmatch [ 26, 6] = $eeee$
$1 [ 25, 1] = $
Control character replacement: \n -> '$' \t -> '~'
The linefeeds inside the string have been replace by dollar signs, the
tabulators have been replaced by the tilde. A ruler line will be shown. The
start of some lines are marked with the line number (depending on the line
length).
The control character replacements can be changed on the command line, e.g.:
:RegexSubstitutions '# '
or by changing the defaults in the file '.vimrc'
let g:Perl_PerlRegexSubstitution = '# '
Linefeeds will now be replaced by '#' (the first character of the given pair),
tabulators will be replaced by a space. Control characters are not allowed as
replacements.
1.5.3.3 MODIFIER g *perlsupport-regex-modifier-g*
The modifier 'g' can be used. The match operator
m/(\d\d)/g
applied to the string
'aaa 1234567890 BBB 123'
gives the following result:
REGEXP = m{(\d\d)}g
STRING [ 0, 22] = aaa 1234567890 BBB 123
prematch [ 0, 19] =|aaa 1234567890 BBB |
MATCH [ 19, 2] = 12
postmatch [ 21, 1] = 3
$1 [ 19, 2] = 12
1.MATCH [ 4, 2] = 12
2.MATCH [ 6, 2] = 34
3.MATCH [ 8, 2] = 56
4.MATCH [ 10, 2] = 78
5.MATCH [ 12, 2] = 90
6.MATCH [ 19, 2] = 12
The match is done in a loop. Prematch, match and postmatch belong to the last
match in this loop. All consecutive matches will be appended to the the
submatches and the last code result.
1.5.3.4 NORMAL MODE *perlsupport-regex-normal-mode*
You can use a scratch buffer or a scratch area to test your
regular expressions. Just write the naked regular expression in one line and
the string on the next line:
([\w\s]+)(jumped)(.{1,6})([\w\s]+)
### The quick brown fox jumped over the lazy dog. ###
Now select 'pick up regex', 'pick up string', and 'match' in normal mode
or use the hotkeys \xr, \xs, \xm and \xmm .
Leading and trailing whitespaces are removed from the regex and target string
if picked up in normal mode. If one of these strings has such whitespaces pick
it up in visual mode.
The picked up regular expression, the string, and the flags are kept in
internal variables. After a change you have just to renew the changed item.
The variable for the regular expression and for the flags is also used by the
menu entry 'explain regex' (see|perlsupport-regex-explain|).
PICK UP FLAG(S) *perlsupport-regex-flags*
The menu item 'pick up flag(s)' asks for one of the regular expression flags
'imsx' or any combination of them (hotkeys \xf ). You can also mark flags in
visual mode and pick the selection up. Characters other than the allowed flags
will be removed.
PICKING UP A MATCH OPERATOR m// WITH FLAGS
If a complete match operator (with flags, if any) is picked up, the plugin
will try to seperate the regular expression and the flags from this line(s).
This form is often be found in the code and saves marking the flags as an
additional action. The recognized flags and the regular expression will be
shown in a message. The following forms are allowed (flags are optional):
/<regex>/<flags> ?<regex>?<flags>
m/<regex>/<flags> m?<regex>?<flags>
m<delimiter><regex><delimiter><flags>
m{<regex>}<flags>
m(<regex>)<flags>
m[<regex>]<flags>
m<<regex>><flags>
Multiline expressions are also possible.
1.5.4 MATCH MULTIPLE *perlsupport-regex-match-multiple*
---------------------
If you have a Vim binary with Perl interface compiled in (see |perl|) you can
test several targets with several regular expressions:
(1) Pick up one or more marked lines with 'pick up regex' or with \xr.
(2) Pick up one or more target strings with 'pick up string' or \xs.
(3) Pick up flags (if any) the same way with 'pick up flags' or \xf.
(4) Select the menu entry 'match multiple' or use \xmm.
The regular expressions, the targets and the matches are shown in a new window
called REGEX-TEST:
1. REGEXP = m{^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,15}$}
1 'abc123'
2 <MATCH> 'BA99342bob'
3 '1232z123311'
4 'abcdef'
5 '123456'
6 '123'ABC'
----- matches: 1/6 -----
2. REGEXP = m{^(?=.*\d)(?=.*[a-zA-Z])(?!.*[\W_\x7B-\xFF]).{6,15}$}
1 <MATCH> 'abc123'
2 <MATCH> 'BA99342bob'
3 <MATCH> '1232z123311'
4 'abcdef'
5 '123456'
6 '123'ABC'
----- matches: 3/6 -----
This example shows two password validator expressions tested against 6
passwords. The matches are marked.
The following rules apply:
If several lines are selected as regular expression and the flag 'x' is set or
found, this lines are used as one extented expression.
If several lines are selected as targets and the flag 'm' is set or
found, this lines are used as one multiline target.
1.5.5 SUBMENU 'CharCls' *perlsupport-regex-charcls*
-------------------------
The entries from this menus will be inserted at the cursor position.
1.5.6 SUBMENU 'Unicode property' *perlsupport-regex-unicodeprop*
----------------------------------
The entries from this menus will be inserted at the cursor position.
1.5.7 SUBMENU 'extended Regex' *perlsupport-regex-ext*
--------------------------------
The entries from this menus will be inserted at the cursor position. The items
have an visual mode too. With 'bbb' marked in the line
aaa bbb ccc
choosing the menu item '(?:...)' yields
aaa (?:bbb) ccc
------------------------------------------------------------------------------
1.6 MENU 'File-Tests' *perlsupport-filetests*
1.7 MENU 'Spec-Var' *perlsupport-specvar*
------------------------------------------------------------------------------
The entries from these menus will be inserted at the cursor position.
------------------------------------------------------------------------------
1.8 MENU 'POD' *perlsupport-pod*
------------------------------------------------------------------------------
Most entries insert POD commands below the cursor position, e.g.
=pod
=cut
The entries 'POD->html', 'POD->man', 'POD->text' call the appropriate
translator which will generate the desired document from the current buffer.
The plugin taglist.vim (Yegappan Lakshmanan) can be expanded for POD
navigation. See |perlsupport-custom-navigate|.
1.8.1 MENU 'invisible POD' *perlsupport-pod-invisible*
---------------------------
These menu entries insert "invisible" POD sections as suggested in Damian
Conway's book "Perl Best Practices", e.g.
=for Improvement: <keyword>
<single paragraph>
=cut
In visual mode these menu entries will surround the marked block with the
appropriate construct. The '=for' line will be put before the first nonempty
line of the marked block.
The text in the single paragraph will be ignored by the compiler and by a POD
formatter. This can be used to embed extended pieces of internal
documentation. For the paragraph to be invisible there must not be an empty
line between =for ... and the following paragraph.
The four formatter names "Improvement", "Optimization", "Rationale", and
"Workaround" are just suggestions. You can choose additional ones.
The <keyword> is a short explanation which makes navigation with taglist
easier. See |perlsupport-custom-navigate|.
Please note the colon after the "formatter name". It is needed for parsing
this construct.
1.8.2 RUN PODCHECKER *perlsupport-podchecker*
---------------------
The current buffer will be run through the application podchecker to check the
syntax of the embedded POD or of a POD format documentation file (see
podchecker(1) and Pod::Checker).
Podchecker always reports errors. Printing warnings can be turned on and off
with the options -warnings/-nowarning . The default is to print warnings. To
turn the warnings off put the following line in the file .vimrc :
let g:Perl_PodcheckerWarnings = 'no'
------------------------------------------------------------------------------
1.9 MENU 'Run' *perlsupport-run*
------------------------------------------------------------------------------
1.9.1 RUN SCRIPT *perlsupport-run-script*
-----------------
Run the script in the current buffer. The output destination can be chosen
using the menu item 'Run->output: ...'. There are 3 choices: VIM command
line, seperate output buffer and xterm (see |perlsupport-output|).
1.9.2 CHECK SYNTAX *perlsupport-syntax-check*
-------------------
The script is run as "perl -wc xxx.pl" with most warnings enabled to check
the syntax.
The Perl script efm_perl.pl (from the VIM standard distribution with a minor
improvement) is needed for checking the syntax of a file with a file name or a
pathname containing blanks. Due to a weakness in the file name representation
in the Perl output, messages have to be filtered in order to be processed
correctly by the VIM quickfix system.
This script has to be executable under UNIX.
For convenience consider to use maps like
noremap <silent> <F5> :copen<CR>
noremap <silent> <F6> :cclose<CR>
noremap <silent> <F7> :cp<CR>
noremap <silent> <F8> :cn<CR>
in your .vimrc file to jump to the error locations (F7,F8) and to open and
close the error window (F5,F6). This makes navigation a lot easier (see also
file 'customization.vimrc', |perlsupport-custom-files|). The error list and
the error locations in your source buffer will be synchronized.
1.9.3 COMMAND LINE ARGUMENTS *perlsupport-cmdline-args*
-----------------------------
The item 'command line arguments' calls an input dialog which asks for
command line arguments. These arguments are forwarded to the script which
is run by the 'run' item. The arguments are kept until you change them.
The arguments can contain pipes and redirections, e.g.
" infile.txt | sort -rn > result.txt"
For the first and only the first argument file name expansion will work (use
the Tab-key).
The arguments belong to the current buffer (that is, each buffer can have its
own arguments). The input dialog has a history.
If the buffer gets a new name with "save as" the arguments will now belong to
the buffer with the new name.
1.9.4 PERL COMMAND LINE SWITCHES *perlsupport-perl-switches*
---------------------------------
The item 'perl switches' calls an input dialog which asks for command line
switches for the perl interpreter. These arguments are forwarded to the call
of the script which is run by the 'run' item. The switches are kept until you
change them.
The switches belong to the current buffer (that is, each buffer can have its
own independent switches). The input dialog has a history.
If the buffer gets a new name with "save as" the switches will now belong to
the buffer with the new name.
1.9.5 DEBUG *perlsupport-run-debug*
------------
Start a debugger from the menu item Run->debug, with hotkey \rd or F9. One of
three debuggers can be started. The preference can be set with the variable
g:Perl_Debugger (possible values: 'perl', 'ptkdb', 'ddd' ). The default is
'perl').
(1) perl
The script will be run as 'perl -d my-script.pl my-arguments' in an xterm.
(2) ptkdb
The debugger ptkdb will be started as an independent process. ptkdb is a Perl
debugger using a Tk GUI. The module Devel::ptkdb and the Tk tool kit have to
be installed (see |perlsupport-dependencies|).
(3) ddd
The data display debugger ddd is a graphical front end for GDB (see
|perlsupport-dependencies|). It will be started as an independent process.
The debugger ddd is not available under MS-Windows.
The debugger starts in an separate xterm or is a separate GUI-application
(e.g. ddd).
Command line arguments (see |perlsupport-cmdline-args|) will be passed on to
the debugger.
Debugging without GUI
---------------------
The hotkey \rd or F9 can be used to start the debugger inside the vim window.
The script will be run with 'perl -d my-script.pl my-arguments'.
1.9.6 READ PERLDOC *perlsupport-perldoc*
-------------------
If a (key-)word is under the cursor the item 'read perldoc' tries to look up
the Perl documentation for this word using perldoc. If a whitespace is under
the cursor the user will be asked for a keyword. Search order:
1. modules *-<-+
2. functions | |
3. FAQs +->-+
This sequence is organized as a ring. If you search for the same item in the
module description (if any) again the plugin tries to look up a function
description, then a FAQ and then the module description again.
On a UNIX platform errors produced by perldoc will be suppressed (a few
module descriptions have POD errors!).
1.9.7 GENERATE PERL MODULE LIST *perlsupport-module-list-generation*
--------------------------------
The item 'Run -> generate Perl module list' generates a text file (default:
$HOME/.vim/perl-support/modules/perl-modules.list ) which contains one line
for each Perl module installed on your machine:
...
Fcntl (1.05) - load the C Fcntl.h defines
File::Basename (2.72) - split a pathname into pieces
File::CheckTree (4.3) - run many filetest checks on a tree
File::Compare (1.1003) - Compare files or filehandles
File::Copy (2.07) - Copy files or filehandles
...
The module list is generated by the Perl script
$HOME/.vim/perl-support/modules/pmdesc3.pl (based on pmdesc2 by Aristotle, see
|perlsupport-credits| ). This script has to be executable under UNIX. The
generation may take a while. pmdesc3.pl has a POD included; see file
doc/pmdesc3.text .
1.9.8 SHOW INSTALLED PERL MODULES *perlsupport-module-list*
----------------------------------
The item 'Run -> show installed Perl modules' loads the module list in a new
window. The full documentation for that module can be opened in a perldoc
help window using the hot keys <Shift-F1>, \h or \rp .
Looking up help with Shift-F1 works also in the perldoc help window.
Vim (without GUI): only \h and \rp are working.
1.9.9 RUN PERLTIDY *perlsupport-perltidy*
-------------------
The buffer can be formatted with perltidy. If nothing is marked the whole
buffer will be formatted. If a region is marked only this region will be
formatted.
Perltidy has a lot of options. It is recommended to use a .perltidyrc
initialization file to define the preferred style (see 'man 1 perltidy').
See also |perlsupport-troubleshooting|.
1.9.10 PROFILER *perlsupport-profiler*
----------------
This plugin is prepared to work with 3 profilers:
Devel::SmallProf - per-line Perl profiler
Devel::FastProf - "fast" per-line Perl profiler
Devel::NYTProf - Powerful feature-rich perl source code profiler
1.9.10.1 Devel::SmallProf *perlsupport-smallprof*
--------------------------
The menu item 'Profiler->SmallProf->run profiler' runs the profiler for the
script in the current buffer. The results will go to the file smallprof.out
in the current directory. This file will be automatically loaded into a
quickfix buffer.
Devel::SmallProf (version 2.00_03) is controlled
by 4 variables (default values shown here):
$DB::drop_zeros = 0; # Do not show lines which were never called: 1
$DB::grep_format = 0; # Output on a format similar to grep : 1
$DB::profile = 1; # Turn off profiling for a time: 0
%DB::packages = ('main'=>1); # Only profile code in a certain package.
These variables can be put in a file called .smallprof in the current
directory. See the module documentation for more information.
Command line arguments (see |perlsupport-cmdline-args|) will be passed on to
the profiler.
Hot spot list in the QuickFix window
------------------------------------
The profiler will be run by the following command:
SMALLPROF_CONFIG=gz perl -d:SmallProf <Perl script> [<arguments>]
The leading part of this command turns on the grep like format (g) and drops
lines which were never called (z). Point and click to go to the script hot
spots.
The report can be sorted using the criterion file-name, line-number,
line-count, time (wall time), ctime (cpu time) using the appropriate menu
item.
In the absence of menus (console mode) sorting is done with the command
:SmallProfSort [ file-name | line-number | line-count | time | ctime ]
Use command completion. Type :Small<Tab> to complete the command name and
a blank and another <Tab> to show the list criteria. The selection will be
highlighted.
Resorting the profiling statistics uses sort(1) and a temporary file.
Resorting is not available under MS-Windows.
Additional hint
---------------
Use the configuration file '.smallprof' to set the deepth of the profiling,
e.g. with
%DB::packages = ('main'=>1); # Only profile code in a certain package.
Please see the package documentation for more information. The following
setting in the file '~/.vimrc' seems also to influence the statistics:
"-----------------------------------------------------------------------------
" The current directory is the directory of the file in the current window.
"-----------------------------------------------------------------------------
if has("autocmd")
autocmd BufEnter * :lchdir %:p:h
endif
Without this setting the report only includes the statistics for the file
profiled. With this setting the report includes the other modules used.
1.9.10.2 Devel::FastProf *perlsupport-fastprof*
-------------------------
The menu item 'Profiler->FastProf->run profiler' runs the profiler for the
script in the current buffer. The results will go to the file fastprof.out in
the current directory. This file will be automatically loaded into a quickfix
buffer.
The report can be sorted using the criterion file-name, line-number, time,
line-count using the appropriate menu item.
In the absence of menus (console mode) sorting is done with the command
:FastProfSort [ file-name | line-number | time | line-count ]
Use command completion. Type :Fast<Tab> to complete the command name and
a blank and another <Tab> to show the list criteria. The selection will be
highlighted.
Resorting the profiling statistics uses sort(1) and a temporary file.
Resorting is not available under MS-Windows.
1.9.10.3 Devel::NYTProf *perlsupport-nytprof*
------------------------
The menu item 'Profiler->NYTProf->run profiler' runs the profiler for the
script in the current buffer. The results will go to the subdirectory nytprof
below the current directory. The profiler generates HTML- and CSV-files
containing the results. Only the CSV-files can be loaded into the editor using
the item 'Profiler->NYTProf->read CSV file'. The selected file will be
automatically loaded into a quickfix buffer.
The report can be sorted using the criterion file-name, line-number, time,
calls, time/call using the appropriate menu item.
In the absence of menus (console mode) sorting is done with the command
:FastProfSort [ file-name | line-number | time | calls | time-call ]
Use command completion. Type :NYT<Tab> to complete the command name and
a blank and another <Tab> to show the list criteria. The selection will be
highlighted.
Resorting the profiling statistics uses sort(1) and a temporary file.
Resorting is not available under MS-Windows.
Profiled library modules are opend as read-only copies in a temp directory.
The Devel::NYTProf profiler generates also HTML-files to be viewed with a
browser. To allow the generation of these files set a global variable in
the file '~/.vimrc' to 'yes' (default is 'no'):
let g:Perl_NYTProf_html = 'yes'
1.9.11 RUN PERLCRITIC *perlsupport-perlcritic*
---------------------
"perlcritic" is a Perl source code analyzer (by Jeffrey Ryan Thalhammer;
search CPAN for the latest version; see also |perlsupport-dependencies|).
This excellent tool is the executable front-end to the Perl::Critic engine,
which attempts to identify awkward, hard to read, error-prone, or
unconventional constructs in your code. Most of the rules are based on Damian
Conway's book Perl Best Practices (PBP). When run from the menu the current
buffer will be saved and run through perlcritic. The reported violations will
be displayed in a separate quickfix error window.
Two perlcritic comand line options can be set by this plugin:
-severity N : Directs perlcritic to only report violations of Policies with
a severity greater than N.
-vebose N : Sets the verbosity level for reporting violations.
SEVERITY
--------
Perlcritic (version 1.02) has 5 severity levels (perlcritic default level
is 5). This plugin sets the default level to 3. This can be changed by
setting the variable g:Perl_PerlcriticSeverity in .vimrc to another value
(1-5):
let g:Perl_PerlcriticSeverity = 1
In addition there is an Ex command to do that, e.g.:
:CriticSeverity 2
The severity names can also be used (gentle, stern, harsh, cruel, brutal).
VERBOSITY
---------
Perlcritic (version 1.02) has 11 verbosity levels (default level is 4). Some
levels are equal except for the filename and are therefore treated equal
because the quickfix error system used by this plugin needs a filename.
The message format will not be exactly the same as from a command line
execution of perlcritic but the information displayed will be the same for the
different verbosity levels. The reason also lies in some peculiarities of the
quickfix error system used by Vim.
See the perlcritic documentation for details.
Verbosity 3 is the default. This can be changed by setting the variable
g:Perl_PerlcriticVerbosity in .vimrc to another value (1-11):
let g:Perl_PerlcriticVerbosity = 9
I addition there is an Ex command to do that, e.g.:
:CriticVerbosity 9
OPTIONS
-------
There is another Ex command to set further options, e.g.
:CriticOptions -top 10
These options are put behind the severity and verbosity option. The actual
values are shown in the plugin settings (|perlsupport-settings|). These
options can be reset with
:CriticOptions
Settings done with CriticOptions override the settings by
g:Perl_PerlcriticOptions (if any).
The default configuration file for perlcritic is '.perlcriticrc'. perlcritic
will look for this file in the current directory first, and then in your home
directory. See the manual for more information ('man perlcritic' or
'perlcritic -man') especially how to influence the policies.
For easier navigation in the error list see tip under
|perlsupport-syntax-check|.
1.9.12 SAVE BUFFER WITH TIMESTAMP *perlsupport-timestamp*
---------------------------------
Save the current buffer into a new file. The filename gets a trailing
timestamp. The format is YYYYMMDD-HHMMSS.
This feature can be used to comfortably save different profiling results
but it will work with any named buffer.
If you do a lot of profiling you want to add timestamps automatically. To
enable this feature put the following line into .vimrc :
let g:Perl_ProfilerTimestamp = "yes"
The default value is "no".
1.9.13 HARDCOPY *perlsupport-hardcopy*
---------------
Generates a PostScript file from the whole buffer or from a marked region.
On a MS-Windows system a printer dialog is displayed.
The hardcopy goes to the current working directory. If the buffer contains
Perl documentation or other material from non-writable directories the
hardcopy goes to the HOME directory. The otput destination will be shown in a
message.
The print header contains date and time for the current locale. The definition
used is
let s:Perl_Printheader = "%<%f%h%m%< %=%{strftime('%x %X')} Page %N"
The current locale can be overwritten by changing the language, e.g.
:language C
or by setting a global variable in the file .vimrc , e.g. :
let g:Perl_Printheader = "%<%f%h%m%< %=%{strftime('%x %X')} SEITE %N"
See :h printheader and :h strftime() for more details.
1.9.14 SETTINGS AND HOTKEYS *perlsupport-settings*
---------------------------
This menu item shows actual settings for the plugin. Some of them can change
during a session (e.g. current output destination or perlcritic verbosity).
1.9.15 XTERM SIZE *perlsupport-xterm*
-----------------
The size of the xterm used for debugging (|perlsupport-run-debug|) or for
running the script (below) can be set by this menu item. The default is 80
columns with 24 lines.
This feature is not available under MS-Windows.
1.9.16 CHANGE OUTPUT DESTINATION *perlsupport-output*
--------------------------------
Running a Perl script can be done in three ways:
(1) The script can be run from the command line as usual.
(2) The output can be directed into a window with name "Perl-Output".
The buffer and its content will disappear when the window is closed and
reused otherwise. If this window remains open it will be used for the next
runs. If the script doesn't produce shell output the output window will
not be opened (but you will see a message).
There is no file behind the window Perl-Output but the content can be
saved with a 'save as'.
(3) The script can be run in an xterm.
The output method can be chosen with the menu item 'Run->output: ...'.
This menu has three states:
output: VIM->buffer->xterm
output: BUFFER->xterm->vim
output: XTERM->vim->buffer
The first (uppercase) item shows the current method. The default is 'vim'.
This can be changed by setting the variable g:Perl_OutputGvim to another
value. Possible values are 'vim', 'buffer' and 'xterm' .
Vim (non-GUI) : The output destination can be toggled between (1) and (2)
using the hotkey \ro .
The xterm defaults can be set in .vimrc by the variable g:Perl_XtermDefaults .
The default is "-fa courier -fs 12 -geometry 80x24" :
font name : -fa courier
font size : -fs 12
terminal size : -geometry 80x24
See 'xterm -help' for more options. Xterms are not available under MS-Windows.
------------------------------------------------------------------------------
1.10 'help' *perlsupport-help*
------------------------------------------------------------------------------
The root menu item 'help' (hotkey \hp ) shows this plugin help in a help
window. The help tags must have been generated with
:helptags ~/.vim/doc
==============================================================================
2. USAGE WITHOUT GUI (Vim) *perlsupport-mappings*
==============================================================================
The frequently used constructs can be inserted with key mappings. These
mappings are also described in the document perl-hot-keys.pdf (reference
card).
The mappings can be suppressed with the following line in the file .vimrc :
let g:Perl_NoKeyMappings = 1
All mappings (except \lps and \ups) are filetype specific: they are only
defined for buffers with filetype 'perl' to minimize conflicts with mappings
from other plugins.
Legend: (i) insert mode, (n) normal mode, (v) visual mode
-- Load / Unload Perl Support ------------
\lps load perl support (n)
\ups unload perl support (n)
-- Comments ------------------------------
\cl line end comment (n,v,i)
\cj adjust line end comments (n,v )
\cs set end comment col. (n )
\cfr frame comment (n i)
\cfu function description (n i)
\cm method description (n i)
\chpl file header (*.pl) (n )
\chpm file header (*.pm) (n )
\cht file header (*.t) (n )
\chpo file header (*.t) (n )
\ckb keyword comment BUG (n i)
\ckt keyword comment TODO (n i)
\ckr keyword comment TRICKY (n i)
\ckw keyword comment WARNING (n i)
\cko keyword comment WORKAROUND (n i)
\ckn keyword comment new keyword (n i)
\cc toggle comment (n,v )
\cb code block to comment (n,v )
\cn uncomment code block (n,v )
\cd date (n i)
\ct date & time (n i)
\cv vim modeline (n i)
-- Statements ----------------------------
\sd do { } while (n,v,i)
\sf for { } (n,v,i)
\sfe foreach { } (n,v,i)
\si if { } (n,v,i)
\sie if { } else { } (n,v,i)
\se else { } (n,v,i)
\sei elsif { } (n,v,i)
\su unless { } (n,v,i)
\sue unless { } else { } (n,v,i)
\st until { } (n,v,i)
\sw while { } (n,v,i)
\s{ \sb { } (n,v,i)
-- Snippets ------------------------------
\nr read code snippet (n)
\nw write code snippet (n,v)
\ne edit code snippet (n)
\ntl edit local template file (n)
\ntg edit global template file (n)
\ntr reread template file (n)
-- Idioms --------------------------------
\$ my $; (*) (n i)
\$= my $ = ; (*) (n i)
\$$ my ( $, $ ); (*) (n i)
\@ my @; (*) (n i)
\@= my @ = (,,); (*) (n i)
\% my %; (*) (n i)
\%= my % = (=>,=>,); (*) (n i)
\ir my $regex_ = q//; (n i)
\im $ =~ m// (n i)
\is $ =~ s/// (n i)
\it $ =~ tr/// (n i)
\isu subroutine (n,v,i)
\ip print "...\n"; (n i)
\ii open input file (n,v,i)
\io open output file (n,v,i)
\ipi open pipe (n,v,i)
-- Regular Expressions -------------------
\xr pick up Regex (n,v)
\xs pick up string (n,v)
\xf pick up flags (n,v)
\xm match (n)
\xmm match multiple (n)
\xe explain Regex (n,v)
-- POSIX Character Classes ---------------
\pa [:alnum:] (n i)
\ph [:alpha:] (n i)
\pi [:ascii:] (n i)
\pb [:blank:] (n i)
\pc [:cntrl:] (n i)
\pd [:digit:] (n i)
\pg [:graph:] (n i)
\pl [:lower:] (n i)
\pp [:print:] (n i)
\pn [:punct:] (n i)
\ps [:space:] (n i)
\pu [:upper:] (n i)
\pw [:word:] (n i)
\px [:xdigit:] (n i)
-- Run -----------------------------------
\rr update file, run script (n) see |perlsupport-run-script|
\rs update file, check syntax (n) see |perlsupport-syntax-check|
\ra set command line argument (n) see |perlsupport-cmdline-args|
\rw set Perl command line switches (n) see |perlsupport-perl-switches|
\rd start debugger (n) see |perlsupport-run-debug|
\re make script executable (**) (n)
\rp read perldoc (n) see |perlsupport-perldoc|
\ri show installed Perl modules (n) see |perlsupport-module-list|
\rg generation Perl module list (n) see |perlsupport-module-list-generation|
\ry run perltidy (n,v) see |perlsupport-perltidy|
\rms run Devel::SmallProf (n) see |perlsupport-smallprof|
\rmf run Devel::FastProf (n) see |perlsupport-fastprof|
\rmn run Devel::NYTProf (n) see |perlsupport-nytprof|
\rc run perlcritic (n) see |perlsupport-perlcritic|
\rt save buffer with timestamp (n) see |perlsupport-timestamp|
\rh hardcopy buffer to FILENAME.ps (n,v) see |perlsupport-hardcopy|
\rk settings and hotkeys (n)
\rx set xterm size (**) (n) see |perlsupport-xterm|
\ro change output destination (n) see |perlsupport-output|
-- Help ----------------------------------
\hp help (plugin) (n,i) see |perlsupport-help|
(*) These key mappings start like Perl references. They are therefore not
available in insert mode for non-empty lines.
(**) Linux/UNIX only
File perl-hot-keys.pdf contains a reference card for these key mappings.
Multi-line inserts and code snippets will be indented after insertion.
The hot-keys are defined in the file type plugin perl.vim (part of this
perl-support plugin package).
The mappings can also be used with gVim.
Changing the default map leader '\'
-----------------------------------
The map leader can be changed by the user by setting a global variable in the
file .vimrc
let g:Perl_MapLeader = ','
The map leader is now a comma. The 'line end comment' command is now defined
as ',cl'. This setting will be used as a so called local leader and influences
only files with filetype 'perl'.
Resolving conflicts
-------------------
Sometimes the map leader '\' may conflict with Perl constructs e.g. when
typing an array reference: \@arrayname . There are three solutions.
(1) Typing speed matters. Type \ and wait some hundred milliseconds. The
following character will no longer be recognized as belonging to the backslash
as a map leader.
(2) Change the map leader for the filetype 'perl' as shown above.
(3) Change the map leader to another character, e.g. to the backtick with
:let mapleader="`"
You can make this change permanent by adding this line to the file .vimrc .
CAVEAT: This setting is global and influences all filetypes.
==============================================================================
3. FUNCTION KEYS *perlsupport-function-keys*
==============================================================================
The following function keys are defined in normal, visual and insert mode:
Shift-F1 read perldoc (for the word under the cursor)
F9 start a debugger
Alt-F9 run syntax check
Ctrl-F9 run script
Shift-F9 set command line arguments (buffer related)
These function keys are defined in the file type plugin ~/.vim/ftplugin/perl.vim .
Note for xterm users (Vim without GUI): The function key combinations
Shift-Fx, Alt-Fx and Ctrl-Fx do not work. F9 is also not working to prevent
unintentional use. Use mappings instead (|perlsupport-mappings|).
==============================================================================
4. CUSTOMIZATION *perlsupport-customization*
==============================================================================
------------------------------------------------------------------------------
4.1 FILES *perlsupport-custom-files*
------------------------------------------------------------------------------
README.perlsupport This file.
autoload/perlsupportgui.vim Menu definitions.
autoload/perlsupportregex.vim Regex analyser code.
doc/perlsupport.txt The help file for the local online help.
ftplugin/perl.vim A filetype plugin. Define hotkeys, create a local
dictionary for each Perl file.
plugin/perl-support.vim The Perl plugin for Vim/gVim.
perl-support/codesnippets-perl/* Some Perl code snippets as a starting point.
perl-support/modules/ Directory for the list of installed Perl modules
perl-support/scripts/efm_perl.pl Perl script; Reformats the error messages of the Perl interpreter
perl-support/scripts/pmdesc3.pl Perl script; generates a list of all installed Perl modules
perl-support/scripts/wrapper.sh The wrapper script for the use of an xterm.
perl-support/templates/Templates Perl main template file
perl-support/templates/comments.template template file for comments
perl-support/templates/idioms.template template file for idioms
perl-support/templates/pod.template template file for pod statements
perl-support/templates/statements.template template file for statements
perl-support/wordlists/perl.list A file used as dictionary for automatic word completion.
This file is referenced in the file customization.vimrc.
--------------- -------------------------------------------------------------
--------------- The following files and extensions are for convenience only.
perl-support.vim will work without them.
-------------------------------------------------------------
perl-support/rc/customization.ctags Additional settings I use in .ctags to enable
navigation through POD with the plugin taglist.vim.
perl-support/rc/customization.gvimrc Additional settings I use in .gvimrc:
hot keys, mouse settings, ...
The file is commented. Append it to your .gvimrc
if you like.
perl-support/rc/customization.perltidyrc Additional settings I use in .perltidyrc to
customize perltidy.
perl-support/rc/customization.smallprof Additional settings I use to control the profiler
Devel::SmallProf
perl-support/rc/customization.vimrc Additional settings I use in .vimrc: incremental search,
tabstop, hot keys, font, use of dictionaries, ...
The file is commented. Append it to your .vimrc if you like.
perl-support/doc/perl-hot-keys.pdf Reference card for the key mappings.
The mappings can also be used with the non-GUI Vim,
where the menus are not available.
perl-support/doc/pmdesc3.text The man page for pmdesc3.
perl-support/doc/ChangeLog The change log.
------------------------------------------------------------------------------
4.2 GLOBAL VARIABLES *perlsupport-custom-variables*
------------------------------------------------------------------------------
Several global variables are checked by the script to customize it:
------------------------------------------------------------------------------
global variable default value tag (see below)
------------------------------------------------------------------------------
g:Perl_GlobalTemplateFile root_dir.'perl-support/templates/Templates'
g:Perl_LocalTemplateFile $HOME.'/.vim/perl-support/templates/Templates'
g:Perl_TemplateOverwrittenMsg 'yes'
g:Perl_Ctrl_j 'on'
g:Perl_CodeSnippets root_dir.'perl-support/codesnippets/'
g:Perl_LoadMenus 'yes'
g:Perl_Dictionary_File ''
g:Perl_Root '&Perl.'
g:Perl_MenuHeader 'yes'
g:Perl_GuiSnippetBrowser 'gui'
g:Perl_GuiTemplateBrowser 'gui'
g:Perl_PerlModuleList root_dir.'perl-support/modules/perl-modules.list'
g:Perl_PerlModuleListGenerator root_dir.'perl-support/scripts/pmdesc3.pl'
g:Perl_OutputGvim "vim"
g:Perl_XtermDefaults "-fa courier -fs 12 -geometry 80x24"
g:Perl_Debugger "perl"
g:Perl_ProfilerTimestamp "no"
g:Perl_LineEndCommColDefault 49
g:Perl_PodcheckerWarnings "yes"
g:Perl_Printheader "%<%f%h%m%< %=%{strftime('%x %X')} Page %N"
g:Perl_PerlcriticSeverity 5
g:Perl_PerlcriticVerbosity 5
g:Perl_PerlcriticOptions ""
g:Perl_PerlRegexSubstitution '$+'
g:Perl_NYTProf_html 'no'
g:Perl_NoKeyMappings - undefined -
g:Perl_MapLeader '\'
The variable root_dir will automatically be set to one of the following values:
$HOME.'/.vim/' for Linux/Unix
$VIM.'/vimfiles/' for MS-Windows
------------------------------------------------------------------------------
1. group: Sets the template directory and the names of the template files (see below).
g:Perl_GlobalTemplateFile : sets the global template file (see|perlsupport-templates|)
g:Perl_LocalTemplateFile : sets the local template file (see|perlsupport-templates|)
g:Perl_TemplateOverwrittenMsg : message if a template is overwritten
g:Perl_Ctrl_j : hotkey Ctrl-j 'on'/'off' (see|perlsupport-Ctrl-j|)
2. group: g:Perl_CodeSnippets : The name of the code snippet directory (see below).
g:Perl_LoadMenus : Load menus and mappings ("yes", "no") at startup.
g:Perl_Dictionary_File : Path and filename of the Perl word list used for
dictionary completion (see below).
g:Perl_Root : The name of the root menu item of this plugin
(see below).
g:Perl_MenuHeader : Switch submenu titles on/off.
g:Perl_GuiSnippetBrowser : code snippet browser: 'gui', 'commandline'
g:Perl_GuiTemplateBrowser : code template browser: 'gui', 'explorer', 'commandline'
3. group: g:Perl_PerlModuleList : The name of the Perl module list (text file,
see below).
g:Perl_PerlModuleListGenerator : The command line which starts the
module list generation.
g:Perl_OutputGvim : when script is running output goes to the vim
command line ("vim"), to a buffer ("buffer")
or to an xterm ("xterm").
g:Perl_XtermDefaults : the xterm defaults
g:Perl_Debugger : the debugger called by F9 (perl, ptkdb, ddd).
g:Perl_ProfilerTimestamp : add time stamp to the profiler buffer name
g:Perl_LineEndCommColDefault : default starting column for line end comments
g:Perl_PodcheckerWarnings : podchecker warnings on/off
g:Perl_Printheader : hardcopy header format
g:Perl_PerlcriticSeverity : perlcritic severity
g:Perl_PerlcriticVerbosity : perlcritic verbosity
g:Perl_PerlcriticOptions : additional perlcritic options
g:Perl_NoKeyMappings : suppress command mappings (|perlsupport-mappings|)
g:Perl_MapLeader : map leader for hotkeys (|perlsupport-mappings|)
g:Perl_PerlRegexSubstitution : regex control character substitutions
g:Perl_NYTProf_html : Devel::NYTProf generates HTML-files (|perlsupport-nytprof|)
------------------------------------------------------------------------------
4.3 THE ROOT MENU *perlsupport-custom-root*
------------------------------------------------------------------------------
The variable g:Perl_Root, if set in .vimrc or in .gvimrc, gives the name of
the single gVim root menu item in which the Perl submenus are contained. The
default is
'&Perl.'
Please note the terminating dot. A single root menu item is appropriate if the
screen is limited or several plugins are in use.
If set to '' (empty string) with
let g:Perl_Root = ''
this single root menu item will not appear. Now all submenus are put into the
gVim root menu. Nice for a Perl-only-programmer and Perl courses with wide
screens.
If you want to set the plugin root menu as a submenu into another menu, e.g.
your own with the name 'Plugin', this is done by the following line in
'.vimrc'
let g:Perl_Root = '&Plugin.&Perl.'
The appearance of the root menu item can also be controlled by the global
variable g:Perl_LoadMenus. The line
let g:Perl_LoadMenus = 'no'
prevents the root menu item from appearing when the editor starts. You can
switch it on (and off again) from the tools menu. The default for this
variable is 'yes'.
------------------------------------------------------------------------------
4.4 NAVIGATE THROUGH PODs *perlsupport-custom-navigate*
------------------------------------------------------------------------------
The plugin taglist.vim (Author: Yegappan Lakshmanan) is a source code browser
plugin for Vim and provides an overview of the structure of source code files
and allows you to efficiently browse through source code files for different
programming languages. It is based on ctags (Exuberant Ctags, Darren Hiebert,
http://ctags.sourceforge.net).
The file rc/customization.ctags is an extension for the configuration file of
ctags. If appended to $HOME/.ctags (the initialization file for ctags)
taglist can show the structure of the included POD as an table of content.
The taglist navigation window for the module Eliza.pm starts like this:
Eliza.pm (/home/mehner)
subroutines
Version
new
_initialize
AUTOLOAD
command_interface
preprocess
postprocess
_testquit
_debug_memory
transform
parse_script_data
POD
NAME
SYNOPSIS
DESCRIPTION
INSTALLATION
USAGE
MAIN DATA MEMBERS
. %decomplist
. %reasmblist
. %reasmblist_for_memory
. . .
Now you can navigate through the embedded POD with a mouse click on these
entries. To enable this feature
(1) append rc/customization.ctags to $HOME/.ctags (or create this file)
(2) add the following lines to $HOME/.vimrc :
"
"-----------------------------------------------------------------------------
" taglist.vim : toggle the taglist window
" taglist.vim : define the title texts for Perl
"-----------------------------------------------------------------------------
noremap <silent> <F11> :Tlist<CR>
inoremap <silent> <F11> <C-C>:Tlist<CR>
let tlist_perl_settings = 'perl;c:constants;l:labels;p:package;s:subroutines;d:POD'
(3) restart vim/gvim
The two maps will toggle the taglist window (hotkey F11) in all editing modes.
The assignment defines the headings for the Perl sections in the taglist
window.
IMPORTANT : The POD contents will not be displayed if the POD comes after an
__END__ token. Ctags (current version 5.6) does not parse beyond this token.
You may therefore want not to use __END__ in your own modules.
------------------------------------------------------------------------------
4.5 Tabulator width *perlsupport-custom-tab*
------------------------------------------------------------------------------
The Perl Style Guide recommends a tabulator setting of 4. You can force this
setting for all files with file type 'perl' by uncommenting the two lines
"setlocal tabstop=4
"setlocal shiftwidth=4
in the file type plugin '~/.vim/ftplugin/perl.vim' .
------------------------------------------------------------------------------
4.6 System-wide installation (Unix/Linux only) *perlsupport-system-wide*
------------------------------------------------------------------------------
A system-wide installation (one installation for all users) is done as
follows.
As *** SUPERUSER *** :
(1) Find the Vim installation directory.
The Vim ex command ':echo $VIM' gives '/usr/local/share/vim' or something like
that. Beyond this directory you will find the Vim installation, e.g. in
'/usr/local/share/vim/vim71' if Vim version 7.1 has been installed.
(2) Create a new subdirectory 'vimfiles', e.g. '/usr/local/share/vim/vimfiles'.
(3) Install Perl Support
Copy the archive perl-support.zip to this new directory and unpack it:
unzip perl-support.zip
(4) Generate the help tags:
:helptags $VIM/vimfiles/doc
As *** USER *** :
Create your private snippet directory:
mkdir --parents ~/.vim/perl-support/codesnippets
You may want to copy the snippets comming with this plugin (in
$VIM/vimfiles/perl-support/codesnippets) into the new directory or to set a
link to the global directory.
==============================================================================
5. TEMPLATE FILES AND TAGS *perlsupport-templates*
==============================================================================
------------------------------------------------------------------------------
5.1 TEMPLATE FILES *perlsupport-templates-files*
------------------------------------------------------------------------------
Nearly all menu entries insert code snippets or comments. All these stuff is
taken from template files and can be changed by the user to meet his
requirements.
The master template file is '$HOME/.vim/perl-support/templates/Templates' for
a user installation and '$VIM/vimfiles/perl-support/templates/Templates' for
a system-wide installation (see|perlsupport-system-wide|).
The master template file starts with a macro section followed by templates for
single menu items or better by including other template files grouping the
templates according to the menu structure of this plugin. The master file
could look like this:
§
§ =============================================================
§ ========== USER MACROS ======================================
§ =============================================================
§
*|AUTHOR|* = Dr. Fritz Mehner
*|AUTHORREF|* = mn
*|EMAIL|* = mehner@fh-swf.de
*|COMPANY|* = FH Südwestfalen, Iserlohn
*|COPYRIGHT|* = Copyright (c)*|YEAR|,|AUTHOR|*
§
§ =============================================================
§ ========== FILE INCLUDES ====================================
§ =============================================================
§
§ -- none --
§
§
§%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
== comment.end-of-line-comment == append ==
# <CURSOR>
§%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
... lot of other templates ...
Lines starting with a paragraph sign are comments. The section starting
with *|AUTHOR|* assigns values to predefined tags
(see|perlsupport-templates-macros|) to personalize some templates. Other
predefined tags with given default values can be used (e.g. *|YEAR|* ).
User defined tags are possible. They have the following syntax:
*|macroname|* = replacement
A macroname starts with a letter (uppercase or lowercase) followed by zero or
more letters, digits or underscores.
------------------------------------------------------------------------------
5.2 MACROS *perlsupport-templates-macros*
------------------------------------------------------------------------------
The following macro names are predefined. The first group is used to
personalize templates.
----------------------------------------------------------------------------
PREDEFINED MACROS DEFAULT VALUE
----------------------------------------------------------------------------
*|AUTHOR|* ""
*|AUTHORREF|* ""
*|EMAIL|* ""
*|COMPANY|* ""
*|PROJECT|* ""
*|COPYRIGHTHOLDER|* ""
*|STYLE|* ""
*|includefile|* ""
*|BASENAME|* filename without path and suffix
*|DATE|* the preferred date representation for the current locale
without the time
*|FILENAME|* filename without path
*|PATH|* path without filename
*|SUFFIX|* filename suffix
*|TIME|* the preferred time representation for the current locale
without the date and the time zone or name or abbreviation
*|YEAR|* the year as a decimal number including the century
*|includefile|* can be used to include an additional template file. A file
will be included only once. Commenting and uncommenting include macros is a
simple way to switch between several sets of templates. Overwriting existing
macros and templates is possible.
----------------------------------------------------------------------------
PREDEFINED TAGS
----------------------------------------------------------------------------
<CURSOR> The cursor position after insertion of a template
<+text+>,<-text->, Jump targets in templates. Jump with Ctrl-j.
{+text+},{-text-} See |perlsupport-templates-jump|.
<SPLIT> The split point when inserting in visual mode
(see|perlsupport-templates-definition|)
A dependent template file can start with its own macro section. There is no
need to have all user defined macros in the master file.
When the first template definition is found (see below) macro definitions are
no longer recognized.
------------------------------------------------------------------------------
5.2.1 USER DEFINED FORMATS FOR DATE AND TIME *perlsupport-templates-date*
------------------------------------------------------------------------------
The format for *|DATE|* ,*|TIME|* , and*|YEAR|* can be set by the user. The
defaults are
*|DATE|* '%x'
*|TIME|* '%X'
*|YEAR|* '%Y'
See the manual page of the C function strftime() for the format. The accepted
format depends on your system, thus this is not portable! The maximum length
of the result is 80 characters.
User defined formats can be set using the following global variables in
~/.vimrc , e.g.
let g:Perl_FormatDate = '%D'
let g:Perl_FormatTime = '%H:%M'
let g:Perl_FormatYear = 'year %Y'
------------------------------------------------------------------------------
5.3 TEMPLATES *perlsupport-templates-names*
------------------------------------------------------------------------------
5.3.1 Template names
The template behind a menu entry is identified by a given name. The first part
of the name identifies the menu, the second part identifies the item. The
modes are also hard coded (see|perlsupport-templates-definition|for the use of
<SPLIT>).
TEMPLATE NAME MODES
--------------------------------------------------------------------------
comment.end-of-line-comment normal
comment.frame normal
comment.function normal
comment.method normal
comment.file-description-pl normal
comment.file-description-pm normal
comment.file-description-t normal
comment.file-description-pod normal
comment.keyword-bug normal
comment.keyword-todo normal
comment.keyword-tricky normal
comment.keyword-warning normal
comment.keyword-workaround normal
comment.keyword-keyword normal
statements.do-while normal, visual
statements.for normal, visual
statements.foreach normal, visual
statements.if normal, visual
statements.elsif normal, visual
statements.else normal, visual
statements.if-else normal, visual
statements.unless normal, visual
statements.unless-else normal, visual
statements.until normal, visual
statements.while normal, visual
statements.block normal, visual
idioms.scalar normal
idioms.scalar-assign normal
idioms.scalar2 normal
idioms.array normal
idioms.array-assign normal
idioms.hash normal
idioms.hash-assign normal
idioms.regex normal
idioms.match normal
idioms.substitute normal
idioms.translate normal
idioms.subroutine norma, visuall
idioms.print normal
idioms.open-input-file normal, visual
idioms.open-output-file normal, visual
idioms.open-pipe normal, visual
pod.pod-cut normal, visual
pod.cut normal
pod.for-cut normal, visual
pod.html normal, visual
pod.man normal, visual
pod.text normal, visual
pod.head1 normal
pod.head2 normal
pod.head3 normal
pod.over-back normal, visual
pod.item normal
pod.invisible-pod-improvement normal
pod.invisible-pod-optimization normal
pod.invisible-pod-rationale normal
pod.invisible-pod-workaround normal
5.3.2 Template definition *perlsupport-templates-definition*
A template definition starts with a template head line with the following
syntax:
== templatename == [ position == ]
The templatename is one of the above template identifiers. The position
attribute is optional. Possible attribute values are:
above insert the template before the current line
append append the template to the current line
below insert the template below the current line (default)
insert insert the template at the cursor position
start insert the template before the first line of the buffer
An example:
== comment.frame ==
#---------------------------------------------------------------------------
# <CURSOR>
#---------------------------------------------------------------------------
The definition of a template ends at the next head line or at the end of the
file.
Templates for the visual mode can use <SPLIT>. The text before <SPLIT> will
than be inserted above the marked area, the text after <SPLIT> will be
inserted behind the marked area. An example:
== statements.if-else ==
if ( <CURSOR> ) {
<SPLIT>} else {
}
If applied to the marked block
xxxxxxxxxxx
xxxxxxxxxxx
this template yields
if ( ) {
xxxxxxxxxxx
xxxxxxxxxxx
} else {
}
The templates with a visual mode are shown in the table under
|perlsupport-templates-names|.
5.3.3 Template expansion *perlsupport-templates-expansion*
There are additional ways to control the expansion of a template.
USER INPUT
----------
If the usage of a yet undefined user macro starts with a question mark the
user will be asked for the replacement first, e.g. with the following template
== idioms.subroutine ==
sub*|?FUNCTION_NAME|* {
my ( $par1<CURSOR> ) = @_;
<SPLIT> return ;
} # ---------- end of subroutine*|FUNCTION_NAME|* ----------
The user can specify the function name which then will be applied twice. If
the macro was already in use the old value will be suggested as default.
MACRO MANIPULATION
------------------
A macro expansion can be controlled by the following attributes
:l change macro text to lowercase
:u change macro text to uppercase
:c capitalize macro text
:L legalize name
Legalization means:
- replace all whitespaces by underscores
- replace all non-word characters by underscores
- replace '+' and '-' by underscore
The keyword comment template is an example for the use of ':u' :
== comment.keyword-keyword == append ==
# :*|?KEYWORD:u|* :*|DATE|* *|TIME|* :*|AUTHORREF|* : <CURSOR>
The user specified keyword will be used in uppercase.
5.3.4 The macros <+text+> etc. *perlsupport-templates-jump*
There are four macro types which can be used as jump targets in templates:
<+text+> Can be jumped to by hitting Ctrl-j.
{+text+} Same as <+text+>. Used in cases where indentation gives unwanted
results with the first one.
<-text-> Same as the two above. Will be removed if the template is used
{-text-} in visual mode.
The text inside the brackets is userdefined and can be empty. The text
can be composed from letters (uppercase and lowercase), digits, underscores
and blanks. After the insertion of an template these jump targets will be
highlighted.
5.3.5 Command Ctrl-j *perlsupport-Ctrl-j*
Use the command Ctrl-j to jump to the next target. The target will be removed
and the mode will switched to insertion. Ctrl-j works in normal and in insert
mode.
The template for an if-else-statement can be written as follows:
== statements.if-else ==
if ( <CURSOR> ) {
<SPLIT>} else {
<+ELSE PART+>
}
The cursor will be set between the parenthesis. When the condition is
specified jump to the end of the line and hit Return to open a new line inside
the if-block. When the block is written a Ctrl-j leads you to the else-part.
The target <+ELSE PART+> disappears and you can type on.
The following example shows the usage of the type {-text-}. The idiom for the
opening of a file marks the line before the file is closed. This is also the
line where the template will be split to surround a marked area. In this case
(visual mode) the target is not needed and therefore removed (minus signs as
mnemonic). In normal and insert mode the target is meaningful and will be
therefore be present. The form <-...-> would result in a wrong indentation of
the file close statement. The brace type will be handled as a block and the
indentation will be correct.
== idioms.open-input-file ==
my $|?FILEPOINTER|_file_name = '<CURSOR>'; # input file name
open my $|FILEPOINTER|, '<', $|FILEPOINTER|_file_name
or die "$0 : failed to open input file '$|FILEPOINTER|_file_name' : $!\n";
<SPLIT>{-continue here-}
close $|FILEPOINTER|
or warn "$0 : failed to close input file '$|FILEPOINTER|_file_name' : $!\n";
How to switch the mapping for Ctrl-j off
----------------------------------------
The original meaning of Ctrl-j is 'move [n] lines downward' (see |CTRL-j|).
If you are accustomed to use the deafult and don't like these jump targets you
can switch them off. Put the following line in the file .vimrc :
let g:Perl_Ctrl_j = 'off'
The default value of g:Perl_Ctrl_j is 'on'. You do not have to change the
template files. All jump targets will be removed before a template will be
inserted.
==============================================================================
5.4 SWITCHING BETWEEN TEMPLATE SETS *perlsupport-templates-sets*
==============================================================================
This plugin comes with two sets of templates. These are suggestions. You may
want to have additional sets for different projects or occasionally want to
use doxygen style comments. To facilitate switching use the macro*|STYLE|*
(|perlsupport-templates-files|) to define a unique name and the
IF-ENDIF-construct to choose a particular set of files for example:
...
*|STYLE|* = my_style
$
$ =============================================================
$ ========== FILE INCLUDES ====================================
$ =============================================================
$
== IF *|STYLE|* IS generic ==
$
*|includefile|* = comments.template
== ENDIF ==
$
== IF *|STYLE|* IS my_style ==
*|includefile|* = my_comments.template
== ENDIF ==
$
*|includefile|* = statements.template
*|includefile|* = idioms.template
*|includefile|* = pod.template
$
...
The syntax is as follows:
== IF macro_name IS macro_value ==
== ENDIF ==
IF, IS, and ENDIF are keywords.
HINT. Use these constructs to avoid overwriting your templates when updating
perlsupport. Copy and rename the set of files you want to change and surround the
includes with an appropriate IF-construct:
*|STYLE|* = MY_PERL
$
...
$
== IF *|STYLE|* IS MY_PERL ==
*|includefile|* = my_comments.template
*|includefile|* = my_statements.template
*|includefile|* = my_idioms.template
*|includefile|* = my_pod.template
== ENDIF ==
Keep a copy of the main template file 'Templates' because this file will be
overwritten if you do not update manually.
==============================================================================
6. Perl::Tags *perlsupport-perltags*
==============================================================================
The use of the module Perl::Tags (version 0.23; see CPAN) is encouraged. In
order to use this feature you need a Vim binary with Perl interface compiled
in (see |perlsupport-compile-vim|) and Perl::Tags must be installed, of
course.
Usage. If the cursor is on the module name in a perl 'use' ore 'require'
statement like
use Graphics::GnuplotIF qw(GnuplotIF);
a CTRL-] let you jump into the file GnuplotIF.pm. An easy way back is with
the CTRL-T command. See also the module documentation on how to use
Perl::Tags.
==============================================================================
7. PERL DICTIONARY *perlsupport-dictionary*
==============================================================================
The file perl.list contains words used as dictionary for automatic word
completion. This feature is enabled by default. The default word list is
$HOME/.vim/perl-support/wordlists/perl.list
If you want to use an additional list MyPerl.List put the following line into
.vimrc :
let g:Perl_Dictionary_File = "$HOME/.vim/perl-support/wordlists/perl.list,".
\ "$HOME/any_of_my_directories/MyPerl.List"
The right side is a comma separated list of files. Note the point at the end
of the first line (string concatenation) and the backslash in front of the
second line (continuation line).
You can use Vim's dictionary feature CTRL-X, CTRL-K (and CTRL-P, CTRL-N).
==============================================================================
8. OPTIONAL DEPENDENCIES *perlsupport-dependencies*
==============================================================================
There are several optional dependencies.
------------------------------------------------------------------------------
8.1 Standard Perl modules
------------------------------------------------------------------------------
These modules should come with your Perl distribution:
perldoc - Look up Perl documentation in Pod format
pod2html - convert .pod files to .html files
pod2man - Convert POD data to formatted *roff input
pod2text - Convert POD data to formatted ASCII text
podchecker - check the syntax of POD format documentation files
------------------------------------------------------------------------------
8.2 Non-standard Perl modules
------------------------------------------------------------------------------
The following modules have to be installed by the user/administrator in order
to use them.
Devel::SmallProf - per-line Perl profiler
Devel::FastProf - per-line Perl profiler
Devel::NYTProf - per-line Perl profiler
Devel::ptkdb - Perl debugger using a Tk GUI
Perl::Critic - Critique Perl source code for best-practices
Perl::Tags - Generate Ctags style tags for Perl source code
(see |perlsupport-perltags|)
Perl::Tidy - Parses and beautifies perl source
YAPE::Regex::Explain - regular expression analyzer
This is done in one of two way:
(1) Download the tarball from CPAN (http://www.cpan.org/) or one of its
mirrors, go to the new directory, read the files README and INSTALL, and
follow the instructions. You have to resolve the dependencies yourself
by first installing them.
(2) Install the cpan shell (module CPAN) and install modules via network.
The dependencies are resolved automatically. Recommended.
------------------------------------------------------------------------------
8.3 Other applications
------------------------------------------------------------------------------
ddd - The Data Display Debugger (graphical front-end for GDB)
The homepage of this project is http://www.gnu.org/software/ddd/.
==============================================================================
9. Compiling Vim *perlsupport-compile-vim*
==============================================================================
You may want to compile Vim yourself because the 'perl' feature is missing.
First, there are two ways to check this:
(1) Type 'version' on the Vim command line and look for 'perl' in the section
"Features includes ... ".
(2) Type 'echo has("perl")' on the Vim command line. If you get a '0' the
feature is not present.
A ':help :version' will show all possible features to choose from.
You could first look around for a binary distribution with this feature which
was compiled for your platform. Install it and all is done.
COMPILE YOUR OWN VERSION (LINUX/UNIX).
--------------------------------------
(1) Download the sources from http://vim.sourceforge.net/ and extract the
sources from the archive (for patches see|perlsupport-compile-vim-patches|).
(2) Inspect the current version again. The section 'Compilation' shows how
this version was built. You can see the libraries used. In order to have your
new version looking like the one you are just using you may have to install
some additional libraries first (the development versions).
(3) Change to the directory containing the source code and type
./configure --enable-perlinterp --enable-gui=gtk2
for Perl and your favorite GUI.
(4) Make the binary the traditional way:
make
make test
make install (you must be root)
You may want to install patches before the first make.
A './configure --help' prior to these steps will show a lot of options (e.g.
for a local or user installation).
(5) Check if you have to add the target directory for the new installation to
PATH.
(6) Check if the new version starts up when you are in your normal working
environment. You may have to remove the old version to avoid conflicts.
The file 'src/INSTALL' contains more details if needed.
PATCHES *perlsupport-compile-vim-patches*
-------
Before compiling your own version you may want to include the patches from
ftp.vim.org/pub/vim/patches/. The patch directory contains a file 'README'
which shows how to do that.
==============================================================================
10. FOLDING *perlsupport-folding*
==============================================================================
This plugin can be used together with folding.
There are a few peculiarities when the cursor is on a closed fold before
inserting a template:
Normal mode
-----------
Inserting blocks of complete lines below and above a fold (e.g. frame
comments) and inserting at the top of a buffer (e.g. file description) works
as usual.
Insertions which go to the end of a line (e.g. end-of-line comments) and
insertions which go to the cursor position (e.g. 'date') will be suppressed
and a warning will be shown.
Visual mode
-----------
A range of lines containing closed folds can be surrounded by constructs which
have a visual mode, e.g. an if-statement:
if ( $check==0 ) {
+--- 5 lines: open my $ss, '<', $ss_file_name----------------------------
}
See |folding| for more information on folding.
==============================================================================
11. Additional Mappings *perlsupport-ad-mappings*
==============================================================================
There are a few additional filetype specific key mappings defined in
'~/.vim/ftplugin/perl.vim'.
Open a block (modes: i,v):
'{<CR>' => {
|
}
In visual mode the content of the new block will be indented.
==============================================================================
12. AUTOLOADING *perlsupport-autoload*
==============================================================================
The this perlsupport plugin uses the Vim autoload mechanism to load parts of
the plugin at the latest possible time.
The main part '~/.vim/plugin/perl-support.vim' will always be loaded at
startup in console mode (Vim) and graphical mode (gVim).
The filetype plugin '~/.vim/ftplugin/perl.vim' (hotkey) will be loaded when a
file of type 'perl' has been opened.
The file '~/.vim/autoload/perlsupportregex.vim' will be loaded when the
regular expression analyzer has been called (hotkey or menu item).
The file '~/.vim/autoload/perlsupportgui.vim' will only be loaded for gVim.
If the global variable g:Perl_LoadMenus is set to 'no' (in the file ~/.vimrc)
the menu definition are loaded at the first time the tool menu item 'Load Perl
Support' or the hotkey \lps is used.
==============================================================================
13. MS-Windows PARTICULARITIES *perlsupport-windows*
==============================================================================
The plugins should go into the directory structure below the local
installation directory $HOME/.vim/ for LINUX/UNIX and $VIM/vimfiles/ for
MS-Windows.
The values of the two variables can be found from inside Vim:
:echo $VIM
or
:echo $HOME
Configuration files:
LINUX/UNIX : $HOME/.vimrc and $HOME/.gvimrc
MS-Windows : $VIM/_vimrc and $VIM/_gvimrc
==============================================================================
14. TROUBLESHOOTING *perlsupport-troubleshooting*
==============================================================================
* I do not see any new main menu item.
- Was the archive extracted into the right directory (see |perlsupport-windows|)?
* How can I see what was loaded?
- Use ':scriptnames' from the Vim command line.
* No main menu item.
- Loading of plugin files must be enabled. If not use
:filetype plugin on
This is the minimal content of the file '$HOME/.vimrc'. Create one if there
is none, or better use customization.vimrc (see |perlsupport-custom-files|).
* Most key mappings do not work.
- They are defined in a filetype plugin in '$HOME/.vim/ftplugin/'. Use
':filetype' to check if filetype plugins are enabled. If not, add the line
filetype plugin on
to the file '.vimrc'.
* Perl script not executable from inside the editor.
- Script executable from the command line ?
- Perl installation correct ?
- PATH variable correct ?
- Script set executable (file access permission under LINUX/UNIX) ?
- Script syntax correct ?
- Necessary modules installed ?
* Some hotkeys (e.g. x-F9) do not work.
- The hotkeys might be in use by your graphical desktop environment.
Under KDE Ctrl-F9 is the hotkey which let you switch to the 9. desktop.
The key settings can usually be redefined or switched off.
Under KDE, 'Keyboard Shortcuts' may be configured by following:
K Menu -> Control Center -> Regional & Accessibility -> Keyboard Shortcuts.
* perltidy not running / messing up my file
Unix/Linux: you have had a proper installation of perltidy, but now it does
not work or messes up your file.
The start script '/usr/bin/perltidy' needs the module 'Perl::Tidy.pm'. Most
likely you have updated Perl and the module can not longer be found. The
easiest remedy is to reinstall perltidy. Check the installation with the
command "perltidy -v" from the command line.
==============================================================================
15. RELEASE NOTES / CHANGELOG *perlsupport-release-notes*
==============================================================================
See files 'README.perlsupport' and 'ChangeLog'.
==============================================================================
16. CREDITS *perlsupport-credits*
==============================================================================
David Fishburn <fishburn@ianywhere.com> for the implementation of the
single root menu and several suggestions for improving the customization
and the documentation.
Ryan Hennig <hennig@amazon.com> improved the install script.
Aristotle, http://qs321.pair.com/~monkads/ is the author of the script pmdesc2
which is the base of the script pmdesc3.pl.
David Fishburn contributed changes for the Windows platform and suggested to
not let enter snippets and templates the list of alternate files.
The code snippet files pod-template-application.pl and pod-template-module.pl
are taken from Damian Conway's book "Perl Best Practices".
==============================================================================
vim:tw=78:noet:ts=2:ft=help:norl:
Jump to Line
Something went wrong with that request. Please try again.