Wednesday, 24 March 2010

 

VIM: Opening an External File using Wildcards

VIM allows the use of wild cards when opening or reading another file with the proviso that only ONE file may match.

e.g.
:r inc/*export*

or

:tabe ../*books/booklist*

(corrected)

Labels:


Friday, 19 March 2010

 

VIM: Creating a Custom Command with a Temporary Map

Maps allow us to create our custom Vim commands

The VIm initialization file .vimrc is typically used to store maps.
eg:-
imap ,,, <esc>bdwa<<esc>pa><cr></<esc>pa><esc>kA
" s commands these are wrap html around visually selected text
vnoremap sb "zdi<b><C-R>z</b><ESC>
vnoremap sq "zdi"<C-R>z"<ESC>
vnoremap sp "zdi<p><C-R>z</p><ESC>
vnoremap s( "zdi(<C-R>z)<ESC>

However it is very easy to create a temporary map eg to use the key '#' as a map

eg a map to copy the word under the cursor into the paste buffer
:map # "*yiw

A map has an advantage over a recording in this case as it is only necessary to type one character, a recording has an advantage over a map in that you don't have to think it out, so why not combine the two?

Map the key # such that it executes the recording q
:map # @q

Labels: ,


Saturday, 6 March 2010

 

Useful VIM Abbreviations for debugging Perl

iab perlb print "<p>debug ::: $_ :: $' :: $` line ".__LINE__."\n";exit;
iab perlbb print "<p>debug ::: <C-R>a line ".__LINE__."\n";exit;
iab perlbd do{print "<p>debug :: <C-R>a line ".__LINE__."\n";exit} if $_ =~ /\w\w/i;
iab perld use Data::Dumper;$Data::Dumper::Pad="<br>";print Dumper @product_array;exit;

the <C-R>a automatically inserts whatever variable you had previously stored in register a
Dumper allows you to display arrays and hashes, you really should be using it.

Perl can be debugged using the Perl debugger eg > perl -d test.pl

or with the tk gui

perl -d:ptkdb test.pl

Labels: , , ,


This page is powered by Blogger. Isn't yours?

Subscribe to Posts [Atom]