home *** CD-ROM | disk | FTP | other *** search
/ vim.ftp.fu-berlin.de / 2015-02-03.vim.ftp.fu-berlin.de.tar / vim.ftp.fu-berlin.de / mac / vim55rt.sit / runtime / doc / if_perl.txt < prev    next >
Encoding:
Text File  |  1999-09-25  |  7.1 KB  |  197 lines  |  [TEXT/MPS ]

  1. *if_perl.txt*   For Vim version 5.5.  Last change: 1999 Sep 17
  2.  
  3.  
  4.           VIM REFERENCE MANUAL    by Sven Verdoolaege
  5.                      and Matt Gerassimof
  6.  
  7. Perl and Vim                *perl* *Perl*
  8.  
  9. 1. Editing Perl files            |perl-editing|
  10. 2. Compiling VIM with Perl interface    |perl-compiling|
  11. 3. Using the Perl interface        |perl-using|
  12.  
  13. {Vi does not have any of these commands}
  14.  
  15. The Perl interface only works when Vim was compiled with the |+perl| feature.
  16.  
  17. ==============================================================================
  18. 1. Editing Perl files                    *perl-editing*
  19.  
  20. Vim syntax highlighting supports Perl and POD files.  Vim assumes a file is
  21. Perl code if the filename has a .pl or .pm suffix. Vim also examines the first
  22. line of a file, regardless of the filename suffix, to check if a file is a
  23. Perl script (see scripts.vim in Vim's syntax directory).  Vim assumes a file
  24. is POD text if the filename has a .POD suffix.
  25.  
  26. To use tags with Perl, you need a script that generates the tags file from a
  27. Perl script.  Here are URLs for two scripts that do this:
  28. http://fohnix.metronet.com/perlinfo/scripts/text-processing/newptags.pl
  29. http://www.geek-girl.com/perl/coombs-scripts/ptags
  30.  
  31. ==============================================================================
  32. 2. Compiling VIM with Perl interface            *perl-compiling*
  33.  
  34. To compile Vim with Perl interface, you need Perl 5.004 (or later).  Perl must
  35. be installed before you compile Vim.  Vim's Perl interface does NOT work with
  36. the 5.003 version that has been officially released!  It will probably work
  37. with Perl 5.003_05 and later.
  38.  
  39. The Perl patches for Vim were made by:
  40.     Sven Verdoolaege <skimo@breughel.ufsia.ac.be>
  41.     Matt Gerassimof
  42.  
  43. Perl for MS-Windows can be found at:
  44. http://www.perl.com/CPAN-local/ports/nt/Standard/x86/
  45.  
  46. ==============================================================================
  47. 3. Using the Perl interface                *perl-using*
  48.  
  49.                             *:perl* *:pe*
  50. :pe[rl] {cmd}        Execute Perl command {cmd}. The current package
  51.             is "main". {not in Vi}
  52.  
  53.                             *:perldo* *:perld*
  54. :[range]perld[o] {cmd}    Execute Perl command {cmd} for each line in the
  55.             [range], with $_ being set to the text of each line in
  56.             turn, without a trailing <EOL>. Setting $_ will change
  57.             the text, but note that it is not possible to add or
  58.             delete lines using this command.
  59.             The default for [range] is the whole file: "1,$".
  60.             {not in Vi}
  61.  
  62. Here are some things you can try:
  63.  
  64. >  :perl $a=1
  65. >  :perldo $_=reverse($_);1
  66. >  :perl VIM::Msg("hello")
  67. >  :perl $line = $curbuf->Get(42)
  68.  
  69.  
  70.                             *perl-overview*
  71. Here is an overview of the functions that are available to Perl:
  72.  
  73. >  :perl VIM::Msg("Text")        # displays a message
  74. >  :perl VIM::Msg("Error", "ErrorMsg")    # displays an error message
  75. >  :perl VIM::Msg("remark", "Comment")    # displays a highlighted message
  76. >  :perl VIM::SetOption("ai")        # sets a vim option
  77. >  :perl ($v, $success) = VIM::Eval('&path') # $v=option 'path', $success=1
  78. >  :perl ($v, $success) = VIM::Eval('&xyz')  # $v='' and $success=0 (no option)
  79. >  :perl $v = VIM::Eval('expand("<cfile>")')   # expand <cfile>
  80. >  :perl $curwin->SetHeight(10)        # sets the window height
  81. >  :perl @pos = $curwin->Cursor()    # returns (row, col) array
  82. >  :perl @pos = (10, 10)
  83. >  :perl $curwin->Cursor(@pos)        # sets cursor to @pos
  84. >  :perl $curwin->Cursor(10,10)        # sets cursor to row 10 col 10
  85. >  :perl $curbuf->Name()        # returns buffer name
  86. >  :perl $curbuf->Count()        # returns the number of lines
  87. >  :perl $l = $curbuf->Get(10)        # returns line 10
  88. >  :perl @l = $curbuf->Get(1 .. 5)    # returns lines 1 through 5
  89. >  :perl $curbuf->Delete(10)        # deletes line 10
  90. >  :perl $curbuf->Delete(10, 20)    # delete lines 10 through 20
  91. >  :perl $curbuf->Append(10, "Line")    # appends a line
  92. >  :perl $curbuf->Append(10, "Line1", "Line2", "Line3") # appends 3 lines
  93. >  :perl @l = ("L1", "L2", "L3")
  94. >  :perl $curbuf->Append(10, @l)    # appends L1, L2 and L3
  95. >  :perl $curbuf->Set(10, "Line")    # replaces line 10
  96. >  :perl $curbuf->Set(10, "Line1", "Line2")    # replaces lines 10 and 11
  97. >  :perl $curbuf->Set(10, @l)        # replaces 3 lines
  98.  
  99.                             *perl-Msg*
  100. VIM::Msg({msg}, {group}?)
  101.             Displays the message {msg}.  The optional {group}
  102.             argument specifies a highlight group for Vim to use
  103.             for the message.
  104.  
  105.                             *perl-SetOption*
  106. VIM::SetOption({arg})    Sets a vim option.  {arg} can be any argument that the
  107.             ":set" command accepts.  Note that this means that no
  108.             spaces are allowed in the argument!  See |:set|.
  109.  
  110.                             *perl-Buffers*
  111. VIM::Buffers([{bn}...])    With no arguments, returns a list of all the buffers
  112.             in an array context or returns the number of buffers
  113.             in a scalar context.  For a list of buffer names or
  114.             numbers {bn}, returns a list of the buffers matching
  115.             {bn}, using the same rules as Vim's internal
  116.             |bufname()| function.
  117.  
  118.                             *perl-Windows*
  119. VIM::Windows([{wn}...])    With no arguments, returns a list of all the windows
  120.             in an array context or returns the number of windows
  121.             in a scalar context.  For a list of window numbers
  122.             {wn}, returns a list of the windows with those
  123.             numbers.
  124.  
  125.                             *perl-DoCommand*
  126. VIM::DoCommand({cmd})    Executes Ex command {cmd}.
  127.  
  128.                             *perl-Eval*
  129. VIM::Eval({expr})    Evaluates {expr} and returns (success, val).
  130.             success=1 indicates that val contains the value of
  131.             {expr}; success=0 indicates a failure to evaluate
  132.             the expression.  '@x' returns the contents of register
  133.             x, '&x' returns the value of option x, 'x' returns the
  134.             value of internal |variables| x, and '$x' is equivalent
  135.             to perl's $ENV{x}.  All |functions| accessible from
  136.             the command-line are valid for {expr}.
  137.  
  138.                             *perl-SetHeight*
  139. Window->SetHeight({height})
  140.             Sets the Window height to {height}, within screen
  141.             limits.
  142.  
  143.                             *perl-GetCursor*
  144. Window->Cursor({row}?, {col}?)
  145.             With no arguments, returns a (row, col) array for the
  146.             current cursor position in the Window.  With {row} and
  147.             {col} arguments, sets the Window's cursor position to
  148.             {row} and {col}.  Note that {col} is numbered from 0,
  149.             Perl-fashion, and thus is one less than the value in
  150.             Vim's ruler.
  151.  
  152. Window->Buffer()                    *perl-Buffer*
  153.             Returns the Buffer object corresponding to the given
  154.             Window.
  155.  
  156.                             *perl-Name*
  157. Buffer->Name()        Returns the filename for the Buffer.
  158.  
  159.                             *perl-Number*
  160. Buffer->Number()    Returns the number of the Buffer.
  161.  
  162.                             *perl-Count*
  163. Buffer->Count()        Returns the number of lines in the Buffer.
  164.  
  165.                             *perl-Get*
  166. Buffer->Get({lnum}, {lnum}?, ...)
  167.             Returns a text string of line {lnum} in the Buffer
  168.             for each {lnum} specified. An array can be passed
  169.             with a list of {lnum}'s specified.
  170.  
  171.                             *perl-Delete*
  172. Buffer->Delete({lnum}, {lnum}?)
  173.             Deletes line {lnum} in the Buffer.  With the second
  174.             {lnum}, deletes the range of lines from the first
  175.             {lnum} to the second {lnum}.
  176.  
  177.                             *perl-Append*
  178. Buffer->Append({lnum}, {line}, {line}?, ...)
  179.             Appends each {line} string after Buffer line {lnum}.
  180.             The list of {line}s can be an array.
  181.  
  182.                             *perl-Set*
  183. Buffer->Set({lnum}, {line}, {line}?, ...)
  184.             Replaces one or more Buffer lines with specified
  185.             {lines}s, starting at Buffer line {lnum}.  The list of
  186.             {line}s can be an array.  If the arguments are
  187.             invalid, replacement does not occur.
  188.  
  189. $main::curwin
  190.             The current window object.
  191.  
  192. $main::curbuf
  193.             The current buffer object.
  194.  
  195.  
  196.  vim:tw=78:ts=8:sw=8:
  197.