NAME

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

SYNOPSIS

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') ;

DESCRIPTION

Find and replace functionality plugin for Vip::Buffer

FUNCTIONS

FindOccurence

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)) ;
	}

FindNextOccurence

Find the next occurence matching the search regex.

FindNextOccurenceForCurrentWord

Finds the next occurence for the word at the modification position.

FindOccurenceBackwards

Searches for the regex going backwards in the buffer. Intricate regexes might not work.

FindPreviousOccurence

Searches for the next occurence going backwards in the buffer

FindPreviousOccurenceForCurrentWord

Finds the previous occurence for the word at the modification position.

ReplaceOccurence

Finds a match for the search_regex argument and replaces it with the replacement_regex. Parenthesis can be be used to assign $1, $2, ... those can be used in the replacement_regex.

$buffer->ReplaceOccurence(qr/..(n[a-z])/, 'xx$1') ;

This sub returns an array containing: ($match_line, $match_position, $match_word, $replacement)

AUTHOR

Khemir Nadim ibn Hamouda
CPAN ID: NKH
mailto:nadim@khemir.net
http:// no web site

COPYRIGHT

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.