views:

880

answers:

2

I'm very fond of vim and really would like to enhance my bash experience with vi-mode. However one thing I'm so accustomed to the emacs behavior in that, when browsing the shell history with cursor up/down, the cursor is positioned at the end of the line.

In vi-mode it's the other way around; the cursor is always positioned at the beginning of the line. It's really burned in the brain to expect the cursor at the end, having used bash in emacs mode for ... way too long.

Any chance to get the cursor position by default at the end of the line in bash vi-mode when browsing through the shell history?

+4  A: 

I don't know of a way of doing this short of re-coding the history code inside of bash (or readline, really).

However, is it really so hard to enter Shift-A once you've found your line to start appending at the end?

If you're going to ditch emacs mode then, at some point, you're going to have to do it totally and accept the vi way of doing things. Join us, you know you want to :-)

paxdiablo
It is hard, yes, because observing my behavior, I'm very often extending existing commands at the *end*; so apart from my habit it also seems quite logical to me. Also the fact that when using history, you're automatically in edit-mode but at the start of the line is weird; so currently I need `ESC Shift-A` but somehow typing this sequence quickly swallows the shift and I end up inserting after the first character :-( I'm using putty from WXP to Linux, 100% of my time.
mark
You shouldn't need ESC since it should be in command mode, at least in every setup I've seen. How are you bringing up the command, ESC-k or the arrow keys?
paxdiablo
Arrows, cursor keys, like the subjects says. I see it is different with ESC-k because it's in command mode then. Helps with this problem, j/k is quite natural for me to use. Still leaves the cursor start/end thing open ... but thanks!
mark
The ESC is a more powerful way to use it since you can do stuff like <ESC>/find<ENTER> to get the last 'find' command and n to continue the search. ESC-k is just a quick way to get last command, it's the ESC itself that puts you in vi mode, with a near-full repertoire of vi commands available.
paxdiablo
+2  A: 
Pianosaurus