Stories
Slash Boxes
Comments

News for nerds, stuff that matters

Slashdot Log In

Log In

Create Account  |  Retrieve Password

A Visual Walkthrough of New Features in Vim 7.0

Posted by ScuttleMonkey on Tue Sep 19, 2006 03:40 AM
from the if-vi-is-wrong-i-don't-wanna-be-right dept.
An anonymous reader writes "Anybody who has used Linux or any other OS would be aware of the very powerful and feature rich text editor Vi. This interesting article takes a visual look at some of the new features in the latest version of Vim 7.0 — a Vi clone created by Bram Moolenaar. From the article: 'Just for once, I wouldn't mind siding with the beast if that is what it takes to use Vi. The modern avatar of Vi is Vim — the free editor created by Bram Moolenaar. Riding from strength to strength, this editor in its 7th version is a powerhouse as far as an editor is concerned. When ever I use Vim (or GVim for that matter), it gives me the impression of the Beauty and the Beast.'"
+ -
story
This discussion has been archived. No new comments can be posted.
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
Loading... please wait.
  • by joss (1346) on Tuesday September 19 2006, @03:48AM (#16136404) Homepage
    Real men just input the entire program at the command line using cat>myprog.c
    Of course, "real men" score higher on machismo than common sense.
    C'mon.. there is nothing that really needs saying on this topic, let the flame
    wars begin.
    • by Anonymous Coward on Tuesday September 19 2006, @04:07AM (#16136456)

      >Real men just input the entire program at the command line using cat>myprog.c


      Huh? Try directly typing into GCC next time, you know, like:

      gcc -x c - && ./a.out
        #include <stdlib.h>
        #include <stdio.h>
       
        int main(void) {
            if(puts("H., w.!")==EOF || fflush(stdout)==EOF) {
                fputs("Failed writing to standard output!\n", stderr);
                return(EXIT_FAILURE);
                }
       
            return(EXIT_SUCCESS);
            }
        ^D
    • Ed, man! (Score:5, Funny)

      by Anonymous Coward on Tuesday September 19 2006, @04:49AM (#16136565)
      Vim is nothing compared to Ed, the greatest WYGIWYG editor of all.

      http://www.gnu.org/fun/jokes/ed.msg.html [gnu.org]
    • by clickclickdrone (964164) on Tuesday September 19 2006, @05:13AM (#16136604) Homepage
      You may laugh, I knew someone that coded that way. They sat, thought, mapped it all out in their head then typed it all in top to bottom in one go. Worse still, it worked first time 99% of the time and I don't recall them ever producing a single bug. Git. This was Dbase III+ FWIW.
      • by NearlyHeadless (110901) on Tuesday September 19 2006, @07:36AM (#16136996)
        In the non-fiction book The Cuckoo's Egg [wikipedia.org], Clifford Stoll is trying to get a call to his computer in Berkeley traced; the person at British Telecom that he talks to originally took computer programming via a correspondence course. He had to write his program out on coding forms, then mail them. They would be keypunched and he would be mailed back the output from the line printer.

        He got in the habit of getting it right the first time.

        • by clickclickdrone (964164) on Tuesday September 19 2006, @07:52AM (#16137065) Homepage
          That was pretty common not that long ago. Most people I know who did programming/science/engineering at University in the 80's did it on clunky old timeshare systems where they wrote the programs (Fortran, usually), punched the cards, sent them off and waited a week. Don't even start talking to them about dropping their card stacks...
          On a slight tangent, I worked for a UK bank around 1988 who had a service where they sent big customers mag tapes of the previous nights checks/cheques for reconcilliation. One tape merged two accounts in error so we had to reproduce the two accounts by hand by having an entire department type out and check 20,000 punch cards over a few days and nights. To add insult to injury, the completed tape was then couriered by motorbike to the customer but the bike crashed and the tape got smashed so we had to get another tape done which took a further 24 hours.
          Youngsters these days with that there Inteenet thang don't know they're born!
    • Real men just input the entire program at the command line using cat>myprog.c
      A real man writes directly to the disk with a magnetised paperclip.
  • Emacs (Score:5, Interesting)

    by arun_s (877518) on Tuesday September 19 2006, @04:00AM (#16136436) Homepage Journal
    I used to use Vim extensively, but have now switched to Emacs for the sheer joy of learning something new and interesting. Not trying to flame here, but this is one of the strongest quotes I've read on Emacs (Stepehenson, of course):
    I use emacs, which might be thought of as a thermonuclear word processor. It was created by Richard Stallman; enough said. It is written in Lisp, which is the only computer language that is beautiful. It is colossal, and yet it only edits straight ASCII text files, which is to say, no fonts, no boldface, no underlining. In other words, the engineer-hours that, in the case of Microsoft Word, were devoted to features like mail merge, and the ability to embed feature-length motion pictures in corporate memoranda, were, in the case of emacs, focused with maniacal intensity on the deceptively simple-seeming problem of editing text. If you are a professional writer--i.e., if someone else is getting paid to worry about how your words are formatted and printed--emacs outshines all other editing software in approximately the same way that the noonday sun does the stars. It is not just bigger and brighter; it simply makes everything else vanish.

    But vim is pretty cool too (I have windows ports for both the editors so I can use both in office). Arguing over which is better is a waste of time IMO, both do their job fantastically well.
    • Re:Emacs (Score:4, Interesting)

      by cortana (588495) <sam&robots,org,uk> on Tuesday September 19 2006, @04:24AM (#16136506) Homepage
      On the other hand, arguing is fun and a good way to learn about the editor you don't use because you're not familiar with it. :)
    • Re:Emacs (Score:4, Funny)

      by Jah-Wren Ryel (80510) on Tuesday September 19 2006, @08:20AM (#16137207)
      I use emacs, which might be thought of as a thermonuclear word processor. It was created by Richard Stallman; enough said....

      Enough said, yet the author goes on to write an entire paragraph?

      Perhaps Neal Stephenson does not quite grasp the meaning of "enough?" Judging by the length of his books, I guess that's probably true.
  • Bill Joy (Score:5, Informative)

    by Brainix (748988) <brainix@gmail.com> on Tuesday September 19 2006, @04:06AM (#16136450) Homepage
    For the younger ones in the audience, Vim is a superset of vi [wikipedia.org], which was originally written by Bill Joy [wikipedia.org].

    Yes, the same Bill Joy who heavily contributed to BSD [wikipedia.org], TCP/IP [wikipedia.org], NFS [wikipedia.org], and csh [wikipedia.org].

    Yet I still count vi as one of his top contributions. :-)
  • Looks good (Score:5, Funny)

    by 1310nm (687270) on Tuesday September 19 2006, @04:09AM (#16136463)
    I can see myself using the tab and undo features, but the spillchucker adn autocomplete seme useliss 2 me.
  • by dp_wiz (954921) on Tuesday September 19 2006, @04:13AM (#16136473)
    How do i enable that clippy?
  • by martinmarv (920771) on Tuesday September 19 2006, @04:14AM (#16136476) Homepage
    From the Article:
    I realise that I have made a mistake. I can easily take the document to a point 10 minutes back by using the command :
    :earlier 10m

    Or for that matter, move to a point 5 seconds ahead by using the command:
    :later 5s


    ... So I don't need to actually do the work any more? I can just start a new file "Project Plan", enter the command ":later 7200s" then print it out?
  • by chub_mackerel (911522) on Tuesday September 19 2006, @04:14AM (#16136480)

    FTFA:

    I can easily take the document to a point 10 minutes back by using the command :
    :earlier 10m
    Or for that matter, move to a point 5 seconds ahead by using the command:
    :later 5s

    AWESOME! Need to finish writing a paper? Normally take about 2 hours? Just type in

    :later 2h

    No muss, no fuss.

  • While it may be free (Score:5, Informative)

    by also-rr (980579) on Tuesday September 19 2006, @04:21AM (#16136499) Homepage
    It is also charity ware. The website asks for donations to a charity that helps children in Uganda [iccf-holland.org].
  • by MickDownUnder (627418) on Tuesday September 19 2006, @04:26AM (#16136510)
    Windows Users DON'T get excited about text editors !
  • by swordgeek (112599) on Tuesday September 19 2006, @04:42AM (#16136549) Journal
    While I have no doubt that vim is a powerful and useful editor, it's increasingly large laundry-list of features is dragging it increasingly farther away from both the functionality and the philosophy behind vi. Keep in mind that vi is a visual superset of ex. As such, it was designed as a visual text editor that works on any cursor-addressable terminal. All functions are accessible from the home-row of keys, with the exception of the esc key. Editing features use regular expressions. In short, it's the ideal editor for the touch-typing administrator who can count on it working under fairly rough circumstances.

    As a sysadmin, I have to ask how features like pop-up spellcheck and "omini" completion will help me edit config files on a vt102 terminal, (OK, my hard terminal is actually a vt520). vim is basically becoming a graphically-dependent editor that happens to use a similar editing structure to vi. Yes, I know about vi compatability mode, but that just throws out most of the last 'n' years of development.

    My point? Not that development should be stopped, or that these goll-durned newfangled features ain't right, but that I wish it wasn't always trumpeted as "vi--but better." Most of the 'better' part of is are things that point away from vi.
  • Vim is good (Score:4, Interesting)

    by jandersen (462034) on Tuesday September 19 2006, @05:29AM (#16136648)
    But it is also becoming what vi was never really intended to be IMO. What makes vi such a great editor is a number of factors, such as:

    - it is small
    - it does a lot of things that are useful for editing source files
    - it is very economical with bandwidth etc
    - all commands map to keys that are found on all terminal keyboards

    If I should say anything against vim it would be that it can do too many things that are only eye candy or 'cool features'. Fortunately you can turn them off, which I always do. If you develop on several different UNIXes (and other OSes with UNIX like environments) getting used to all the extra features in vim can be a real pain, when you have to work with the classic form of vi.
  • by kahei (466208) on Tuesday September 19 2006, @05:34AM (#16136657) Homepage

    Recently, Richard Stallman gave a speech in which he illustrated an academic point about programming history by quoting a guy who described vi as 'an editor spread at sword-point and which is really hard to use'.

    I think I speak for all moderate vi(m) users when I say -- DEATH and DAMNATION (in that order) to this Cardinal of the CTRL key! Needless to say my own local vim user group has dispatched assassins to kill Mr. Stallman, but this is hardly the end of the story. The fact is that a man has referred to another man who in turn expressed some often-voiced reservations about OUR EDITOR! On behalf of all editors of text everywhere, I implore EMACS users to return to the true path, lest you be burned at the stake and then go to hell, the Buffer From Which There Is No Unloading. We'll see how productive you are then, with your ctrl-meta-alt and your ELISP and your 'ring buffer', whatever THAT is.

    Peace and love to all.
    ^C
    ^X
    quit
    q
    QUIT
    exit :exit
    zz
    ZZ

  • The elegance of vi (Score:5, Interesting)

    by PhotoGuy (189467) on Tuesday September 19 2006, @05:59AM (#16136717) Homepage
    Not to start an editor war, but one thing a lot of people don't "get" about vi, is how much more natural it is for touch typists. The typewriter keyboard was designed with two shift keys within easy reach. Ctrl and Alt were grafted on later for computers, and are less natural to reach (and in the early days, there were only ones for the left fingers, making things like Ctrl-T fairly hard on the hands).

    vi lets you access all of its powerful functionality using only these natural keys for typing (well, plus ESC, which is another computer addition, but its only used to flip out of insert mode, when you're done a bunch of typing, typically). Being able to move to the top of the screen by typing capital-H is a lot faster than control-whatever/control-whatever, or taking your hand off the keyboard, reaching for your mouse, aiming, and clicking. (It still amazes me that this latter approach is the one that leads the way in modern word processors, due to its obvious, but inefficient, nature.)

    This is why vi fans often joke as emacs standing for escape-meta-alt-control-shift; to a seasoned vi user, all the escapes in emacs are far more confusing than the biggest complaint about vi, it's two modes. (Reminds one of the joke about the newbie asking the TA for help; the TA says, "you do know vi has two modes, right?" The newbie replies, "yes, the one where it beeps, and the one where it doesn't.") But at the end of the day, the concept of two modes isn't rocket science to learn, and as far as all the key commands one has to learn, it's no different than emacs, where I found the key sequences far more confusing.

    • by anandsr (148302) on Tuesday September 19 2006, @09:03AM (#16137454) Homepage
      There are two types of people.
      1) Those who can think very clearly and can write whatever they need to in one go, without ever having to revise it.
      2) Those who cannot write even a single line without needing to use the delete feature 10 times.

      For the type 2) people vi is not a useable editor. At least not for anything that requires writing more than a couple of lines. I unfortunately am a type 2) person and have to live with emacs. IOW vi is for perfect people, and I am actually a blathering idiot when it comes to typing in my thoughts or code.

      I still use vi quite a lot, for quick editing. But if I have to write more than a couple of lines then I start searching for emacs.

      I am quite used to the two editors. Since when you are within emacs you can do almost anything, there is very little motivation to learn another editor. This is why I hate having to use any other program that tries to make me learn its editor, and does not provide emacs key bindings.

      It is good that some of the emacs key bindings are used in many editors like the firefox input box.
  • by cabazorro (601004) on Tuesday September 19 2006, @07:26AM (#16136956) Homepage Journal
    Real men of genius
    Today we salute you Mr. vi editor coder guy.
    Mr. vi editor coder guy!
    You type at lightning speed while while the rest of us squint our eyes in wonder.
    What the hell you just did to my file!?
    You scour through code like a red-hot knife on butter
    now my file looks funny in Notepad!!
    Thanks to you Mr. vi editor coder guy, you remind us, it's all about the code!
    Mr vi editor coder guy!
  • Returning to VI(M) (Score:5, Informative)

    by qazwart (261667) on Tuesday September 19 2006, @08:18AM (#16137193) Homepage
    I've been programming since the 1970s when we really didn't have screen editors. We used line editors, and had to keep retyping the "list" command to see how our program was shaping.

    VI was actually not the first screen editor I used. The first I used was the old Textedit on the Mac. I thought it was wonderful. I could actually move the cursor around and see what I wrote. My introduction to VI was when I first started working with C on Unix. I hated it.

    VI was primative. Where my Mac editor was single mode, I had to switch back and forth between command mode and insert mode with VI. Where my Mac editor would wrap text, VI wouldn't. Where I could easily find a command with the menus, with VI, I had to remember archaic key strokes. Who in the hell wrote this junk!

    However, once I started getting use to it, VI grew on me. The commands I quickly learned could be combined. For example, "d" deletes. "e" moves to the end of a word. "de" deletes to the end of a word and "3de" deletes the next three words. "xp" transposes two characters. There was an order to them: "d" for delete", "f" for find, "r" for replace. It started making sense. Then I started learning the ins and outs of RegEx, and I never looked back.

    Not only that, but I quickly learned that for program editing, VI simply worked better than Textedit or Notepad. Unlike word oriented text editors, VI was line oriented just like a computer program. I've been using VI ever since. Over the years, I've tried GUI editors (Jedit, Nedit, KDEdit, TextPad, etc.) but I keep returning back to VI.

    Most of these young whipper JDs (Java Developers) with their "Object Orientation" and "Virtual Machines" think of my preference for this non-graphical editor as quaint. Sort of like the way you'd look at Grandpa playing around with his model trains. That is until they realize that I can write code a lot faster than they can.

    Last year, one developer told me it was going to take a few hours to clean up a particular program. I loaded the files in VI and transformed them in a matter of minutes. He was shocked. How can this "obsolete" little text editor do the job much more efficiently and faster than his feature ladened GUI? Why doesn't his editor support regular expressions? Why can VI load the files in less than a second while it takes VisualStudio three or four minutes? How can I write a program and never have to touch the mouse?

    My sons have just started taken up programming. My 15 year old kid likes working with PHP, and first refused to even look at VI -- to old fashion and out of date -- just like his dad. He had a *better* IDE that was made specifically for HTML/PHP web development.

    I recently caught him using VI. He had to admit that once you get over the basics, VI is faster and easier to use for his needs. My oldest is in college and I saw using VI for writing his term papers and essays. He said he found working with VI better because it kept him concentrating on content than formatting. Plus, it makes writing a lot faster. Takes a lot of time switch to the mouse each time really slows you down. He showed me how he programmed a macro spell checker using an ASCII dictionary and ispell. He also showed me the "linebreak" feature in VIM (something I didn't know about).

    After all these years, I still haven't found anything that is as efficient as VI for editing. From what I see in Linux world, a lot of younger programmers who grew up with nothing but graphical interfaces agree with me.
    • Re: (Score:3, Insightful)

      Basically vi was designed for 24x80 CRT screens of which the ADM3 and the VT100 became the most popular although this depends who you talk to. On an ADM3 the HJKL key actually had the Left, Down, Up and Right arrow keys printed on them hence the convention. I do actually surprise my colleagues by using the basic keyboard (ie. no function or cursor keys) but I have a background of using so many different keyboards (including teletypes) that it is much faster for me to do this.

      By using "cursors" it was possib
    • by njdj (458173) on Tuesday September 19 2006, @06:33AM (#16136786)

      I know the best way to learn to use Vim is to use it every day.

      That's the only way. Getting to like vi (or vim) requires that you damage your brain, and a tool to do that is already to hand - vi. After using it every day for a while, it will seem quite natural to you that the letter "l" is the command to move the cursor to the right.

      • Re: (Score:3, Informative)

        Well, it was natural on the terminals where it was originally developed, because those keys were marked with arrows.

        As people were using it on other terminals, they discovered that it didn't matter what the key actually said and that it was just a good key binding.
    • by nickos (91443) on Tuesday September 19 2006, @08:47AM (#16137345)
      Like probably many people, I have the "inverse T" cursor key layout deeply etched in muscle memory, and I much prefer this to having left, down, up, right in a row like hjkl is (although I'm sure others prefer having all the keys on the home row). As a result I use ijkl to move the cursor and h to insert (this also means that touch typists get to keep their fingers on the touchtyping home keys and just move their second finger to i when they move the cursor up). This is what the relevant part of my .vimrc file looks like:
      " remap h to insert and use ijkl for inverse T cursor movement
      map h <insert>
      map i <up>
      map j <left>
      map k <down>
      • by Lusa (153265) on Tuesday September 19 2006, @05:03AM (#16136588)
        So maybe you could try reducing your dependency on IDEs.
        Open a terminal and stick with it.
        Symlink eclipse to vi.


        That is perhaps the worst bit of advise I have seen so far. If they have a job to do, then they should not switch away from what gets the job done quickest for them. A far better bit of advise is to use vi for when the IDE does not help. Such as quick edits, shell script editing or config file changing. That way they still can get their job done in a reasonable amount of time but still get to use vi on a regular basis.
    • Re:Default mode (Score:4, Informative)

      by swordgeek (112599) on Tuesday September 19 2006, @04:51AM (#16136567) Journal
      Sucks to be you.

      I work on dozens of modern, high-end systems that don't have arrow keys. In fact, the only access to many of them is through an amber-on-black text-only monitor (hey, we've evolved from green on black! :-).

      If you don't like vim, fine--there are those other 99% of editors that you can choose from. However, that's not a valid reason to change it from what it was designed for (or at least what vi was designed for) and in the process piss off the people who use it the way it is.

      In short, don't try to change MY editor to suit YOUR desires. -g may be an unintuitive way to get to the end, but you can do it without having to move away from the home-row on the keyboard, it works on all terminals, and 1-g to get to the top of the file or 341-g to get to the line that some config file parser told you was the source of your error is a lot more consistent and efficient than having different keystrokes for each function, and having to scroll to a specific arbitrary line.

      It's not a friendly editor. It's an efficient and universal editor.
    • Re:Default mode (Score:5, Informative)

      by TheBogBrushZone (975846) on Tuesday September 19 2006, @05:45AM (#16136676)
      Does Vim still default to starting in command mode? I suppose it does (...) It's a text editor, it should start in insert mode like every other editor.

      It has something called 'Easy mode' for those who dislike the mode distinction or just want to use a dubmed-down editor interface. And why should starting in insert mode be the 'right' thing to do just because other editors do it? 99% of the time when I first open a text file I don't want to start inserting text. I want to navigate somewhere, usually by searching for a string or a line number.

      Pressing some key to start typing is bloody annoying, then pressing Esc to insert commands is also annoying.

      You seem to be very easily annoyed. Use vi or ViM for a while and the dual mode system becomes second nature and you miss it in other applications.

      Ctrl-sequences are much better, and the default insert mode means I can do simple text editing and slowly learn other commands of the editor.

      I don't see any major disadvantage here. You can do the same with ViM. All you need to start with are 'i', 'ESC' and 'ZZ'. The cursor keys and most of the navigation keys work in the same way as other editors until you learn to use the more advanced navigation available.

      To be honest, I also find Vim's shortcuts extremely unintuative. Want to go to the end of the document? 99% of editors, Ctrl-end. Vim, G. Sorry, that's retarded.

      Did you actually try doing that in ViM? CTRL-END works just the same as G. Has done for a long time. And why should using one arbitary key combination be more 'retarded' than another? CTRL-END could just as correctly be used to terminate the application or insert the letters 'E', 'N' and 'D'. You are entitled to your opinion but it's just arrogance to assume your interpretation is the only valid one.

      Maybe it's based in the days of legacy terminals that didn't have arrow keys or even control sequences, but we're not in those days anymore; it's the text editor equivalent of still using a green-on-black text-only monitor.

      It's called Vi iMproved. It takes the features that people found useful with vi (and its predecessors) with newer features added (not that the Control key you seem to have an obsession with is exactly a cutting-edge invention). Most developers I know, myself included, prefer ViM because it contains a wealth of practical features and a fast, efficient user interface for those with the patience to learn a little and get past the preoccupation with Microsoft-prescribed keyboard shortcuts.
      • Re: (Score:3, Informative)


        My first serious use of vi was under OpenBSD 2.6 and I forced myself to become relatively proficient because I recognized that vi was the universal reference point for console administration. For creative work (writing code, documentation) I slogged through the emacs learning curve and eventually found a pleasant comfort level, though never equalling my old proficiency with Brief under MSDOS. Sometimes I manage to get twenty powerful psgml-mode commands embedded into my fingers, but they are soon gone aga
    • Re: (Score:3, Interesting)

      One thing that could sell some of my co-workers on vim would be if it had better XML features. Nothing too fancy but at least prettyprinting and a wellformedness check.

      :%!xmllint --format
      :%!xmlwf

      Add a few GUI things to make life easier for people using search+replace and it could well become the preferred editor (people are now making do with editpad, notepad2, xmlspy home edition, etc.)

      Point those people at gvim (or, if they don't want a modal editor, evim).

      The rest of your suggestions are more