Petro | 28 May 2012 15:22
Picon

insert a symbol

Hi all.
Is there a way to insert one symbol without entering into insert mode?
I find it unconvenient to push "i <symbol> C-[" to insert one letter. 
Thanks.
Petro.
Michael Markert | 28 May 2012 15:33
Gravatar

Re: insert a symbol

On Mon, May 28 2012 (15:22), Petro <khoroshyy <at> gmail.com> wrote: 

> Is there a way to insert one symbol without entering into insert mode?
> I find it unconvenient to push "i <symbol> C-[" to insert one letter. 

\ <symbol>

\ is bound to evil-execute-in-emacs-state that executes the following
key chord in emacs state.

That's not insert state so be aware of changed keybindings.

But it's quite easy to derive an `execute-in-insert-state` from its
code.

Michael
_______________________________________________
implementations-list mailing list
implementations-list <at> lists.ourproject.org
https://lists.ourproject.org/cgi-bin/mailman/listinfo/implementations-list
Vegard Øye | 28 May 2012 15:57
Picon
Favicon

Re: insert a symbol

On 2012-05-28 15:22 +0200, Petro wrote:

> Is there a way to insert one symbol without entering into insert mode?
> I find it unconvenient to push "i <symbol> C-[" to insert one letter.

As Michael pointed out, you can use "\" to escape to Emacs state for
the duration of one command. Thus, "\e" inserts the letter "e" and
then returns to Normal state.

The following Vim tip suggests to bind a character-insertion command
to "SPC":

    http://vim.wikia.com/wiki/Insert_a_single_character

If you would rather type "SPC <symbol>" instead of "\ <symbol>", then
you can rebind "SPC". By typing "C-h k \", we see that "\" is bound to
the command `evil-execute-in-emacs-state'. Thus, the following binds
it to "SPC":

    (define-key evil-normal-state-map " " 'evil-execute-in-emacs-state)

Then you can follow the Vim tip to set up similar behavior in Vim,
if you use both editors.

--

-- 
Vegard
York Zhao | 29 May 2012 17:41
Picon

Re: insert a symbol

"\ <char>" is a good tip for inputing one char without entering insert mode,
however, it is not dot repeatable. I used to have my own function bound to SPC
to insert one char and was repeatable, but I'm now binding SPC to ace-jump which
I found to be even more useful. Is it possible to make "\<command>" repeatable?

Thanks,
York
Frank Fischer | 30 May 2012 09:57
Picon

Re: insert a symbol

You guys always find strange situations I've never thought off ... ;)

On Tue, May 29, 2012 at 11:41:32AM -0400, York Zhao wrote:
> "\ <char>" is a good tip for inputing one char without entering insert mode,
> however, it is not dot repeatable. I used to have my own function bound to SPC
> to insert one char and was repeatable, but I'm now binding SPC to ace-jump which
> I found to be even more useful. Is it possible to make "\<command>" repeatable?

No, not easily. There are two reasons for this. The first one is that
Emacs state is not repeatable by intention. When Evil switches to
Emacs state, then evil is essentially turned off (as far as it could
be). This means the repeat system ignores all commands in Emacs state
completely. That's because Emacs state is, well, plain Emacs, and it
is very difficult to do repeat-recording right if there is no
distinction between different states like normal state and insert
state. Furthermore almost all commands active in Emacs state are
non-Evil commands, which makes it even more difficult (they usually do
not carry appropriate :repeat attributes). Furthermore the one-shot
Emacs state, i.e., the command `evil-execute-in-emacs-state',
essentially simply switches to Emacs state and installs a
post-command-hook that returns to the previous state after the next
command. So there is no easy way for the repeat system to distinguish
the one-shot emacs state from the "real" emacs state.

The second problem is that the repeat system relies on
post-command-hook, too, in this interferes easily with the
post-command-hook of `evil-execute-in-emacs-state'.

A compromise could be to use insert-state instead of emacs-state. Both
states are almost equivalent except for the repeat-recording and a few
(Continue reading)

York Zhao | 30 May 2012 16:48
Picon

Re: insert a symbol

Thanks for the extremely detailed explanation Frank. I actually didn't think too
much about this but I was sure it wouldn't be easy.

And thanks for your creative ideas.

Gmane