Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

ethan (3163)

ethan
  reversethis-{ed. ... rap.nov.olissat}

Being a 25-year old chap living in the western-most town of Germany. Stuying communication and information science and being a huge fan of XS-related things.

Journal of ethan (3163)

Tuesday November 05, 2002
05:06 AM

Use_Perl_from_vim

[ #8767 ]

So I really was serious with my previous journal entry.

Today I started digging through the extensive vim documentation to find out how to write vim scripts. It's actually quite simple but also has some strange scoping semantics. When running a vim script twice using ":so script.vim" the values set in the first run are still present. You either have to re-start the vim session from which you are calling the script or include a lot of


if exists("b:var")
      unlet b:var
endif

in your scripts.

One great thing about vim is the option to include a Perl interpreter in it. I, for one, am not very inclined to learn any other regex package than the one from Perl, so I don't feel quite at home if I have to use the crippled regexes of grep or, for that matter, vim. Also, the Perl interpreter will make the blogger for use.perl.com a snap. It should even be possible to retrieve old entries from a journal and modify them. My initial concern was that perhaps vim scripting isn't quite as powerful as Emacs' Elisp language. This, fortunately, turned out to be wrong.

<note_to_myself>
A Perl-enabled editor is always superior.
</note_to_myself>

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • I enjoy vim scripting and find it quite powerful [perl.org]. (Plus, it's okay to program in baby-vim and we won't laugh;-) Not all variables (or mappings, or functions) are global in vim, see the documentation, for example at :help script-variable and help script-local. (Assuming you're using vim 6.) I never use the perl interpreter in vim (in fact I never compile my vims with it), because I can always use ! or :! in case of emergency. But again, I feel at home with vim's regexps, because I learned vi (and sed, awk, .
    • I enjoy vim scripting and find it quite powerful [perl.org]. (Plus, it's okay to program in baby-vim and we won't laugh;-)

      Ah, just reminds me that it was your webpage where I picked up this little hack to use vim as a perldoc pager (I need it to be able to paste the relevant parts of the Perl documentation into postings for comp.lang.perl.misc;-). Also, your Perl indenter is in regular use.

      But again, I feel at home with vim's regexps, because I learned vi (and sed, awk, ...) before perl. (I have to admi