I have a bunch of lines of text and I'm trying to insert text starting at a certain column on each line. For example:
'Some text' This is ok
'Another longer text' ask Ram
'weird stuff' see other file
'more lines'
'even more lines'
I'd like to continue typing text on the further lines, at the same column as the previous lines. The part that's cumbersome is moving to the right place on each line.
Emacs has a way of moving to the same place on each line: set-goal-column
. This would work if that column already existed on each line, but that's not the case here.
One way I can work around this (which I'm actually using) is to insert a lot of spaces on each line (replace-regexp $ with a few dozen spaces), then C-x C-n (set-goal-column
), and use regular C-n to move between lines. But I'd like to know whether there's a clean way of achieving something better: of setting things up so that after set-goal-column
, I can just use C-n to move to the next line, and Emacs will automatically insert the appropriate number of spaces if there weren't enough columns to start with.
artist-mode
source code for inspiration for how to approach this without introducing permanent whitespace unnecessarily... – phils Oct 19 '17 at 2:17(when goal-column (move-to-column goal-column t))
– phils Oct 19 '17 at 2:19line-move-to-column
is what ultimately carries out the normal behaviour. – phils Oct 19 '17 at 2:26line-move-to-column
etc), I think I need to changeline-move-to-column
which does(move-to-column col)
to do(move-to-column col t)
instead. Or maybe(when goal-column (move-to-column goal-column t))
as you suggested. Can you post that as an answer, along with how to “modify”line-move-to-column
? – ShreevatsaR Oct 19 '17 at 2:31