Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

Vim and You

by nefigah (Monk)
on Mar 23, 2008 at 09:12 UTC ( #675751=perlmeditation: print w/replies, xml ) Need Help??

Beloved Monks,

In searching to find what people use on Windows for a Perl editor, vim inevitably shows up. As someone who is relatively new to *nix and programming, I actually initially thought that this was some sort of joke played on noobs who would ask what editor they should use. However, it has happened enough times that I'm pretty sure it's not :)

The general opinion seems to be "vim is the best once you get over the learning curve." That is fine; I'm just curious what vim gives you, as a Perl developer, that other editors do not? (Aside from, of course, "I've used vi since the 80s.")

I'm sure the answer must lie in some of its more complicated features; every editor and their mother does syntax highlighting, auto-indenting, parentheses-matching, regex searching, etc.

So I'm curious what you like best about it. A flat list of features isn't as interesting as "I can't live without X."

Again, please know this is coming from someone who is seriously considering using it--I have no interest in ridiculing anyone for their choice of editor or anything silly like that. I personally use TextMate on OS X as my main editor, as usually I'm on the mac. But the need to do something in Windows does occasionally arise, and hence my curiosity.


I'm a peripheral visionary... I can see into the future, but just way off to the side.

Replies are listed 'Best First'.
Re: Vim and You
by Erez (Priest) on Mar 23, 2008 at 10:35 UTC

    Before anything else I say, keep in mind that Vi/Vim is a text editor; meaning, it can't "give" you anything as a Perl development tool, or as any other language's development tool. Especially, it can't "give" you anything special compared to other editors/IDEs: Syntax highlighting, auto completion, tag recognition, indenting and "prettifying", combination with other tools, macro definitions, all are available from other editors as well. (Whether a given tool's choice can "give" you anything is another debate, which I'll ignore for the moment).

    This been said, Perl development isn't something that requires an IDE, but a text editor. The reasoning is twofold; one, out of the IDE trio components - Compiler/Editor/Debugger, only the editor component doesn't arrive built-in perl, and two, Perl doesn't unload its interface at you, in the sense that you don't need to call String.Regexp.Read.Compile(Match.Test.Show()).ToString() where a simple =~ will do.
    This makes your choice of the editor tool, somewhat more significant, but the actual choice is less critical.
    Vi's modal interface allows you to text-edit in a way that is akin to playing a fast-action game. Without removing your hands from the keyboard, you can edit files using complex commands in a relatively fast way. To get on top of the interface, you'll need to learn the Vi key-modes, which is slightly like learning to touch type. As with touch-type, once you get over the learning curve, your editing speed will become much faster and your actions will be much more precise than before

    However, other than that change, its importance be what it may, Vi/Vim includes no magic tools, and for that sense, no editor really does. If you like working with TextMate, carry on with it. Those who know Vi usually swear by it, as no other editor gives them the editing speed that Vi does. Those who don't, don't really "get" it, or don't think the one main advantage is actually of any worth, or feel "their" editor's special attack is better than Vi's.
    And as always, Your Mileage May Vary.

    Software speaks in tongues of man.
    Stop saying 'script'. Stop saying 'line-noise'.
    We have nothing to lose but our metaphors.

      I would think emacs most likely includes the magic tools to be found somewhere in there. See also the bufferfly effect. ;>}
