A common use-case that I have is to add a string to the same position of each line of text.
For example, I might start with
expect(one).toEqual(true); expect(two).toEqual(false); which I want to transform into
expect(oneValue).toEqual(true); expect(twoValue).toEqual(false); What I currently do is:
- place my cursor after
one - press
C-x <SPC>(invokingrectangle-mark-mode) - press
C-nto extend the zero-width rectangle down one row - (look up the keystrokes and then) press
C-x r t Value <RET>to invokestring-rectangle, thereby adding the stringValueto the desired locations
I would like to simply start typing after selecting a rectangle with rectangle-mark-mode, and the rectangular selection would be interactively replaced with what I'm typing (including the case where I've marked a zero-width rectangle). In other words, I want to eliminate the C-x r t step above and just start typing Value immediately. How can I accomplish this?
I'm also curious why this isn't the default behavior of Emacs, since I can't think of a disadvantage to this approach.
C-x r truns a command,V,a,l,uandeall run a command as well. You have to teach Emacs what's the mean of "start typing".string-rectanglelong pre-datesrectangle-mark-mode-- you can save yourself a keystroke by usingC-SPCrather thanC-x SPC.