
Readline in Vim's Insert Mode - resonator
https://github.com/jonhiggs/vim-readline
======
thristian
> _Why am I always exiting from insert mode? Because I don 't know the insert
> modes special keys._ > _Why are those special keys so different from
> Readline?_

You were doing it right the first time. Vim's "insert mode special keys" are
basically incredibly basic terminal controls that are the same as Readline
anyway (like backspace, or ^U to delete to the beginning of the line), or
incredibly obscure things like inserting the contents of a specific register.
Vim doesn't expect you to move the cursor much in insert mode, it's just for
typing.

As it turns out, the extra Readline bindings this emulates are basically
emulating Emacs' standard bindings, so if you want those bindings in an
editor, you know where to look.

Personally, I just stick these settings in ~/.inputrc:

    
    
        set editing-mode vi
        set keymap vi
    

...and then every application that uses Readline (including bash, the Python
REPL, the PostgreSQL REPL, and a bunch of other things) defaults to vi
keybindings. It's dreamy.

~~~
randomanybody
have you ever found a solution to make readline change cursor shape depending
on mode? not knowing the mode before typing keeps me from turning this on,
even though I prefer vi bindings.

~~~
calid
You can do something similar using the show-mode-in-prompt option:

    
    
      show-mode-in-prompt
        If set to `on', add a character to the beginning of the prompt indicating
        the editing mode: emacs (`@'), vi command (`:'), or vi insertion (`+').
        The default value is `off'.
    

Unfortunately it's currently hardcoded to only use the '+' and ':' chars, and
to only display at the beginning of the prompt.

Chet accepted a patch I submitted for custom indicators, and this will be
coming in bash 4.4/readline 7.0:
[http://thread.gmane.org/gmane.comp.shells.bash.bugs/22580/fo...](http://thread.gmane.org/gmane.comp.shells.bash.bugs/22580/focus=22613)

I have patched versions of bash 4.3/readline 6.3 available on github (the bash
page has gifs showing the functionality in action):
[https://github.com/calid/bash](https://github.com/calid/bash)
[https://github.com/calid/readline](https://github.com/calid/readline)

Note that the '\m' escape hasn't been accepted into the mainline yet, so as of
now the custom indicators will still only display at the beginning of the
prompt in the new versions.

------
bluemenot
Counterargument: It might disrupt your flow and make undos and using the dot
more difficult.

There is an [episode of vimcasts]([http://vimcasts.org/episodes/modal-editing-
undo-redo-and-rep...](http://vimcasts.org/episodes/modal-editing-undo-redo-
and-repeat/)) which compares editing in vim's insert mode to making a brush
stroke in a graphics program. With this plugin one must be careful not to make
the brush strokes too long.

~~~
agumonkey
Very interesting analogy. Many 3D modeling programs had undos based on clean
abstractions (history of transformation matrices for object P/O/S, stack of
operators to influence geometry) but it often broke when you go below. Houdini
(one that was fairly dogmatic about being 'procedural') had to reify
vertices/edges modification as an Edit node in its object graph to stay
coherent without losing information (or making it a second class citizen).

------
devnonymous
No ! just say no ! Don't do it ! This repo is created by an emacs lovers who
pretends to use vim and then creates subversive plugins just so that they can
spread confusion, fear and chaos among vim users !!

:-)

Ah, well, whatever peels your banana...

~~~
aaronem
> confusion, fear and chaos among vim users

What, more than usual? How could you even tell?

------
Muska17
There is already a plugin that does the job pretty fine : tpope/vim-rsi

~~~
groovy2shoes
vim-rsi... Readline-Style Insertion or Repetitive Strain Injury?

~~~
krisdol
Tomato tomato

