unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Equivalent of vim's o or O commands
@ 2008-02-05 19:22 Brian Adkins
  2008-02-05 19:47 ` Brian Adkins
  0 siblings, 1 reply; 9+ messages in thread
From: Brian Adkins @ 2008-02-05 19:22 UTC (permalink / raw)
  To: help-gnu-emacs

I would like to have the equivalent of vim's o or O commands in emacs.
The o command will open a new line below the cursor and position the
cursor properly indented (if autoindent is on). The O command does the
same but opens the line above the cursor.

In emacs, C-o will open a line above the cursor if the cursor is at
the beginning of the line (but won't properly indent), but splits the
line if the cursor is within some text.

This is such a common operation for me, that I would like to bind it
to a simple combination instead of requiring C-e C-j.

I failed to find a good "emacs for vim users" reference on Google.
There are some partial ones that are helpful, but I would like a more
complete reference as I consider transitioning from vim to emacs. If
anyone knows of one, I'd appreciate a link.

Thanks,
Brian Adkins


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Equivalent of vim's o or O commands
  2008-02-05 19:22 Equivalent of vim's o or O commands Brian Adkins
@ 2008-02-05 19:47 ` Brian Adkins
  2008-02-06  0:49   ` Jason Earl
  0 siblings, 1 reply; 9+ messages in thread
From: Brian Adkins @ 2008-02-05 19:47 UTC (permalink / raw)
  To: help-gnu-emacs

On Feb 5, 2:22 pm, Brian Adkins <lojicdot...@gmail.com> wrote:
> I would like to have the equivalent of vim's o or O commands in emacs.
> The o command will open a new line below the cursor and position the
> cursor properly indented (if autoindent is on). The O command does the
> same but opens the line above the cursor.
>
> In emacs, C-o will open a line above the cursor if the cursor is at
> the beginning of the line (but won't properly indent), but splits the
> line if the cursor is within some text.
>
> This is such a common operation for me, that I would like to bind it
> to a simple combination instead of requiring C-e C-j.
>
> I failed to find a good "emacs for vim users" reference on Google.
> There are some partial ones that are helpful, but I would like a more
> complete reference as I consider transitioning from vim to emacs. If
> anyone knows of one, I'd appreciate a link.
>
> Thanks,
> Brian Adkins

I should have searched the group archives first. I found a
satisfactory solution from a 2002 posting :)

(defun bja-open-line-below ()
  (interactive)
  (end-of-line)
  (open-line 1)
  (next-line 1)
  (indent-according-to-mode))

(defun bja-open-line-above ()
  (interactive)
  (beginning-of-line)
  (open-line 1)
  (indent-according-to-mode))

(global-set-key [?\C-o] 'bja-open-line-below)
(global-set-key [?\M-o] 'bja-open-line-above)

Being able to customize emacs with elisp is one of the main reasons
I'm considering a switch (that and being able to use emacs/slime for
Lisp programming).

Brian


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Equivalent of vim's o or O commands
  2008-02-05 19:47 ` Brian Adkins
@ 2008-02-06  0:49   ` Jason Earl
  2008-02-06 22:07     ` Brian Adkins
  0 siblings, 1 reply; 9+ messages in thread
From: Jason Earl @ 2008-02-06  0:49 UTC (permalink / raw)
  To: help-gnu-emacs

Brian Adkins <lojicdotcom@gmail.com> writes:

