Vim Documentation: if_perl


    For Vim version 5.0p.  Last modification: 1997 Sep 13


		  VIM REFERENCE MANUAL    by Sven Verdoolaege
		  			 and Matt Gerassimof

[This document is still under construction]

Perl and Vim				 

1. Editing Perl files			|perl-editing|
2. Compiling VIM with Perl interface	|perl-compiling|
3. Using the Perl interface		|perl-using|

{Vi does not have any of these commands}


1. Editing Perl files [should add some info about Perl highlighting here] To use tags with Perl, you need a script that generates the tags file from a Perl script. Here's the URL for two of these: <URL:http://fohnix.metronet.com/perlinfo/scripts/text-processing/newptags.pl> <URL:http://www.geek-girl.com/perl/coombs-scripts/ptags>
2. Compiling VIM with Perl interface To compile Vim with Perl interface, you need Perl 5.004 (or later). It must have been installed already, before starting to compile Vim. It will NOT work with the 5.003 version that has been officially released! It will probably work with Perl 5.003_05 and later. The Perl patches for Vim were made by: Sven Verdoolaege <skimo@breughel.ufsia.ac.be> Matt Gerassimof
3. Using the Perl interface :pe[rl] {cmd} Execute Perl command {cmd}. {not in Vi} :[range]perld[o] {cmd} Execute Perl command {cmd} for each line in the [range] (default whole file). {not in Vi} Here're some things you can try: > :perl $a=1 > :perldo $_=reverse($_);1 > :perl VIM::Msg("hello") > :perl $line = $curwin->Buffer->GetLine(42) Here is an overview of the functions that are available to Perl: > perl VIM::Msg("Text") # displays a message > perl VIM::SetOption("ai") # sets a vim option > perl $curwin->SetHeight(10) # sets the window height > perl @pos = $curwin->Cursor() # returns (row, col) array > perl @pos = (10, 10) > perl $curwin->Cursor(@pos) # sets cursor to @pos > perl $curwin->Cursor(10,10) # sets cursor to row 10 col 10 > perl $b = $curwin->Buffer > perl $b->Name() # returns buffer name > perl $b->Count() # returns the number of lines > perl $l = $b->Get(10) # returns line 10 > perl @l = $b->Get(1 .. 5) # returns lines 1 through 5 > perl $b->Delete(10) # deletes line 10 > perl $b->Delete(10, 20) # delete lines 10 through 20 > perl $b->Append(10, "Line") # appends a line > perl $b->Append(10, "Line1", "Line2", "Line3") # appends 3 lines > perl @l = ("L1", "L2", "L3") > perl $b->Append(10, @l) # appends L1, L2 and L3 > perl $b->Set(10, "Line") # replaces line 10 > perl $b->Set(10, "Line1", "Line2") # replaces lines 10 and 11 > perl $b->Set(10, @l) # replaces 3 lines VIM::Msg({message}) Displays the message {message}. VIM::SetOption({arg}) Sets a vim option. {arg} can be any argument that the ":set" command accepts. Note that this means that no spaces are allowed in the argument! See |:set|. VIM::Buffers({bn}?) If {bn} is not specified the function will return a list of all the buffers in an array context and will return the number of buffers in a scalar context. If {bn} is given, it will return the buffer number {bn} if it exists or undef if not. VIM::Windows({wn}?) If {bn} is not specified the function will return a list of all the windows in an array context and will return the number of windows in a scalar context. If {bn} is given, it will return the window number {wn} if it exists or undef if not. Window->SetHeight({height}) Sets the Window height to {height}. The resulting height is limited by the height of the screen. Window->Cursor({row}?, {col}?) Returns (row, col) array for the current cursor position in the Window if {row} and {col} are not specified. If {row} and {col} are specified, it sets the Window's cursor position to {row} and {col}. Buffer->Name() Returns the filename for the Buffer. Buffer->Count() Returns the number of lines in the Buffer. Buffer->Get({lnum}, {lnum}?, ...) Returns a text string of line {lnum} in the Buffer for each {lnum} specified. An array can be passed with a list of {lnum}'s specified. Buffer->Delete({lnum}, {lnum}?) Deletes line {lnum} in the Buffer. If the second {lnum} is specified, the range of lines from the first {lnum} to the second {lnum} are deleted. Buffer->Append({lnum}, {line}, {line}?, ...) Appends the string {line} after line {lnum} in the Buffer for each {line} specified. An array can be passed with a list of {line}'s specified. Buffer->Set({lnum}, {line}, {line}?, ...) Replaces line {lnum} with string {line} for each {line} specified. An array of {lines} can be passed and each subsequent line will be replaced. If the arguments are invalid, the line is not replaced.

Generated by vim2html on Mon Nov 3 03:34:24 EST 1997