Preparing Vim for Perl?

Syntax highlighting

Vim is excellent in syntax highlighting. Since all popular languages are supported, Perl is also..

Vim identifies comments, strings, keywords, variables, … and other.

Text completion

Do you think that Vim has excellent text completion? I do not.

Vim has Ctrl-n / Ctrl-p press to cycle word completion suggestions. These suggestions Vim generates based on the words in the current file. Yes, only in the current file.

You need key completion (suggestions) from other files, then you use Vim’s ctags file.

You simply run

ctags *.p?

to generate ctags for all Perl files and modules in the current folder. I take for granted that you are using .pl extension for Perl scripts and .pm extension for Perl modules

Line numbers

Next  Vim should set lines numbers. Just add set number to .vimrc.

Working with multiple files

Vim supports editing of several Perl files simultaneously. Start Vim as “vim file1.pl file2.pl” and then use :next and :previous to navigate through open file. It is also possible to open files for editing without exiting Vim.

Use use simple :e file2.pl command.

To use Perl 5 and Perl 6

Just check this out: https://github.com/vim-perl/vim-perl

Reformat your code to look nice

There are different options to do that in Vim, but perltidy is fair one.

It will reformat your file (whole file) based on settings.</em>

Hope this helps, this is just a basic view, how you can use Vim for Perl programming. Vim also has plugins, that you can use to further improve functionality of this great file editor.

tags: & category: -