> On Feb 5, 2:22 pm, Brian Adkins <lojicdot...@gmail.com> wrote:
>> I would like to have the equivalent of vim's o or O commands in emacs.
>> The o command will open a new line below the cursor and position the
>> cursor properly indented (if autoindent is on). The O command does the
>> same but opens the line above the cursor.
>>
>> In emacs, C-o will open a line above the cursor if the cursor is at
>> the beginning of the line (but won't properly indent), but splits the
>> line if the cursor is within some text.
>>
>> This is such a common operation for me, that I would like to bind it
>> to a simple combination instead of requiring C-e C-j.
>>
>> I failed to find a good "emacs for vim users" reference on Google.
>> There are some partial ones that are helpful, but I would like a more
>> complete reference as I consider transitioning from vim to emacs. If
>> anyone knows of one, I'd appreciate a link.
>>
>> Thanks,
>> Brian Adkins
>
> I should have searched the group archives first. I found a
> satisfactory solution from a 2002 posting :)
>
> (defun bja-open-line-below ()
>   (interactive)
>   (end-of-line)
>   (open-line 1)
>   (next-line 1)
>   (indent-according-to-mode))
>
> (defun bja-open-line-above ()
>   (interactive)
>   (beginning-of-line)
>   (open-line 1)
>   (indent-according-to-mode))
>
> (global-set-key [?\C-o] 'bja-open-line-below)
> (global-set-key [?\M-o] 'bja-open-line-above)
>
> Being able to customize emacs with elisp is one of the main reasons
> I'm considering a switch (that and being able to use emacs/slime for
> Lisp programming).
>
> Brian

One of the things that you might consider trying is viper-mode.  That
way you don't have to give up your typist friendly keystrokes just to
use Emacs' lisp-scriptable goodness.

Jason


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Equivalent of vim's o or O commands
  2008-02-06  0:49   ` Jason Earl
@ 2008-02-06 22:07     ` Brian Adkins
  2008-02-06 22:45       ` Lennart Borgman (gmail)
       [not found]       ` <mailman.7061.1202337917.18990.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 9+ messages in thread
From: Brian Adkins @ 2008-02-06 22:07 UTC (permalink / raw)
  To: help-gnu-emacs

On Feb 5, 7:49 pm, Jason Earl <je...@xmission.com> wrote:
> Brian Adkins <lojicdot...@gmail.com> writes:
> > On Feb 5, 2:22 pm, Brian Adkins <lojicdot...@gmail.com> wrote:
> >> I would like to have the equivalent of vim's o or O commands in emacs.
> >> The o command will open a new line below the cursor and position the
> >> cursor properly indented (if autoindent is on). The O command does the
> >> same but opens the line above the cursor.
>
> >> In emacs, C-o will open a line above the cursor if the cursor is at
> >> the beginning of the line (but won't properly indent), but splits the
> >> line if the cursor is within some text.
>
> >> This is such a common operation for me, that I would like to bind it
> >> to a simple combination instead of requiring C-e C-j.
>
> >> I failed to find a good "emacs for vim users" reference on Google.
> >> There are some partial ones that are helpful, but I would like a more
> >> complete reference as I consider transitioning from vim to emacs. If
> >> anyone knows of one, I'd appreciate a link.
>
> >> Thanks,
> >> Brian Adkins
>
> > I should have searched the group archives first. I found a
> > satisfactory solution from a 2002 posting :)
>
> > (defun bja-open-line-below ()
> >   (interactive)
> >   (end-of-line)
> >   (open-line 1)
> >   (next-line 1)
> >   (indent-according-to-mode))
>
> > (defun bja-open-line-above ()
> >   (interactive)
> >   (beginning-of-line)
> >   (open-line 1)
> >   (indent-according-to-mode))
>
> > (global-set-key [?\C-o] 'bja-open-line-below)
> > (global-set-key [?\M-o] 'bja-open-line-above)
>
> > Being able to customize emacs with elisp is one of the main reasons
> > I'm considering a switch (that and being able to use emacs/slime for
> > Lisp programming).
>
> > Brian
>
> One of the things that you might consider trying is viper-mode.  That
> way you don't have to give up your typist friendly keystrokes just to
> use Emacs' lisp-scriptable goodness.
>
> Jason

Thanks. I did try viper mode briefly, but it seemed nothing like vim
(maybe it's more similar to vi), so I gave up on it.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Equivalent of vim's o or O commands
  2008-02-06 22:07     ` Brian Adkins
@ 2008-02-06 22:45       ` Lennart Borgman (gmail)
       [not found]       ` <mailman.7061.1202337917.18990.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 9+ messages in thread
From: Lennart Borgman (gmail) @ 2008-02-06 22:45 UTC (permalink / raw)
  To: Brian Adkins; +Cc: help-gnu-emacs

Brian Adkins wrote:
>> One of the things that you might consider trying is viper-mode.  That
>> way you don't have to give up your typist friendly keystrokes just to
>> use Emacs' lisp-scriptable goodness.
>>
>> Jason
> 
> Thanks. I did try viper mode briefly, but it seemed nothing like vim
> (maybe it's more similar to vi), so I gave up on it.

Did you try this:

   http://www.emacswiki.org/cgi-bin/wiki/vimpulse.el

If you try it please let us know what you think.




^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Equivalent of vim's o or O commands
       [not found]       ` <mailman.7061.1202337917.18990.help-gnu-emacs@gnu.org>
@ 2008-02-07 20:44         ` Brian Adkins
  2008-02-07 22:06           ` Samuel Karl Peterson
  0 siblings, 1 reply; 9+ messages in thread
From: Brian Adkins @ 2008-02-07 20:44 UTC (permalink / raw)
  To: help-gnu-emacs

On Feb 6, 5:45 pm, "Lennart Borgman (gmail)"
<lennart.borg...@gmail.com> wrote:
> Brian Adkins wrote:
> >> One of the things that you might consider trying is viper-mode.  That
> >> way you don't have to give up your typist friendly keystrokes just to
> >> use Emacs' lisp-scriptable goodness.
>
> >> Jason
>
> > Thanks. I did try viper mode briefly, but it seemed nothing like vim
> > (maybe it's more similar to vi), so I gave up on it.
>
> Did you try this:
>
>    http://www.emacswiki.org/cgi-bin/wiki/vimpulse.el
>
> If you try it please let us know what you think.

My first attempt didn't go so well. I chose viper level 5.

1) V did not put me into line visual mode, instead it attempted to
"Find file in other window".

2) v did not put me into visual mode, instead it attempted to "Find
file"

3) Neither C-c nor C-[ took me out of insert mode back to normal mode.
There's no way I'm reaching for ESC each time.

So, that's pretty much a deal breaker, unfortunately.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Equivalent of vim's o or O commands
  2008-02-07 20:44         ` Brian Adkins
@ 2008-02-07 22:06           ` Samuel Karl Peterson
  2008-02-07 23:14             ` Lennart Borgman (gmail)
       [not found]             ` <mailman.7125.1202426051.18990.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 9+ messages in thread
From: Samuel Karl Peterson @ 2008-02-07 22:06 UTC (permalink / raw)
  To: help-gnu-emacs

Brian Adkins <lojicdotcom@gmail.com> on Thu, 7 Feb 2008 12:44:17 -0800
(PST) didst step forth and proclaim thus:

> My first attempt didn't go so well. I chose viper level 5.
>
> 1) V did not put me into line visual mode, instead it attempted to
> "Find file in other window".
>
> 2) v did not put me into visual mode, instead it attempted to "Find
> file"
>
> 3) Neither C-c nor C-[ took me out of insert mode back to normal mode.
> There's no way I'm reaching for ESC each time.

If you run Emacs in a terminal window (emacs -nw), C-[ should work for
esc.  C-c works in lower levels (though not in ex).

Viper emulates system V vi, not vim, and incompletely at that.  Things
like :set nu don't work.  vimpulse.el seems to be all the rage these
days.

-- 
Sam Peterson
skpeterson At nospam ucdavis.edu
"if programmers were paid to remove code instead of adding it,
software would be much better" -- unknown


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Equivalent of vim's o or O commands
  2008-02-07 22:06           ` Samuel Karl Peterson
@ 2008-02-07 23:14             ` Lennart Borgman (gmail)
       [not found]             ` <mailman.7125.1202426051.18990.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 9+ messages in thread
From: Lennart Borgman (gmail) @ 2008-02-07 23:14 UTC (permalink / raw)
  Cc: help-gnu-emacs, jasonspiro3

Samuel Karl Peterson wrote:
> Brian Adkins <lojicdotcom@gmail.com> on Thu, 7 Feb 2008 12:44:17 -0800
> (PST) didst step forth and proclaim thus:
> 
>> My first attempt didn't go so well. I chose viper level 5.
>>
>> 1) V did not put me into line visual mode, instead it attempted to
>> "Find file in other window".
>>
>> 2) v did not put me into visual mode, instead it attempted to "Find
>> file"

Looks like there is something called viper-visual-mode in vimpulse.el. I 
wonder why that does not work?

>> 3) Neither C-c nor C-[ took me out of insert mode back to normal mode.
>> There's no way I'm reaching for ESC each time.
> 
> If you run Emacs in a terminal window (emacs -nw), C-[ should work for
> esc.  C-c works in lower levels (though not in ex).
> 
> Viper emulates system V vi, not vim, and incompletely at that.  Things
> like :set nu don't work.  vimpulse.el seems to be all the rage these
> days.
> 




^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Equivalent of vim's o or O commands
       [not found]             ` <mailman.7125.1202426051.18990.help-gnu-emacs@gnu.org>
@ 2008-02-09 11:11               ` Fabian Braennstroem
  0 siblings, 0 replies; 9+ messages in thread
From: Fabian Braennstroem @ 2008-02-09 11:11 UTC (permalink / raw)
  To: help-gnu-emacs

Hi,

viper in combination with vimpulse works great for me. The 
visual marking works well, except the rectangular marking, 
but I can get along with cua for these cases. Obviously, you 
won't have every vim command, but  in combination with the 
power of emacs you can have most of it or even more.  Once 
you got used to some annoying stuff in the visual mode 
(marking to the end of the line stops at the last character) 
it is great :-)

Regards!
Fabian

Lennart Borgman (gmail) schrieb am 02/07/2008 11:14 PM:
> Samuel Karl Peterson wrote:
>> Brian Adkins <lojicdotcom@gmail.com> on Thu, 7 Feb 2008 12:44:17 -0800
>> (PST) didst step forth and proclaim thus:
>>
>>> My first attempt didn't go so well. I chose viper level 5.
>>>
>>> 1) V did not put me into line visual mode, instead it attempted to
>>> "Find file in other window".
>>>
>>> 2) v did not put me into visual mode, instead it attempted to "Find
>>> file"
> 
> Looks like there is something called viper-visual-mode in vimpulse.el. I 
> wonder why that does not work?
> 
>>> 3) Neither C-c nor C-[ took me out of insert mode back to normal mode.
>>> There's no way I'm reaching for ESC each time.
>> If you run Emacs in a terminal window (emacs -nw), C-[ should work for
>> esc.  C-c works in lower levels (though not in ex).
>>
>> Viper emulates system V vi, not vim, and incompletely at that.  Things
>> like :set nu don't work.  vimpulse.el seems to be all the rage these
>> days.
>>
> 
> 


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2008-02-09 11:11 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-02-05 19:22 Equivalent of vim's o or O commands Brian Adkins
2008-02-05 19:47 ` Brian Adkins
2008-02-06  0:49   ` Jason Earl
2008-02-06 22:07     ` Brian Adkins
2008-02-06 22:45       ` Lennart Borgman (gmail)
     [not found]       ` <mailman.7061.1202337917.18990.help-gnu-emacs@gnu.org>
2008-02-07 20:44         ` Brian Adkins
2008-02-07 22:06           ` Samuel Karl Peterson
2008-02-07 23:14             ` Lennart Borgman (gmail)
     [not found]             ` <mailman.7125.1202426051.18990.help-gnu-emacs@gnu.org>
2008-02-09 11:11               ` Fabian Braennstroem

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).