Menu

#125 Document bash vi bind mapping

closed
nobody
2015-02-13
2015-02-13
Anonymous
No

Originally created by: grugnog
Originally owned by: dvorka

It took me a few minutes to figure these out, and I suspect this may be useful to others:

bind '"\C-r": "\e^ihh \n"'

For the curious, \e is an escape, ^ to go to start of line, i to reenter insert mode and \n to execute the command. Perhaps there is a snazzier way of doing this, but it seems to work for me, so far.

Discussion

  • Anonymous

    Anonymous - 2015-02-13

    Originally posted by: livibetter

    I have only used Emacs mode in Bash even I am a Vim user. The configuration might just need a line or two, but hh --show-configuration would need more, here is what I've tried, first time using readline's $if:

    if [[ $- =~ .*i.* ]]; then bind <<EOF
    $if mode=emacs
    "\C-r": "\C-a hh \C-j"'
    $else
    "\C-r": "\e^ihh \n"
    $endif
    EOF
    fi
    

    Doesn't look clean, maybe bind -v | grep 'set keymap emacs'?

     
  • Anonymous

    Anonymous - 2015-02-13

    Originally posted by: dvorka

    Thank you @grugnog - I added the binding to MD documentation and man page. @livibetter I appreciate you suggestion, however, it would probably make default configuration too complicated - I added a hint to the default configuration produced by hh -s and enriched MD documentation.

     
  • Anonymous

    Anonymous - 2015-02-13

    Ticket changed by: dvorka

    • status: open --> closed
     
  • Anonymous

    Anonymous - 2015-02-13

    Originally posted by: dvorka

    ... @livibetter I changed (slightly ;) my mind - hh will produce default configuration as you suggested, but I will do that in time of running hh -s (i.e. in C) and not in the produced script. I will be optimistic in a sense that user made Emacs vs. Vi choice and wont change it. It's better than nothing and slightly worse than what you suggested. I created [#126] enhancement.

     

    Related

    Tickets: #126


Log in to post a comment.