vim user switch to emacs?

Discussion in 'Ruby' started by Joe Van Dyk, Aug 26, 2005.

  1. Joe Van Dyk

    Joe Van Dyk Guest

    Hi,

    So, I've been a long-term vim user. But I've heard about how emacs is
    pretty good, and there's a vim-compatible mode in emacs (i tried using
    standard emacs for a day, but my hands hurt so bad from pressing ctrl
    so much).

    Are there any Rubyists out there who use emacs in vim mode? Can you
    post your configuration files so I can get syntax highlighting,
    automatic indentation, etc? And how can I set up emacs to run a shell
    command (i.e. 'ruby <current file>' or 'ruby unit_tests.rb' easily)?

    Thanks,
    Joe
     
    Joe Van Dyk, Aug 26, 2005
    #1
    1. Advertising

  2. ------=_Part_10162_32681173.1125077902247
    Content-Type: text/plain; charset=ISO-8859-1
    Content-Transfer-Encoding: quoted-printable
    Content-Disposition: inline

    I can't speak to the vimisms. Shell mode in emacs is really easy: M-x shell

    In emacs-speak, that's "hold down the Alt key, and press the x key, type=20
    'shell' and hit return.

    You are now sitting at a shell.



    On 8/26/05, Joe Van Dyk <> wrote:
    >=20
    > Hi,
    >=20
    > So, I've been a long-term vim user. But I've heard about how emacs is
    > pretty good, and there's a vim-compatible mode in emacs (i tried using
    > standard emacs for a day, but my hands hurt so bad from pressing ctrl
    > so much).
    >=20
    > Are there any Rubyists out there who use emacs in vim mode? Can you
    > post your configuration files so I can get syntax highlighting,
    > automatic indentation, etc? And how can I set up emacs to run a shell
    > command (i.e. 'ruby <current file>' or 'ruby unit_tests.rb' easily)?
    >=20
    > Thanks,
    > Joe
    >=20
    >


    ------=_Part_10162_32681173.1125077902247--
     
    Kelly Felkins, Aug 26, 2005
    #2
    1. Advertising

  3. Joe Van Dyk

    Mike Douglas Guest

    The mode you are looking for is called Viper Mode.

    M-x viper-mode.

    Btw, remapping the Caps Lock key to Ctrl made the Emacs key bindings
    much easier for me.

    On 8/26/05, Kelly Felkins <> wrote:
    > I can't speak to the vimisms. Shell mode in emacs is really easy: M-x she=

    ll
    >=20
    > In emacs-speak, that's "hold down the Alt key, and press the x key, type
    > 'shell' and hit return.
    >=20
    > You are now sitting at a shell.
    >=20
    >=20
    >=20
    > On 8/26/05, Joe Van Dyk <> wrote:
    > >
    > > Hi,
    > >
    > > So, I've been a long-term vim user. But I've heard about how emacs is
    > > pretty good, and there's a vim-compatible mode in emacs (i tried using
    > > standard emacs for a day, but my hands hurt so bad from pressing ctrl
    > > so much).
    > >
    > > Are there any Rubyists out there who use emacs in vim mode? Can you
    > > post your configuration files so I can get syntax highlighting,
    > > automatic indentation, etc? And how can I set up emacs to run a shell
    > > command (i.e. 'ruby <current file>' or 'ruby unit_tests.rb' easily)?
    > >
    > > Thanks,
    > > Joe
    > >
    > >

    >=20
    >=20



    --=20
    Mike Douglas
     
    Mike Douglas, Aug 26, 2005
    #3
  4. Joe Van Dyk

    Joe Van Dyk Guest

    On 8/26/05, Kelly Felkins <> wrote:
    > I can't speak to the vimisms. Shell mode in emacs is really easy: M-x she=

    ll
    >=20
    > In emacs-speak, that's "hold down the Alt key, and press the x key, type
    > 'shell' and hit return.
    >=20
    > You are now sitting at a shell.
    >=20


    Thanks! What about syntax highlighting and Ruby indentation? (And
    rhtml support would be nice)

    Also, does emacs support stuff like this properly?

    some_function argument_1,=20
    argument_2,
    argument_3
    #cursor should not be here!
    #cursor should be here!

    That's one of the things that bugged me with vim. =20
    =20

    >=20
    >=20
    > On 8/26/05, Joe Van Dyk <> wrote:
    > >
    > > Hi,
    > >
    > > So, I've been a long-term vim user. But I've heard about how emacs is
    > > pretty good, and there's a vim-compatible mode in emacs (i tried using
    > > standard emacs for a day, but my hands hurt so bad from pressing ctrl
    > > so much).
    > >
    > > Are there any Rubyists out there who use emacs in vim mode? Can you
    > > post your configuration files so I can get syntax highlighting,
    > > automatic indentation, etc? And how can I set up emacs to run a shell
    > > command (i.e. 'ruby <current file>' or 'ruby unit_tests.rb' easily)?
    > >
    > > Thanks,
    > > Joe
    > >
    > >

    >=20
    >
     
    Joe Van Dyk, Aug 26, 2005
    #4
  5. Joe Van Dyk wrote:

    > Also, does emacs support stuff like this properly?
    >
    > some_function argument_1,
    > argument_2,
    > argument_3
    > #cursor should not be here!
    > #cursor should be here!
    >
    > That's one of the things that bugged me with vim.


    This has been fixed. Get the latest from CVS:

    http://rubyforge.org/cgi-bin/viewcv...vim-ruby&content-type=text/vnd.viewcvs-markup

    Actually, a lot of things have been fixed in CVS.

    (Although it doesn't work how you describe above. The arguments would
    have to be contained in parentheses. Anything else would require a lot
    more work (_a lot more_)),
    nikolai

    --
    Nikolai Weibull: now available free of charge at http://bitwi.se/!
    Born in Chicago, IL USA; currently residing in Gothenburg, Sweden.
    main(){printf(&linux["\021%six\012\0"],(linux)["have"]+"fun"-97);}
     
    Nikolai Weibull, Aug 26, 2005
    #5
  6. On 8/26/05, Nikolai Weibull
    <> wrote:
    > (Although it doesn't work how you describe above. The arguments would
    > have to be contained in parentheses. Anything else would require a lot
    > more work (_a lot more_)),
    > nikolai


    As far as I can tell, Nikolai, it *does* work without the parens.

    -austin
    --=20
    Austin Ziegler *
    * Alternate:
     
    Austin Ziegler, Aug 26, 2005
    #6
  7. Joe Van Dyk

    Joe Van Dyk Guest

    On 8/26/05, Nikolai Weibull
    <> wrote:
    > Joe Van Dyk wrote:
    >=20
    > > Also, does emacs support stuff like this properly?
    > >
    > > some_function argument_1,
    > > argument_2,
    > > argument_3
    > > #cursor should not be here!
    > > #cursor should be here!
    > >
    > > That's one of the things that bugged me with vim.

    >=20
    > This has been fixed. Get the latest from CVS:
    >=20
    > http://rubyforge.org/cgi-bin/viewcvs.cgi/vim-ruby/indent/ruby.vim?rev=3D1=

    24&cvsroot=3Dvim-ruby&content-type=3Dtext/vnd.viewcvs-markup
    >=20
    > Actually, a lot of things have been fixed in CVS.
    >=20
    > (Although it doesn't work how you describe above. The arguments would
    > have to be contained in parentheses. Anything else would require a lot
    > more work (_a lot more_)),
    > nikolai
    >=20


    Great! If I want to use that, I'd put it in $HOME/.vim/indent? And
    it'll be used automatically instead of the stock version?
     
    Joe Van Dyk, Aug 26, 2005
    #7
  8. Joe Van Dyk

    Cam Guest

    Hi,

    On 8/26/05, Derek Wyatt <> wrote:
    > If this is the sort of thing you're looking for then I have an
    > alternate solution. I was a hard-core emacs user who switched to
    > vim and the one major thing i missed was running a shell in my editor.


    did ':shell' not work for you?

    Cameron Matheson
     
    Cam, Aug 26, 2005
    #8
  9. On 8/26/05, Cam <> wrote:
    > On 8/26/05, Derek Wyatt <> wrote:
    > > If this is the sort of thing you're looking for then I have an
    > > alternate solution. I was a hard-core emacs user who switched to
    > > vim and the one major thing i missed was running a shell in my editor.

    > did ':shell' not work for you?


    That's different. That starts a shell in a new window, or shells out.
    The emacs shell -- one of the few things that I *do* like about emacs
    -- essentially does a new pty on Unix, similar to what screen does.

    -austin
    --=20
    Austin Ziegler *
    * Alternate:
     
    Austin Ziegler, Aug 26, 2005
    #9
  10. Cam wrote:

    > On 8/26/05, Derek Wyatt <> wrote:


    > > If this is the sort of thing you're looking for then I have an
    > > alternate solution. I was a hard-core emacs user who switched to
    > > vim and the one major thing i missed was running a shell in my
    > > editor.


    > did ':shell' not work for you?


    I hear good things about screen as well,
    nikolai (full of irony)

    --
    Nikolai Weibull: now available free of charge at http://bitwi.se/!
    Born in Chicago, IL USA; currently residing in Gothenburg, Sweden.
    main(){printf(&linux["\021%six\012\0"],(linux)["have"]+"fun"-97);}
     
    Nikolai Weibull, Aug 26, 2005
    #10
  11. Joe Van Dyk

    Jacob Fugal Guest

    On 8/26/05, Derek Wyatt <> wrote:
    > -----BEGIN PGP SIGNED MESSAGE-----
    > Hash: SHA1
    >=20
    > |>If this is the sort of thing you're looking for then I have an
    > |>alternate solution. I was a hard-core emacs user who switched to
    > |>vim and the one major thing i missed was running a shell in my editor.
    > |
    > |
    > | did ':shell' not work for you?
    >=20
    > Dont' get me wrong, i love vim and it's the greatest editor in the
    > history of the world, but umm... ":shell" sucks.


    Under what conditions? I'll agree that :shell from inside a gvim
    window (note: gvim, not terminal vim) sucks. However, shell from a
    terminal vim process works fine for me. It would be nice if it had
    screen-type functionality, but I don't consider that one missed
    feature enough to make it suck as horrendously as you imply. In all
    respects, when I :shell from terminal vim, I might as well be in
    another terminal except I have the added bonus that exit takes me back
    to my still running vim instance.

    So, I admitted the :shell under gvim sucks... but why would I need it?
    If I'm in gvim, I've got plenty of other dedicated terminals just an
    M-<tab> away. The only time I use shell is when I'm stuck in a
    terminal vim across an SSH connection without X tunnelling.

    Jacob Fugal
     
    Jacob Fugal, Aug 26, 2005
    #11
  12. Derek Wyatt wrote:

    > > > If this is the sort of thing you're looking for then I have an
    > > > alternate solution. I was a hard-core emacs user who switched to
    > > > vim and the one major thing i missed was running a shell in my
    > > > editor.


    > > did ':shell' not work for you?


    > Dont' get me wrong, i love vim and it's the greatest editor in the
    > history of the world, but umm... ":shell" sucks. Oh does it suck...
    > the vaccuum of space is envious of the amount that ":shell" can suck. :)


    Well, that's really not Vim's fault. If you don't like what :shell
    does, switch shells. Zsh is good, for one,
    nikolai

    --
    Nikolai Weibull: now available free of charge at http://bitwi.se/!
    Born in Chicago, IL USA; currently residing in Gothenburg, Sweden.
    main(){printf(&linux["\021%six\012\0"],(linux)["have"]+"fun"-97);}
     
    Nikolai Weibull, Aug 27, 2005
    #12
  13. Hi!

    At Sat, 27 Aug 2005 02:18:42 +0900, Joe Van Dyk wrote:

    > So, I've been a long-term vim user. But I've heard about how emacs
    > is pretty good, and there's a vim-compatible mode in emacs


    Don't believe those false rumors. Yes, there is viper-mode but it is
    unusable to anyone relying on the advanced features of vi (leave alone
    vim). Yes, unfortunately I know precisely what I am talking about :-|

    Nevertheless you can make Emacs 100% compatible: Simply use 'M-x
    ansi-term' then 'vim ENTER'.

    That actually is running vim inside a terminal emulation inside Emacs.

    When people hear me say "Emacs is great. It only lacks a good editor."
    they first think that is meant to be a funny remark. It is not. Emacs
    is a great program I use for many tasks but when it comes to quite
    advanced editing tasks I usually save the file, do the complex editing
    in vim, then switch back to Emacs.

    Note that customizing Emacs can help a lot. My favorite setting is:

    (delete-selection-mode t)

    Its effect is that a selection is replaced by the text that is entered
    (or pasted). This is much handier than the original behavior.

    Josef 'Jupp' SCHUGT
    --
    Receiving this message does not necessarily imply that you are
    expected to understand it. If you do not understand it the best
    current practice (BCP) is ignoring it. If you only understand parts
    of it the BCP is ignoring the rest.
     
    Josef 'Jupp' SCHUGT, Aug 29, 2005
    #13
  14. On Tue, 30 Aug 2005 23:37:54 +0900, Christian Neukirchen <> wrote:

    > Josef 'Jupp' SCHUGT <> writes:
    >
    >> When people hear me say "Emacs is great. It only lacks a good editor."
    >> they first think that is meant to be a funny remark. It is not. Emacs
    >> is a great program I use for many tasks but when it comes to quite
    >> advanced editing tasks I usually save the file, do the complex editing
    >> in vim, then switch back to Emacs.

    >
    > Hmm, I'm curious. Can you show me a sample task that made you switch
    > to vim?


    The global command, for example:

    :%g/\[CRON\]/d deletes all (uninteresting) cron entries in my auth.log

    :%g/Customer$/s/\([^ ]*\) \([^ ]*\)/&2, &1/g
    .... give and take a few \ in front of parentheses ...
    exchanges the first and second space delimited word in lines ending with Customer

    Being able to record arbitrary command sequences like (not a real life example)
    df.3j04 p (cut upto and including . and paste the deletion 3 lines down after column 4)

    and of course my favourite vim application: vimoutliner (www.vimoutliner.org)

    all of this without breaking my fingers because of the unlucky positioning of CTRL.

    s.
     
    Stefan Schmiedl, Aug 30, 2005
    #14
  15. On Aug 31, 2005, at 9:20 AM, Christian Neukirchen wrote:

    > "Stefan Schmiedl" <> writes:
    >
    >
    >> On Tue, 30 Aug 2005 23:37:54 +0900, Christian Neukirchen
    >> <> wrote:
    >>
    >>
    >>> Josef 'Jupp' SCHUGT <> writes:
    >>>
    >>>
    >>>> When people hear me say "Emacs is great. It only lacks a good
    >>>> editor."
    >>>> they first think that is meant to be a funny remark. It is not.
    >>>> Emacs
    >>>> is a great program I use for many tasks but when it comes to quite
    >>>> advanced editing tasks I usually save the file, do the complex
    >>>> editing
    >>>> in vim, then switch back to Emacs.
    >>>>
    >>>
    >>> Hmm, I'm curious. Can you show me a sample task that made you
    >>> switch
    >>> to vim?
    >>>

    >>
    >> The global command, for example:
    >>
    >> :%g/\[CRON\]/d deletes all (uninteresting) cron entries in my
    >> auth.log
    >>

    >
    > C-x h M-x flush-lines \[CRON\] RET
    >
    >
    >> :%g/Customer$/s/\([^ ]*\) \([^ ]*\)/&2, &1/g
    >> .... give and take a few \ in front of parentheses ...
    >> exchanges the first and second space delimited word in lines
    >> ending with Customer
    >>

    >
    > M-% ... RET ... !
    >
    >
    >> Being able to record arbitrary command sequences like (not a real
    >> life example)
    >> df.3j04 p (cut upto and including . and paste the deletion 3 lines
    >> down after column 4)
    >>

    >
    > C-x ( M-z . M-3 C-n C-a M-4 C-f C-y C-x )
    >
    > Execute with C-x e as often as you want, or bind it to a key of your
    > choice. (Untested, I just wrote down what I'd intuitively type.)
    >
    >
    >> and of course my favourite vim application: vimoutliner
    >> (www.vimoutliner.org)
    >>

    >
    > Ok, outliners. There are lots of them for Emacs but I admit I don't
    > really like any of them (I prefer org-mode). I know I tried
    > vimoutliner once, but I can't recall how it was... I think I was not
    > too impressed. I use OPML Editor for now when I need outlines.
    >
    >
    >> all of this without breaking my fingers because of the unlucky
    >> positioning of CTRL.
    >>

    >
    > Just curious: How do you leave vim's input mode?
    >
    >


    I'm not the OP, but probably the same way I do, ESC.

    >> s.
    >>

    > --
    > Christian Neukirchen <> http://
    > chneukirchen.org
    >
    >
     
    Logan Capaldo, Aug 31, 2005
    #15
  16. On Wed, 31 Aug 2005 22:20:46 +0900, Christian Neukirchen <> wrote:

    >> The global command, for example:
    >>
    >> :%g/\[CRON\]/d deletes all (uninteresting) cron entries in my auth.log

    >
    > C-x h M-x flush-lines \[CRON\] RET


    vim lets you put any command after the global pattern. How does emacs solve this
    with its interactive parameter queries?

    >
    >> :%g/Customer$/s/\([^ ]*\) \([^ ]*\)/&2, &1/g
    >> .... give and take a few \ in front of parentheses ...
    >> exchanges the first and second space delimited word in lines ending with Customer

    >
    > M-% ... RET ... !


    I don't know enough emacs to see through the dots, but that's not important.

    >
    >> Being able to record arbitrary command sequences like (not a real life example)
    >> df.3j04 p (cut upto and including . and paste the deletion 3 lines down after column 4)

    >
    > C-x ( M-z . M-3 C-n C-a M-4 C-f C-y C-x )


    That's the main difference for me. I just can't remember all those meta/control
    combinations. the vim command maps better to my brain.

    >
    >> all of this without breaking my fingers because of the unlucky
    >> positioning of CTRL.

    >
    > Just curious: How do you leave vim's input mode?


    with a swish of the hand to the ESC button ... don't ask how often
    I hit ESC while I typed this message in Opera ...

    s.
     
    Stefan Schmiedl, Aug 31, 2005
    #16
  17. Joe Van Dyk

    Randy Kramer Guest

    Top posting to say, if you're looking for (or to recommend) an editor and
    you're considering vim or emacs, I'd recommend considering nedit as well.

    In many ways it's almost as powerful as emacs (ignoring the emacs as an OS
    syndrome), including such features as regular expressions, macros, recordable
    keyboard macros (which can be editied to include any macro command or
    construct available), (programmable) syntax highlighting, the possiblity to
    do folding by virtue of macros (the text is, unfortunately, truly folded
    instead of hidden--this may be its biggest weak point), but encased in a much
    more modern GUI with "traditional" (Windows like) menus and keyboard
    shortcuts.

    At a quick glance, I believe that all of the tasks mentioned below can be done
    in nedit (but I might not respond to any challenge to prove it, at least not
    at the moment).

    Randy Kramer

    On Wednesday 31 August 2005 11:01 am, Stefan Schmiedl wrote:
    > On Wed, 31 Aug 2005 22:20:46 +0900, Christian Neukirchen

    <> wrote:
    > >> The global command, for example:
    > >> :%g/\[CRON\]/d deletes all (uninteresting) cron entries in my auth.log

    > >
    > > C-x h M-x flush-lines \[CRON\] RET

    >
    > vim lets you put any command after the global pattern. How does emacs solve
    > this with its interactive parameter queries?
    >
    > >> :%g/Customer$/s/\([^ ]*\) \([^ ]*\)/&2, &1/g
    > >>
    > >> .... give and take a few \ in front of parentheses ...
    > >> exchanges the first and second space delimited word in lines ending with
    > >> Customer

    > >
    > > M-% ... RET ... !

    >
    > I don't know enough emacs to see through the dots, but that's not
    > important.
    >
    > >> Being able to record arbitrary command sequences like (not a real life
    > >> example) df.3j04 p (cut upto and including . and paste the deletion 3
    > >> lines down after column 4)

    > >
    > > C-x ( M-z . M-3 C-n C-a M-4 C-f C-y C-x )

    >
    > That's the main difference for me. I just can't remember all those
    > meta/control combinations. the vim command maps better to my brain.
    >
    > >> all of this without breaking my fingers because of the unlucky
    > >> positioning of CTRL.

    > >
    > > Just curious: How do you leave vim's input mode?

    >
    > with a swish of the hand to the ESC button ... don't ask how often
    > I hit ESC while I typed this message in Opera ...
    >
    > s.
     
    Randy Kramer, Aug 31, 2005
    #17
  18. Christian Neukirchen <> writes:

    > C-x ( and C-x ) define the macro
    > M-z zap to char
    > M-<number> prefix argument
    > C-n next line
    > C-a beginning of line (ok, that doesn't fit)


    Ironically, I think C-a for beginning-of-line is one of the
    best and easiest-to-remember bindings of all time.

    Not only is `A' the first letter of the alphabet, which
    would make a perfectly adequate mnemonic, but the `A' key is
    actually located physically at the beginning of the keyboard
    (on both Dvorak and QWERTY!).

    In my experience, this "spatial mnemonic" enables you to
    wire the C-a binding really deep into muscle memory. YMMV.

    > C-f forward
    > C-y yank


    --
    Daniel Brockman <>
     
    Daniel Brockman, Aug 31, 2005
    #18
  19. Derek Wyatt <> writes:

    > | C-x ( M-z . M-3 C-n C-a M-4 C-f C-y C-x )
    >
    > I hate to say it but, strangely enough, you've just
    > reinforced my decision to switch from emacs. It probably
    > took you at least twice as long to type the example.


    It probably took Stefan even longer to think through what
    commands he needed to include in the macro. I very much
    doubt that raw typing speed is any bottleneck here.

    --
    Daniel Brockman <>
     
    Daniel Brockman, Aug 31, 2005
    #19
  20. Hi --

    On Thu, 1 Sep 2005, Christian Neukirchen wrote:

    > Daniel Brockman <> writes:
    >
    >> Christian Neukirchen <> writes:
    >>
    >>> C-a beginning of line (ok, that doesn't fit)

    >>
    >> Ironically, I think C-a for beginning-of-line is one of the
    >> best and easiest-to-remember bindings of all time.

    >
    > Yeah, it makes sense but there is no direct english word.
    > (in german: Anfang und Ende.)


    Alpha and... end :)


    David

    --
    David A. Black
     
    David A. Black, Aug 31, 2005
    #20
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. tocer
    Replies:
    0
    Views:
    483
    tocer
    Aug 28, 2004
  2. Daniel Folkes

    New to Vim and Vim-Python

    Daniel Folkes, Oct 24, 2007, in forum: Python
    Replies:
    3
    Views:
    550
    projecktzero
    Oct 25, 2007
  3. Guoliang Cao

    vim 6.2 + vim-ruby don't work

    Guoliang Cao, Oct 16, 2003, in forum: Ruby
    Replies:
    1
    Views:
    178
    Brett H. Williams
    Oct 16, 2003
  4. Vincent Foley
    Replies:
    6
    Views:
    156
    Gavin Sinclair
    Apr 10, 2006
  5. lolveley
    Replies:
    3
    Views:
    218
Loading...

Share This Page