Re: Vim and You
by ambrus (Abbot) on Mar 23, 2008 at 10:15 UTC
Re: Vim and You
by mobiGeek (Beadle) on Mar 23, 2008 at 15:08 UTC
    The biggest "can't live without" for me (this goes for both VIM and Emacs) is the fact that this text editor is designed specifically WITHOUT a mouse. Yes, mouse support has been added, but I can do everything much, much faster sticking to the keyboard (which is weird, as that's where the "text" comes from) than being forced to:
      Edit >> Find... >> (type, type) >> Replace... >> (type, type) >> Replace All.
      :%s@(type, type)@(type,type)@g
    30 seconds and a whack of context switches compared to 3 seconds and none.

    Those who prefer Notepad++/textpad/ultraedit/yada-yada are for the most part tethered to their mouse. I, for one, despise having to move WAY OVER THERE to get to my mouse (now how can I preview this post without the use of...D'OH!!!!).

Re: Vim and You
by xdg (Monsignor) on Mar 23, 2008 at 16:08 UTC

    Reasons I use vim on Windows. (Not necessarily unique to vim, but it does what I want.)

    Must haves:

    • It's the same editor I use on unix, whether I'm on the GUI or connected on an ssh terminal -- I don't have to retrain my brain when I switch platforms and I have all my macros/shortcuts available wherever I am
    • No mouse needed -- less RSI
    • Smart/explicit about line-ending conversion -- DWIW

    Nice to haves:

    • Fast, particularly on large files
    • Can search/replace with advanced regexes
    • POD folding
    • Macro language
    • Visual column selection (though I rarely use it, it's awesome when I need it)


    Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.

Re: Vim and You
by Lu. (Hermit) on Mar 23, 2008 at 10:10 UTC
    I tend to prefer emacs when I begin to code, especially with Devel::PerlySense, for its real-time syntax checking, but I occasionnally use vim, and like the fact that it is well integrated with the less pager. It's quicker to do
    less v [editing] q
    less q emacs [editing] C-x C-s C-x C-c
    especially when you just want to correct a typo.
    And vi is quicker to launch, too.

      but I occasionnally use vim, and like the fact that it is well integrated with the less pager.

      less is just calling whatever you have set for the EDITOR environment variable. I have EDITOR set to "emacs -nw" on my workstation, and usually "nano" on most of my servers.

        Thank you for that precision. I didn't read the doc thoroughly enough, it seems... Since the editor is launched by pressing 'v', I had assumed it stood for 'Vi'.

        My *Nix-fu is not good enough, have to practice more...

Re: Vim and You
by perrin (Chancellor) on Mar 23, 2008 at 15:21 UTC
    "I've used vi since the 80s."
Re: Vim and You
by parv (Vicar) on Mar 23, 2008 at 09:37 UTC

    I cannot live without vim for I want "<Esc>:w" to do what it is meant to, not do nothing or beep followed by ":w" being entered at the cursor position. I also don't have to reach for the mouse to do tasks other than typing.

    Everything else I suppose you can bury under the "flat list" label, but anyway ...

    • "gf" opens the file invoked on any string, includes support for simple variables ("$dir/file" but not "${dir}/file");
    • visual selection allowing to select columns, and cutting & pasting as such;
    • extensive support for regular expressions;
    • oh, oh before I forget ... key bindings, really love them.

Re: Vim and You
by moritz (Cardinal) on Mar 23, 2008 at 16:00 UTC
    There are many features I love about vim, and most are the usual ones (not so many key strokes, no need to move the hands to the arrow keys, no mouse required, syntax hilighting for 300+ file types).

    But one is really that it makes reading text and editing text different things. That's very helpful when you read source code, and you have a barrier before changing it. That barrier is quite low because many different keys place you into insert or replace mode, but it's there, and I like it.

Re: Vim and You
by wade (Pilgrim) on Mar 23, 2008 at 16:47 UTC

    Well, I have been using vi since the 80s. 8o)

    I'm a big fan of ctags (but ctags also works with emacs), which is a feature that lets you jump to the definition of a subroutine or a variable. I like how easy it is to move around in the code, in code-specific ways, and the fact that many of the commands (like delete) use these movement actions to scope the editing. It handles multiple files nicely (like allowing you to diff two files within the scope of the editing session).

    But the thing, for me, that it's a powerful, free (so that I can use it at home and at any job), nearly ubiquitous editor that I know how to use really well.

Re: Vim and You
by Joost (Canon) on Mar 23, 2008 at 13:52 UTC
    gvim on windows is really a pretty good editor. it's got everything you need for basic text/code editing and it's a fairly small download if you sit down at a new machine.

    personally, i prefer emacs for serious coding anywhere. it takes a lot more time to set up (or at least, I haven't sorted my home configuration to be easily migrated to other machines) but when that's done, there's nothing better.

Re: Vim and You
by akho (Hermit) on Mar 23, 2008 at 22:03 UTC
Re: Vim and You
by frostman (Beadle) on Mar 24, 2008 at 04:04 UTC

    I've used vim on a wide variety of UNIX derivatives, on Windows, and on the Mac, and I look forward to using it on the iPhone (pocket Mac?).

    I think of it as my "first editor" even though I know that can't be true. I must have used something else when failing to learn Pascal on an Amiga, and I must have used pico during the years I used pine, and when I wrote my C64 Super BASIC and played around with Logo and assembly on the //c I must have used a non-vim.

    But at least in my "growed-up life" vi(m) claims some sort of historical primacy. It remains my editor of first resort on unfamiliar systems and on the various things I access by ssh.

    To be perfectly honest my devotion is probably fueled by simple muscle memory. I can :wq! in a half-second in my sleep, and routinely do, causing all sorts of trouble. If nearly every system had the dreaded emacs installed and not vi(m) ("emacs" - it even sounds like a monster!) then I'd probably suck it up and learn ed.

    Nowadays I find myself even more slavishly devoted to TextMate, since I'm usually on a Mac (poor BB, I knew thee well, dinosaur, Darwinian road kill, alas...). For Windows there's a clone called "E" and all the other hyper-powerful little visual editors, not least of them the marvelously quirky UltraEdit, with which I pounded out about four years of code.

    But there's one thing vim does better than any of them, and about which I actually care quite a lot, and that's syntax highlighting.

    Vim's Perl syntax highlighting is the gold standard, the reference. It's so good I use it for "pretty-printing" out of TextMate. I have a back-burnered project to make a toolchain of TextMate -> vim -> XHTML+CSS, just because.

    So, at long last, as much as I love vim for other things, Perl syntax highlighting is the one thing it does that I would mourn, tearfully, if it disappeared from the world, and I would know I was right and not just being a sissy.

Re: Vim and You
by planetscape (Chancellor) on Mar 23, 2008 at 21:29 UTC

      Perl-support rocks the house. I use that with a couple of other plugins such as autocomplete (to keep the rsi away). I gave a talk to where I demonstrated a simple vim IDE I put together using perl-support as the core:

Re: Vim and You
by redlemon (Hermit) on Mar 23, 2008 at 19:41 UTC

    Being able to apply a change on multiple files at once. In the middle of a project I decided to move a module to another namespace. So it went:

    $ gvim $(find . -type f | grep -v \.svn | xargs grep -l 'MyModule') Then in vim: :bufdo %s/MyModule/My::Module/gc

    and hey presto.


Re: Vim and You
by swampyankee (Parson) on Mar 23, 2008 at 17:20 UTC

    Gee, I've used vi and emacs since the 80's, too. Despite the fact that I love emacs (emacs is loved or loathed, occasionally simultaneously), I do find vim quite useful. What I like best about vim? Global search and replace with regex. For emacs? Programming modes.


    Information about American English usage here and here. Floating point issues? Please read this before posting.

Re: Vim and You
by radiantmatrix (Parson) on Mar 24, 2008 at 15:25 UTC

    I use Vim, Elcipse with EPIC, and SciTE for Perl development on Windows. I find myself using Vim most often because:

    1. It works the same on Windows, Unix (incl. Linux), and OS-X
    2. It has an excellent Perl mode, with lots of time-saving shortcuts
    3. It's endlessly extensible; writing your own macros/etc. is extremely easy
    4. It's portable -- I can have versions of Vim for every major OS on a keychain drive

    Every editor in my personal toolkit does some of those things, but Vim is they only one that has all of them.

    That said, the best advice as to which editor to use is this: find one that works the way you like to work, and use it. Editors are a very personal preference, and there is no "one true editor". Your editor should:

    • Help you to work quickly (helping with correctness fits here too)
    • Make it easy to work on code with others (e.g. shouldn't auto-convert line endings, etc.)

    If you like TextMate, though, you may want to try InType or E-TextEditor. Both are attempts to be a "TextMate for Windows".

    Ramblings and references
    The Code that can be seen is not the true Code
    I haven't found a problem yet that can't be solved by a well-placed trebuchet
Re: Vim and You
by herveus (Parson) on Mar 24, 2008 at 11:59 UTC

    Most of all, I like the ubiquity. I can rely on it being on a system (particularly since I eschew Windows to the greatest extent possible), or can get it easily. Since I make some claim to be a Unix sysadmin, I feel it is essential that I be at least comfortable with vi. Anyone who makes that claim and who can't use vi is lying. You can't really call yourself a Unix sysadmin if you don't know vi, unless you prefer ed. I tend to use nedit or BBedit most of the time, but I'm not shy about using vi when indicated.

Re: Vim and You
by TGI (Parson) on Mar 24, 2008 at 19:01 UTC

    The main thing I like about Vim is that it "lays under the hands" better than any editor I have used. I can use Vim to do things without spending a lot of thought the actions themselves.

    Despite what everyone says about learning curve, I was able to reach a point where my productivity was equivalent to other editors a few hours. Within a week, I was able to work much more quickly and smoothly than I was before. The payoff was very quick.

    TGI says moo

Re: Vim and You
by nefigah (Monk) on Mar 24, 2008 at 03:03 UTC

    Ooo, lots of interesting stuff turned up here. Perhaps ironically, my Vim thread has inspired me to investigate Emacs :P (not having to hit Esc to use commands makes them seem "faster," and I want to check out PerlySense that was mentioned).

    I do suppose I'll have a look-see at EPIC too.

    And perl-support.vim :P

    Thanks everyone for the info so far, and for that which is yet to come. So much to learn...

    I'm a peripheral visionary... I can see into the future, but just way off to the side.

Re: Vim and You
by ff (Hermit) on Mar 27, 2008 at 04:46 UTC
    If it's not already clear, it helps to be a touch typist to appreciate vi.

    Something I've discovered recently (after wishing for a long time and not being quite motivated enough to look for such) is vimgrep. I work on a Windows machine and haven't installed some sort of grep....

    One reason I like it stems from the fact that my program is a collection of about 20 Perl files and I have sprinkled error codes throughout. (The wisdom of which will be the point of some other node.) Well when one of those errors lands in my log file, and it's not obvious to me exactly which of all my files generated the message with that code, I can simply do:

    :vimgrep abc123 *.pl

    and Vim searches all the .pl files and goes to the first instance of that string. (There are other ways of delimiting the search string.)

    If I want to see a split screen of the various hits for the search, I can do :cope and a listing pops up at the bottom that I can traverse with my navigation keys (e.g. h, j, k, l) and when my cursor is on the line that matches a line in a file I want to go to, I just press Enter. Ah, much better than the previous way, to which I will not admit.... (You can close out the split screen by clicking in that section and doing :q.)

Re: Vim and You
by smithers (Friar) on Mar 25, 2008 at 03:53 UTC
    Vim is a beautiful text editor Im lost without it for editing any and all files on unix and Windows. I love all the simple editing tasks that vi/vim make easy such as moving lines or blocks of code/text around, joining lines, indenting blocks of code and traversing files. These are just the basics but they are so easy to use in vim without ever touching the mouse (or use the mouse if you prefer in vim). Other simple tasks such as searching for text or expressions is wonderfully simple and subtle features like search highlighting all the matches in a file is appreciated so I can navigate the file and visually see all the search matches without constantly hitting some find-next key. Text search and replace is also very powerful too.

    Another simple feature I love in vim is the syntax highlighting for many types of files such as Perl source, SQL, VBScript, HTML, etc. Another handy simple features I love is visual parenthetical matching in my code vim visually shows the parenthetical pairs no matter how deeply nested.

    These are just the simple aspects of vim but used daily they make a huge difference in the joy of coding/writing and add to my productivity. Ive omitted many of the more complex and amazing aspects of vim but you will discover those over time. Try vim, starting with just the basic editing, navigation, searching, etc. and I think you will get hooked. As a bonus, you will gain the basic vi skills needed to modify/search files and crontabs on practically any *nix system.

Re: Vim and You
by Prof Vince (Friar) on Mar 30, 2008 at 21:56 UTC
    Vim's perl syntax highlighting, although pretty good, still has some quirks. mauke tried to address some of them with its alternate syntax highlighting. In particular, it now handles much more regexp delimiters, as well as subroutines prototypes and attributes. Give it a try by copying the .vim file to your ~/.vim/syntax/perl.vim.
Re: Vim and You
by BrowserUk (Pope) on Mar 23, 2008 at 21:10 UTC

    vi in all it's incarnations always reminds me of an antique motorcycle (of roughly the same vintage:) I got to play with once. Inovatively for it's day, it had two gears. One for the flat and one for hills. The only downside was that you had to stop and move the chain from one set of sprockets to the other by hand.

    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
Re: Vim and You
by Pancho (Pilgrim) on Mar 24, 2008 at 01:20 UTC


    I have been using the Eclipse Plug In EPIC (open source Perl IDE), and it does the job for me...

Re: Vim and You
by rudder (Scribe) on Mar 25, 2008 at 09:29 UTC

    What I like about Vim is that, if you practice, it can be very efficient. That said, once I got over the learning curve, I decided not to use it for other reasons.

    IMO, the important things are:

    1. that you can control your editor quickly using only the keyboard, and
    2. that you can (eventually) program your editor

    Vim meets those req's and so does Emacs. Maybe TextMate does too -- I dunno. Any way you slice it though, you will live very closely with your editor of choice for a long time, and it's tough to get wired like that to more than one editor.

    You might consider just using some simple editor on Windows; one that you can configure to have basically the same key combinations as TextMate. Use it for occasional light editing, but get your files over to TextMate when it comes to doing real work.

Re: Vim and You
by Anonymous Monk on Mar 23, 2008 at 09:35 UTC
Re: Vim and You
by clp (Friar) on Oct 07, 2009 at 23:32 UTC

    Some things that I like about vim.

    • Tips and tools; like CPAN for vim.
    • An editor that can operate in a terminal window (vim) or as a GUI (gvim), with the same keystrokes and commands.
    • gvimdiff <file1> <file2>
      Or try
      vimdiff <file1> <file2>

      not as pretty, but functional if you don't have gvim.

    • :help help<Ctrl-D>

      See all the entries in the help system that contain the given term.

    • VimOutliner

      A set of functions that lets you quickly manipulate text in an outline style inside Vim: organize text into an outline; expand and collapse sections to focus on one topic; quickly move a section with Vim keystrokes as if moving a single line.

      VimOutliner makes very efficient use of the keyboard. You can edit the main topics of a document, then quickly shift to a deep subtopic level with only a few keystrokes.

      Highly recommended.

    • Vim vs IDE

      For writing Perl, I find Vim much easier and more versatile than the IDEs I've tried (ca 2002).
      Plus, I don't have to use the mouse or learn a new set of commands to build code in an IDE, since I already know Vim.
      Plus, any time I spend learning new features of Vim or a plug-in gives me knowledge that I can use for other editing tasks with Vim, not just when I develop code. Time spent learning and debugging an IDE or other tool can only be applied to using that tool.

      If you want to use plug-ins with Vim to gain some features you might face the problem of keystroke conflict. This is less likely to occur with an IDE without third-party plug-ins. These issues can be resolved, which requires you to learn more about Vim and plug-ins. Again, that knowledge will help when you use Vim elsewhere.

      I've recently started learning Java and using the Eclipse IDE, which I find helpful. I don't know if Vim has features and plug-ins that would make it as good as Eclipse to develop Java code. I do wish that I could use Vim as my editor inside Eclipse, and that I could use the Vim keystrokes to navigate inside Eclipse.

    • If I don't use a tool for some time, my ability to operate it quickly and efficiently degrades. The GUI and menus of an IDE can help the occasional user. Using Vim every day for editing text files keeps my skills sharp, so I can use it to write code effectively after several months of not doing it.

Re: Vim and You
by dreadpiratepeter (Priest) on Mar 24, 2008 at 04:50 UTC
    I have to share one of my favorite quotes, very apropos, although I don't remember the source anymore.

    Emacs has disciples; Vi has slaves

    "Worry is like a rocking chair. It gives you something to do, but it doesn't get you anywhere."
      Vi/Vim is beautiful and simple. Why would you say such a thing and flame against it?
Re: Vim and You
by Burak (Chaplain) on Mar 24, 2008 at 10:13 UTC
    I hate command line editors :p I use vi/vim only for quick edits or on small files (or when I need to open a file with different permission) but I generally use Komodo Edit and it's SCP feature for remote files. I know only these vi commands actually (nothing more): i,d,u,w,q,/, !<cmd>
Re: Vim and You
by hill (Sexton) on Mar 24, 2008 at 12:03 UTC
    At the risk of being mildly off topic, have a look at an IDE called Optiperl (check Many useful features and pretty cheap.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlmeditation [id://675751]
Approved by davies
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2021-11-30 22:21 GMT
Find Nodes?
    Voting Booth?

    No recent polls found