Text::Editor::Vip::Buffer::Indenter - Default indentiation plugin and documentation for indentation plugins.
Nothing need to be done for using the default indenter. Read on to learn how to define your own indenters.
If you have an indenter for any "standard" indentation, please contribute it to VIP.
If Vip::Buffer::Insert() or InsertNewLine() is called with a SMART_INDENTATION argument, IndentNewLine is called. This lets you define your own indentation strategy.
To define you own indenter, Create a perl module, preferably under Text::Editor::Vip::Buffer::Plugins::Indent::.
The module needs a single function IndentNewLine
package Text::Editor::Vip::Buffer::Plugins::Indent::MyIndenter ; sub IndentNewLine { # modification position is set at the line to indent my $buffer = shift ; # the buffer my $line_index = shift ; # usefull if we indent depending on previous lines # code to implement you indenter }
use Text::Editor::Vip::Buffer ; my $buffer = new Text::Editor::Vip::Buffer() ; $buffer->LoadAndExpandWith('Text::Editor::Vip::Buffer::Plugins::Indent::MyIndenter') ;
if you want to play with an indenter but don't want to bother creating a separate file and package.
use Text::Editor::Vip::Buffer ; my $buffer = new Text::Editor::Vip::Buffer() ; sub my_indenter { # modification position is set at the line to indent my $buffer = shift ; # the buffer my $line_index = shift ; # usefull if we indent depending on previous lines $buffer->Insert(' ') ; # silly indentation $buffer->MarkBufferAsEdited() ; } $buffer->ExpandWith('IndentNewLine', \&my_indenter) ; $buffer->Insert("hi\nThere\nWhats\nYour\nName\n") ; is($buffer->GetLineText(1), " There", "Same text") ;
Khemir Nadim ibn Hamouda CPAN ID: NKH mailto:nadim@khemir.net http:// no web site
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
The full text of the license can be found in the LICENSE file included with this module.
Default Line indenter for Vip::Buffer. Does nothing.
To install Text::Editor::Vip, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Text::Editor::Vip
CPAN shell
perl -MCPAN -e shell install Text::Editor::Vip
For more information on module installation, please visit the detailed CPAN module installation guide.