What are your suggestions for an ideal Vim configuration for Perl development?

后端 未结 12 1018
说谎
说谎 2021-01-29 17:56

There are a lot of threads pertaining to how to configure Vim/GVim for Perl development on PerlMonks.org. My purpose in posting this question is to try to create, as much as pos

相关标签:
12条回答
  • 2021-01-29 18:30

    For tidying, I use the following; either \t to tidy the whole file, or I select a few lines in shift+V mode and then do \t

    nnoremap <silent> \t :%!perltidy -q<Enter>
    vnoremap <silent> \t :!perltidy -q<Enter>
    

    Sometimes it's also useful to deparse code. As the above lines, either for the whole file or for a selection.

    nnoremap <silent> \D :.!perl -MO=Deparse 2>/dev/null<CR>
    vnoremap <silent> \D :!perl -MO=Deparse 2>/dev/null<CR>
    
    0 讨论(0)
  • 2021-01-29 18:30

    Here's an interesting module I found on the weekend: App::EditorTools::Vim. Its most interesting feature seems to be its ability to rename lexical variables. Unfortunately, my tests revealed that it doesn't seem to be ready yet for any production use, but it sure seems worth to keep an eye on.

    0 讨论(0)
  • 2021-01-29 18:32

    .vimrc:

    " Allow :make to run 'perl -c' on the current buffer, jumping to 
    " errors as appropriate
    " My copy of vimparse: http://irc.peeron.com/~zigdon/misc/vimparse.pl
    
    set makeprg=$HOME/bin/vimparse.pl\ -c\ %\ $*
    
    " point at wherever you keep the output of pltags.pl, allowing use of ^-]
    " to jump to function definitions.
    
    set tags+=/path/to/tags
    
    0 讨论(0)
  • 2021-01-29 18:40

    Here are a couple of my .vimrc settings. They may not be Perl specific, but I couldn't work without them:

    set nocompatible        " Use Vim defaults (much better!) "
    set bs=2                " Allow backspacing over everything in insert mode "
    set ai                  " Always set auto-indenting on "
    set showmatch           " show matching brackets "
    
    " for quick scripts, just open a new buffer and type '_perls' "
    iab _perls #!/usr/bin/perl<CR><BS><CR>use strict;<CR>use warnings;<CR>
    
    0 讨论(0)
  • 2021-01-29 18:41

    I find the following abbreviations useful

    iab perlb  print "Content-type: text/html\n\n <p>zdebug + $_ + $' + $`  line ".__LINE__.__FILE__."\n";exit;
    iab perlbb print "Content-type: text/html\n\n<p>zdebug  <C-R>a  line ".__LINE__.__FILE__."\n";exit;
    iab perlbd do{print "Content-type: text/html\n\n<p>zdebug  <C-R>a  line ".__LINE__."\n";exit} if $_ =~ /\w\w/i;
    iab perld print "Content-type: text/html\n\n dumper";use Data::Dumper;$Data::Dumper::Pad="<br>";print Dumper <C-R>a ;exit;
    
    iab perlf foreach $line ( keys %ENV )<CR> {<CR> }<LEFT><LEFT>
    iab perle while (($k,$v) = each %ENV) { print "<br>$k = $v\n"; }
    iab perli x = (i<4) ? 4 : i;
    iab perlif if ($i==1)<CR>{<CR>}<CR>else<CR>{<CR>}
    iab perlh $html=<<___HTML___;<CR>___HTML___<CR>
    

    You can make them perl only with

    au bufenter *.pl iab xbug print "<p>zdebug ::: $_ :: $' :: $`  line ".__LINE__."\n";exit;
    
    0 讨论(0)
  • 2021-01-29 18:42

    Perl Best Practices has an appendix on Editor Configurations. vim is the first editor listed.

    0 讨论(0)
提交回复
热议问题