This is a guest post written by SathiyaMoorthy.
The Perl-Support Vim Plugin – Perl-IDE offers easiest way to do all of the above, saving lot of time and keystrokes. 3 Steps to Install the Perl-Support Vim Plugin
Step 1: Download Perl-Support Vim PluginDownload the plugin from website. $ cd /usr/src $ wget http://www./scripts/download_script.php?src_id=9701 Step 2: Install the Perl-Support Vim Plugin$ mkdir ~/.vim $ cd ~/.vim $ unzip /usr/src/perl-support.zip Step 3: Enable the plugin in the ~/.vimrcAdd the following line to the ~/.vimrc to enable the plugin for Vim editor. $ vim ~/.vimrc filetype plugin on
7 Powerful Features of Perl-Support Vim Plugin
Feature 1: Add Automatic Header to *.pl fileWhen you open a file with the extension .pl it opens the file with header as shown below. This will also place the cursor in the Description field in Insert mode. $ vim #!/usr/bin/perl #=================================================== # # FILE: # # USAGE: ./ # # DESCRIPTION: # # OPTIONS: --- # REQUIREMENTS: --- # BUGS: --- # NOTES: --- # AUTHOR: Dr. Fritz Mehner (mn), mehner@ # COMPANY: FH S??dwestfalen, Iserlohn # VERSION: 1.0 # CREATED: 12/23/2008 03:47:07 PM # REVISION: --- #=================================================== use strict; use warnings;
$ vim ~/.vim/perl-support/templates/Templates |AUTHOR| = SathiyaMoorthy |AUTHORREF| = sm |EMAIL| = test@test.com |COMPANY| = mycompany
$ vim #!/usr/bin/perl #=================================================== # # FILE: # # USAGE: ./ # # DESCRIPTION: # # OPTIONS: --- # REQUIREMENTS: --- # BUGS: --- # NOTES: --- # AUTHOR: SathiyaMoorthy (sm), test@test.com # COMPANY: mycompany # VERSION: 1.0 # CREATED: 12/23/2008 04:09:23 PM # REVISION: --- #=================================================== use strict; use warnings;
Feature 2: Adding Perl Subroutine using \isuFor writing a subroutine, type \isu in normal mode, which will prompt for the subroutine name (as shown in Fig1 below) and inserts the subroutine with default function content (as shown in Fig2 below). Fig 1: Prompt User For Sub-Routine Name
Fig 2: Insert Sub-Routine Automatically to the Perl Code
Feature 3: Insert a Function Header using \cfuFor inserting a function header, type \cfu in normal mode, which will add the comment as shown below. Fig 3: Insert Function Comment to the Perl Code
Feature 4: Add a Frame comment using \cfrTo add a frame comment, type \cfr in normal mode, which will give the following formatted comment. Fig 4: Insert Frame Comment to the Perl Code
Feature 5: Save the file and execute it immediately using \rrType \rr in the normal mode, which will save the file and execute it immediately. Feature 6: Comment a block of code using \ccTo change a entire code block to comment, select the code in visual mode and type \cc. Feature 7: Insert pre-defined code-snippet to the Perl code using \nrThe plugin comes with few pre-defined code snippets that you can insert into your code. Following are the default code snippets that comes with the plugin. $ ls ~/.vim/perl-support/codesnippets/ dot.SmallProf print-data-structure-with-Dumper.pl free-software-comment SmallProf-variables.pl
$ cat ~/.vim/perl-support/codesnippets/ #---------------------------------------------------------------------- # subroutine : print_hash #---------------------------------------------------------------------- sub print_hash { my $hashref = shift; # 1. parameter : hash reference print "\n"; while ( my ( $key, $value ) = each %$hashref ) { print "'$key'\t=>\t'$value'\n"; } # ----- end while ----- } # ---------- end of subroutine print_hash_sorted ----------
Recommended ReadingVim 101 Hacks, by Ramesh Natarajan. I’m a command-line junkie. So, naturally I’m a huge fan of Vi and Vim editors. Several years back, when I wrote lot of C code on Linux, I used to read all available Vim editor tips and tricks. Based on my Vim editor experience, I’ve written Vim 101 Hacks eBook that contains 101 practical examples on various advanced Vim features that will make you fast and productive in the Vim editor. Even if you’ve been using Vi and Vim Editors for several years and have not read this book, please do yourself a favor and read this book. You’ll be amazed with the capabilities of Vim editor. If you enjoyed this article, you might also like.. |
|