Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

On the fly syntax checkers in emacs, ultraedit or vi

by ISAI student (Scribe)
on Nov 30, 2012 at 16:34 UTC ( #1006496=perlquestion: print w/replies, xml ) Need Help??

ISAI student has asked for the wisdom of the Perl Monks concerning the following question:

Hello all. I have used komodo edit, which allows on the fly syntax check. This means that, for example, if I do:

use strict; my $name; $namw="Hello";

There will be on the fly red under-wavey thing, that will show me the typo, BEFORE I do perl -c. This cuts down development time, at least for me. Does anyone know of similar functionality in emacs, vi, ultraedit?

Replies are listed 'Best First'.
Re: On the fly syntax checkers (flymake in emacs)
by LanX (Sage) on Nov 30, 2012 at 17:25 UTC
      Thanks for the head up ... I use Komodo!
        Hi astroboy,

        I'm not a Komodo expert, but it's likely that they also copied the configuration options emacs offers.

        from *Customize Group: Flymake*

        Flymake Start Syntax Check On Find File:  Toggle  off (nil)
           State: SAVED and set.
           Start syntax check on find file.

        No check on load means that simply viewing a foreign file w/o modifying it won't be a risk.

        ("Find file" is emacs lingo for loading a file╣ for editing)

        HTH! =)

        Cheers Rolf

        ╣) or switching to a file if already loaded

Re: On the fly syntax checkers in emacs, ultraedit or vi
by ww (Archbishop) on Nov 30, 2012 at 16:42 UTC
    Perhaps you should read the documentation for "emacs, vi, ultraedit."
Re: On the fly syntax checkers in emacs, ultraedit or vi
by Kenosis (Priest) on Dec 01, 2012 at 03:03 UTC

    EPIC, a Perl Editor and IDE for Eclipse, supports on-the-fly syntax checking. There are Windows, Linux and Mac OS X versions.

Re: On the fly syntax checkers in emacs, ultraedit or vi
by samwyse (Scribe) on Nov 30, 2012 at 23:35 UTC
    When syntax coloring is turned on, vim will (on my system, at least) flag invalid syntax with white text on a red background. OTOH, your example isn't what I would call a syntax error. By misspelling the variable name ($namw) in the second line, the third line appears to use an undeclared variable, which vim won't catch.
      The OP means automatically running perl -c on the current file in the background to display compile time errors "on the fly". Syntax errors are only a subset of possible compile time problems, like missing modules.

      This way warnings and fatals are found an external highlighter would never notice.

      How flymake works

      When flymake mode is active, any of the 3 conditions stated above will cause flymake to try to syntax check the current buffer. Flymake first determines whether it is able to do syntax check. It then saves a copy of the buffer in a temporary file in the buffer's directory (or in the system temp directory -- for java files), creates a syntax check command and launches a process with this command. The output is parsed using known error message patterns, and error information (file name, line number, type and text) is saved. After the process has finished, flymake highlights erroneous lines in the buffer using the accumulated error information.

      There are ports for other editors, e.g.

      Cheers Rolf

Re: On the fly syntax checkers in emacs, ultraedit or vi
by fisher (Priest) on Dec 01, 2012 at 10:33 UTC
    Default emacs installation on debian/wheezy, just open your file in emacs and hit M-x flymake-mode.

    This mode has only two useful functions which you may want to assign to some keys like

    (global-set-key [f5] 'flymake-goto-next-error) (global-set-key [f6] 'flymake-display-err-menu-for-current-line) your .emacs.d/init.el file.

    For even more fun run M-x cperl-mode and read it's docs with C-h m.

      For even more fun :)

      M-x customize-mode [RET] Major mode: flymake-mode [RET]

      (or click Options -> Customize Emacs -> Specific Group)

      And you're getting an interactive menu to change settings.

      For instance I've changed the error highlighting to underlining and switched off the option to flymake on file-load (security reasons).

      Cheers Rolf

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1006496]
Approved by LanX
Front-paged by LanX
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2021-09-24 19:22 GMT
Find Nodes?
    Voting Booth?

    No recent polls found