[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Equivalent of vim's o or O commands

From: Jason Earl
Subject: Re: Equivalent of vim's o or O commands
Date: Tue, 05 Feb 2008 17:49:58 -0700
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux)

Brian Adkins <address@hidden> writes:

> On Feb 5, 2:22 pm, Brian Adkins <address@hidden> 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.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]