
Text::Editor::Vip::Buffer::Plugins::FindReplace- Find and replace functionality plugin for Vip::Buffer

is_deeply([$buffer->FindOccurence('1', 0, 0)], [0, 5, '1'], 'Found occurence 1') ;
is($buffer->GetText(), $text, 'Text still the same') ;
is($buffer->GetSelectionText(), '', 'GetSelectionText empty') ;
#FindNextOccurence
$buffer->SetModificationPosition(0, 0) ;
is_deeply([$buffer->FindNextOccurence()], [0, 5, '1'], 'FindNextOccurence') ;
$buffer->SetModificationPosition(0, 5) ;
is_deeply([$buffer->FindNextOccurence()], [0, 9, '1'], 'FindNextOccurence') ;
# FindNextOccurenceForCurrentWord
$buffer->SetModificationPosition(0, 0) ;
is_deeply([$buffer->FindNextOccurenceForCurrentWord()], [1, 0, 'line'], 'FindNextOccurenceForCurrentWord') ;
$buffer->SetModificationPosition(1, 0) ;
is_deeply([$buffer->FindNextOccurenceForCurrentWord()], [2, 0, 'line'], 'FindNextOccurenceForCurrentWord') ;
$buffer->SetModificationPosition(4, 0) ;
is_deeply([$buffer->FindNextOccurenceForCurrentWord()], [undef, undef, undef], 'FindNextOccurenceForCurrentWord') ;
# Regex search
is_deeply([$buffer->FindOccurence(qr/..n[a-z]/, 0, 0)], [0, 0, 'line'], 'Found occurence with regex') ;

Find and replace functionality plugin for Vip::Buffer

Finds the text matching the regex argument starting at the line and character arguments. If no line argument is passed, the modification position is used.
This sub returns an array containing: ($match_line, $match_position, $match_word)
The Selection is not modified by this sub. To set the modification at the match position:
my ($match_line, $match_position, $match_word) = $buffer->FindOccurence($regex, $line, $character) ;
if(defined $match_line)
{
$buffer->SetModificationPosition($match_line, $match_position + length($match_word)) ;
$buffer->{SELECTION}->Set($match_line, $match_position,$match_line, $match_position + length($match_word)) ;
}
Finds the text matching the regex argument within tha passed boundaries starting at the line and character arguments. If no line argument is passed, the modification position is used.
This sub returns an array containing: ($match_line, $match_character, $match_word)
The Selection an the current modification position are not modified by this sub.
$buffer->FindOccurenceWithinBoundaries('line', @boundaries) ;
Find the next occurence matching the search regex.
Finds the next occurence for the word at the modification position.
Searches for the regex going backwards in the buffer. Intricate regexes might not work.
Searches for the next occurence going backwards in the buffer
Finds the previous occurence for the word at the modification position.
Finds a match for the search_regex argument and replaces it with the replacement_regex.
Arguments:
$buffer->ReplaceOccurence(qr/..(n[a-z])/, 'xx$1') ;
If line or character are undefined or invalid, the current modification position is used.
Valid boudaries must be passed to this sub or it will return undef. No replacement is done if the searched regex doesn't match within the boudaries.
This sub returns an array containing: ($match_line, $match_position, $match_word, $replacement)
Finds a match for the search_regex argument and replaces it with the replacement_regex.
Arguments:
$buffer->ReplaceOccurence(qr/..(n[a-z])/, 'xx$1') ;
If line or character are undefined or invalid, the current modification position is used.
This sub returns an array containing: ($match_line, $match_position, $match_word, $replacement)

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.