Vim::X::Line - A line in a Vim buffer
version 1.3.0
Creates a new Vim::X::Buffer object. Both buffer and index arguments are required.
Makes a copy of the object.
Sets the content of the line to ne $new_content or, if $new_content is not given, returns the current content.
Append the @lines after the current line.
Carriage returns in lines will cause them to be splitted.
Makes the object point to the previous line. Returns the object or undef if at the beginning of the buffer and can't backtrack anymore.
undef
Makes the object point to the next line. Returns the object or, undef if at the end of the buffer and can't advance anymore.
Move back in the buffer until $condition is met.
The condition can be a regular expression, or a coderef that will return true on success. If the condition is not met, the method returns false and the line index of the object is not modified.
true
false
Move forward in the buffer until $condition is met.
When created, the line objects store the buffer and index of the line they correspond to, so they are more like cursors than representations of the actual lines. If lines are added or deleted in the buffer, the object will not be updated in consequence. For example, this won't do what you think:
vim_append( '1 meh', '2 meh', '3 meh' ); for my $line ( vim_lines ) { $line->delete if "$line" =~ /meh/; } vim_msg join ' ', vim_lines; # prints '2 meh'
That's because the original line #2 become line #1 after the first delete. For things to work correctly, you can process the lines in reverse order:
vim_append( '1 meh', '2 meh', '3 meh' ); for my $line ( reverse vim_lines ) { $line->delete if "$line" =~ /meh/; } vim_msg join ' ', vim_lines; # prints nothing!
The line object, when used as a string, will yield its content. And if used in a numerical context, it'll returns its line number.
As an additional piece of sugar is the overloading of '<<=', which sets the content of the line.
$line <<= "$line" =~ s/foo/bar/rg; # equivalent to $line->content( $line->content =~ s/foo/bar/rg );
The Vim::X::Buffer the line belongs to. Read-only.
Sets or gets the line number of the object.
Yanick Champoux <yanick@cpan.org>
This software is copyright (c) 2014 by Yanick Champoux.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
3 POD Errors
The following errors were encountered while parsing the POD:
Unknown directive: =description
Unknown directive: =attribute
To install Vim::X, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Vim::X
CPAN shell
perl -MCPAN -e shell install Vim::X
For more information on module installation, please visit the detailed CPAN module installation guide.