home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / vim53os2.zip / vim-5.3 / doc / if_perl.txt < prev    next >
Text File  |  1998-08-30  |  8KB  |  189 lines

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