Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Favorite Text Editor?

by Rhandom (Curate)
on May 22, 2001 at 20:12 UTC ( [id://82262]=perlquestion: print w/replies, xml ) Need Help??

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

I am asking an age old question. I did a super search and found some information in Development Speed and Productivity. But mostly I have found nothing. My question is, "What text editor do you use for coding perl, and why do you use it to code perl?"

Let me lay out some ground rules here. I am not looking for an editor holy war here. I am not interested in whether one or the other is better. I am looking for features that editors have that make them useful for editing perl. I am not even looking for statements like "vi is better because it is always installed on the box." On the emacs side, I am not interested whether Xemacs is better than Emacs or whether perl-mode is better than cperl-mode. I hope that any posts that attempt to extol the virtues of one editor OVER another are "--"ed.

A little background...
We have 15 to 20 programmers, about 5 to 10 sysadmins, and half a dozen html developers. The html guys use Windows based EditPad and WinCVS -- for one reason or another, they have found an easy learning curve with those tools. The sysadmins generally use vi (we are using Red Hat so "vi" is actually spelled "vim") and they use command line cvs -- in their case, vi is always on the box, and "who would be caught using an interface to cvs?" The programmers however are split. Sixty percent use vim and the rest use emacs (although we have had the occasional Nedit, CRiSP, or Microsoft IDE people). I am a firm believer that you really need an extended editor that has minimum features of:
  • Multiple buffers to allow multiple files to be opened, or even viewed at the same time.
  • Copy/Cut/Paste Features (at least basic).
  • Full featured Search/Replace for easy searching of text.
  • Basic line/column numbering.

For obvious reasons, this rules out editors like notepad and pico. I'm sure there are some that are some developers who are capable of turning out lots of good work using pico and notepad, but experience (managing and viewing the work habits of 20 to 30 developers) has shown that people who use an extended editor such as emacs or vim and know their editor well, tend to get more done.

As for myself, I do most of my editing in a terminal window. I am currently using GNU Emacs 21.0.100.2 running in perl-mode with global-font-lock-mode on (which means I get color syntax highlighting in emacs through a telnet window -- yes, vim has had this for years). I know vi and vim at least fairly well, but have found some rather desirable features in using emacs.
  • Excellent indentation model. Emacs actually reads syntax and indents accordingly. Vim has some functionallity as well but is a little less rigorous. Emacs has some trouble with indentation on constructs like ${"x"} = 1; because it thinks ${ is a special variable (you can fix it by $ {"x"} = 1;).
  • Excellent syntax highlighting mode. (Vim is descent as well)
  • Wonderful interface to CVS - ie commiting, updating, logging, checking status (vc- commands)
  • Very powerful searching and replacing using string or regex (so does vim)
  • Macro support (so does vim).
  • Directory Edit mode (dired) allowing for file manipulation, complex regex rename of multiple files, etc.
  • Editting files across FTP (ange-ftp).
  • perldb (interface to the perl debugger).
  • Bookmarks
  • Rectange copy/cut/paste/insert
  • Extremely customizable (vim is too)

I love emacs. But I get the impression that many, if not a majority, of people use vim. Larry uses vi from what I hear. So, what do you use to code perl and why?

my @a=qw(random brilliant braindead); print $a[rand(@a)];

Replies are listed 'Best First'.
Re: Favorite Text Editor?
by premchai21 (Curate) on May 22, 2001 at 20:56 UTC
    I, personally, use Emacs (X usually, but I might switch to GNU) to code Perl, or anything else. For viewing files, I use less. Reasons:

    XEmacs

    1. dired-mode
    2. elisp
    3. indentation
    4. multiple-buffer, multiple-frame
    5. customizable ** 2
    6. gnuclient

    less

    1. /
    2. somewhat like vi, in case I need to use vi in the future
    3. lightweight
    4. runs in terminal
      I'll second these emotions. But more important to me than gnuclient and dired-mode are:
      1. shell
      2. shell-command-on-region
      3. apropos-command, and info

      There's more, but these are the main features that, to my admittedly limited knowledge, aren't to be found in any of the .*vi.* editors.

      I appreciate the desirability of .*vi.* for its small size and ubiquity, but for a fast loading, small editor I use JOE (jmacs, actually).

      -- Frag.

    A reply falls below the community's threshold of quality. You may see it by logging in.
Re: Favorite Text Editor?
by arhuman (Vicar) on May 22, 2001 at 20:30 UTC
    Azatoth is right !
    vi/wordpad win for availability, and beccause they are both powerful enough for a programmer (In fact mostly vi ;-).
    And this point was discussed MANY times here in the monastery...
    That's may be how you should decode the 'I hate this question' sentence...
    (SuperSearch brought me code editor, an editor for perl, and this...)

    Now some facts I'd like to add to help YOU decide
    (you must realize that it's a VERY SUBJECTIVE problem, that can only be solved by YOU).

    • Vim exists both on Windows and Unix
    • Vim has a built-in perl API and can't execute Perl code on text...
    • Ultraedit on windows is also a common choice among programmers


    "Only Bad Coders Badly Code In Perl" (OBC2IP)
Re: Favorite Text Editor?
by sierrathedog04 (Hermit) on May 22, 2001 at 21:15 UTC
    If I may add to Rhandom's question about vi, here is my related one: I use either the vim or vile variants of vi to write Perl scripts. I would love from inside the vi editor to be able to run my perl programs and see my output and errors (if any), possibly in separate windows.

    But I don't know how to run my Perl scripts from inside of vi. Sometimes I fire up a shell inside vi and run my Perl script inside the shell, but that is a lot of extra typing.

    Back when I used to use the Borland C++ editor I was able to run Perl scripts from inside the editor. There must be away to do so with vi. If anyone knows how then please clue me in.

    Update: It is in fact easy to run a perl script while vi is editing it. You simply type the following EX editor command at the colon prompt:

    !perl %
    If you start your perl program off with the shebang command, then you can also use the following command instead:
    !./%

      In the same range, I'm rather fond of the filtering feature of vim (actually, I think it's a feature of all "standard" vi's).

      If you prefix the ! with a range (i.e. "%" for the whole buffer, or ".,147" for current line thru line 147, or "'a,'b" for marker a thru marker b, etc.), vi will pipe the given range into the external command that follows the bang, and replace it with the output of the same command.

      Very useful for one-liners, IMHO. Example: you're editing an SQL file with zillions of INSERT statements, and want to insert a COMMIT every 500 lines, lest the rollback segments chokes under the load:

      :%!perl -ple "print 'COMMIT;' unless $.\%500"

      You need to escape the modulo operator, lest vi interpolates into the current buffer name

      The down side is that you don't see error messages. Unless maybe you say 2>&1 (haven't tried that yet, though

      --bwana147

      You might find the :make feature of vim very useful: You can set makeprg to "perl\ -cw\ %" and use afterwards :make to check the program. This aproach offers you some nice features:
      • It's easier to type
      • You get the error-messages in a special buffer and can step through it. Read about this feature in :help quickfix
      Another real good feature, btw :)
      --
      use signature; signature(" So long\nAlfie");
Re: Favorite Text Editor?
by azatoth (Curate) on May 22, 2001 at 20:16 UTC
    Vi on *nix || TextPad on Windows.

    I hate this question! {g}
      I can't imagine not using Vim on all three of the platforms I use: Linux, Solaris and Win2K.

      Steve Oualline's excellent Vi Improved -- Vim is a thorough overview of Vim, as well as a great introduction to Vi in general. I dig it even more than the tarsier book.

      xoxo,
      Andy

      %_=split/;/,".;;n;u;e;ot;t;her;c; ".   #   Andy Lester
      'Perl ;@; a;a;j;m;er;y;t;p;n;d;s;o;'.  #   http://petdance.com
      "hack";print map delete$_{$_},split//,q<   andy@petdance.com   >
      
      I'm sorry you hate the question. Many people hate the question and are tired of people who argue about it. I am asking "Why do you use what you use?" Is it easier to use or do you use it because you always have.

      my @a=qw(random brilliant braindead); print $a[rand(@a)];
Re: Favorite Text Editor?
by Beatnik (Parson) on May 22, 2001 at 20:15 UTC
    Found nothing?? What about Outside Links ? :-)

    Greetz
    Beatnik
    ... Quidquid perl dictum sit, altum viditur.
      Links to the home pages for the editors are nice but not useful. I could (and have) looked at the home pages before. I'm interested in what the monks use to do their perl coding.

      my @a=qw(random brilliant braindead); print $a[rand(@a)];
        There has been a poll about it... and yes it turned up as one of the first entries of a search :)

        Greetz
        Beatnik
        ... Quidquid perl dictum sit, altum viditur.
Re: Favorite Text Editor?
by lemming (Priest) on May 22, 2001 at 22:22 UTC
    My favorite is vim, it does everything I want it to do. Started using vi in 1981 and never turned back.
    Emacs has loads of nice features, but I also thought of it as a tool for carpal tunnel. Both vi and emacs have plenty going for them and it's silly to try to convert people from one to the other.
    This link shows what some people like about their editor of choice: Editor tricks.
Re: Favorite Text Editor?
by alfie (Pilgrim) on May 23, 2001 at 15:02 UTC
    For me it was definitely Vim - the Vi Improved. Well, I was in search for a good editor when Vim 5.0 has first met the light, and was really astonished by the syntax-highlighting features. And the more I used it and read within through the included online-help the more I loved it. I could quote most of the Why Vim? page here, but just let me quote my own reasons (for, that's what you are looking for :).
    • Multi Platform: I personally like to use the same editor on Windows, OS/2 and any Unix.
    • Definitely syntax highlighting: I've read once that emacs can't use embedded syntax (don't know if that's still true) - Vim can do that quite easy.
    • You can set options depending on the file you edit. Like different (auto)indenting on different files (like mails, code, ...) or even skeleton files when opening new files. This is really one of the features that I like most.
    • Vim has blockmode (rectangle copy/cut/paste/insert). I use it e.g. for commenting out a whole block (insert/delete # infront of a block).
    • Bookmarks are possible through the viminfo file
    • You can jump from subroutines through files and have open multiple files with multiple windows
    • Just found through google: ftpbrws.vim: A script that lets you edit a file through ftp
    google is always a good point to start searching, and if you know what you are searching for you are most of the time quite directly there (like I did for the ftpbrws.vim script: "ftp edit vim" and it was the first link ;-)

    Feel free to contact me if you have questions about vim :)
    --
    use signature; signature(" So long\nAlfie");

      Hi alfie,
      just a few remarks:

      Definitely syntax highlighting: I've read once that emacs can't use embedded syntax (don't know if that's still true) - Vim can do that quite easy.

      Although there is a mode which enables multiple major-modes per buffer this is one of the major FIXMEs in Emacs.

      You can set options depending on the file you edit. Like different (auto)indenting on different files (like mails, code, ...) or even skeleton files when opening new files. This is really one of the features that I like most.

      If I get you right that comes down to use this or that for perl files and this and that for C files etc. That is achieved with the major-mode concept in Emacs

      Vim has blockmode (rectangle copy/cut/paste/insert). I use it e.g. for commenting out a whole block (insert/delete # infront of a block).

      No problem: i got mark rectangle on M-Mouse1 and kill and paste on M-M2 and M-M3 ... :-) (and yes, it works with keys, too)

      Bookmarks are possible through the viminfo file

      Emacs has various ways for that: save-places is just automatic (open file, are at last position) recent-files (stores the N last visited files), desktop (see my post above), and I have read about bookmarks but have never used them

      A script that lets you edit a file through ftp

      Emacs' answer: EFS (does just that)

      Disclaimer:
      yeah OK, this is like showing off, I just wanted to state that these features are (mostly) available with emacs, too. I'm not trying to convert you! I'll never take part in the Holy Editor Wars. If vim is fine for you, use it.

      *grin*

      Regards... Stefan

Re: Favorite Text Editor?
by turnstep (Parson) on May 22, 2001 at 20:24 UTC

    If I'm on a *nix box, it's emacs. If that's not available, I use vi. On Win*, I use TextPad. If it's a very short script, I'll use cat or notepad. You say you are not looking for an editor holy war, but your post is full of comparisons between /vim?/ and emacs. What exactly are you looking for here? Work with whatever makes you the most productive and happy, I say. Don't worry about what others use, except from a curiosity standpoint.

      Partially curiosity. I am fine using vim (much of the time I do use vim because emacs is not on the box I am looking at). When I have my choice I use emacs because it has features that make programming more enjoyable. I know there are some features in vim that people enjoy - but what are they?

      I don't want a flamewar, but I would like to bring to the surface, features which make programming perl easier, be it Nedit, or Crisp, or whatever.

      my @a=qw(random brilliant braindead); print $a[rand(@a)];
Re: Favorite Text Editor?
by Coyote (Deacon) on May 22, 2001 at 22:36 UTC
    I've been using Komodo from ActiveState lately on the Windows side of things. It's more of an IDE than an editor. It's still beta but its worth checking out. The regex modeling tool included with Komodo is worth the download. They also have a version for linux, but I haven't had a chance to check it out yet.

    ----
    Coyote

Re: Favorite Text Editor?
by stefan k (Curate) on May 23, 2001 at 13:54 UTC
    Hi,
    I'm a strong believer in XEmacs. I prefer X over GNU simply because it is highly configured by now (mostly due to traditional reasons: some mode was better preconfigured when I started coding, and I stuck with XEmacs ;-)

    THE major features that I don't know from other editors are:

    • dabbrev
      Usually bound to M-/ but for me it sits on Shift Space. This takes the chars of the word you have typed so far and searches from the current cursorposition in the whole buffer if it finds a match, then expands. If the current buffer yields no result all buffers are searched. I consider this _extremely_ usefull!
    • speedbar
      The speedbar is the major navigation tool with a little problem. The problem is that it usually recognizes files only from ther suffix (which gives a problem when your perl script doesn't have a name that ends in .pl). Anyway if you got speedbar-get-focus on an easy to reach keystroke (for me: C-c C-s) you hit that, get a new frame (whose dimensions are -of curse- customizable). Then you can open a list of functions, global vars, whatever (depends on the programming language you're in) that you can choose (Cursor on it and return or middle mouse button) and jump right to that position.
      This noavigation is waaay cool! (BTW: I wrote a little defun that toggles the open/close-state of a file in speedbar, so you can use space to open or close a function list with one key instead of using + and -. Look at my lisp defuns; site in german, code documented in english...)
    • I can write my own extensions (and can profit from those written by others ;-). If I really need this or that feature, well, I write it. I am no lisp-coder but the little I know is enough for most of the things I want to do.
    • Emacsen are very well documented! And you can live inside Emacs for hours and hours, reading the description of variables and functions, browsing info docs and so on...
    • CVS support is built in but I never used it til now
    • and don't forget the desktop package: in every directory you can have a session file which contains the names of all open files. If you start a new (x)emacs in that directory it can be set up so that if automatically restores your old session
    SyntaxHiliting and indention are very important, but that's what most of the editors offer (and sometimes Emacs is a bit confused. admitted! ;-). But the navigation of sources (esp. when there is more than one file involved) and extensability (word correct?) are major to many of the editors of the world (at least as far as I know, and I know no other editor thoroughly *grin*)

    OK, that's enough for the start, isn't it?

    Regards... Stefan

Re: Favorite Text Editor?
by Animal (Sexton) on May 22, 2001 at 23:39 UTC
    I personally use pico, but only because I'm already familiar with it. I made a cursory attempt to learn how to use emacs, but promptly forgot everything I learned the next day. I've been meaning to give it another shot, but haven't gotten around to it yet.

    ~Animal

Re: Favorite Text Editor?
by brettc (Novice) on May 23, 2001 at 04:35 UTC
    I use VI or VIM on all platforms. I like to use it as a developer because, well I generate errors when I code.(I know hard to belive.) When an error is given in perl try to find the line number quickly in Notepad, pico etc. Second REGEXP ROCK. Go and try to edit you webserver log with notpad or Pico or even emacs. I even went so far as to find an VI like editor to do my work on all platforms. Also it is what I know. I find my self trying to use VI commands in notepad. So if I have a vote go with a VI derivite. Brett
Re: Favorite Text Editor?
by shotgunefx (Parson) on May 23, 2001 at 03:58 UTC
Re: Favorite Text Editor?
by runrig (Abbot) on May 23, 2001 at 05:20 UTC
    I use vi because that's what I learned after notepad :)

    I am currently trying to learn emacs and fumbling along with the basic commands. I think for the things that vi does, its quicker for me to get things done (as can be said for perl) in vi. My fingers don't have to leave the home row whereas in emacs you have to keep reaching over to hit the escape key (I'm sure that could be solved by remapping or something, but I haven't got around to that yet, or what I'd want to remap it to).

    So why I'm I learning emacs? Because emacs and vi are not really comparable. Vi is a great text editor, Emacs is (as I understand it) a great development environment.

    BTW, I find syntax highlighting distracting even on HTML files where a decent job is done of it, and completely annoying when editing perl.

    For another perspective, see this (Hey, I used to use edlin! :).

A reply falls below the community's threshold of quality. You may see it by logging in.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://82262]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (5)
As of 2024-04-16 07:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found