One feature of emacs buffers (even ansi-term
, shell
, and eshell
) that I really like is the ability of C-l
to "center" the current line in the terminal so that the top half of the screen still contains some of the previous output.
It seems like a standard (not sure what the name of the standard is) terminal will move the current line to the top of the window when C-l
is pressed. Is there a general way to move the current line to the center of the screen? If not, is there a way to do this specifically for iterm2, terminal, or some terminal emulator that has been ported to OS X?
Best Answer
Most terminal emulators can "do" this, but it takes some work:
That only moves the line up. You can move a line down, similarly, using "reverse indexing". These operations by the way are not in the standard ECMA-48, but are in anything like xterm (based on DEC vt100).
ansi-term
supports scrolling/indexing.Finally, that's just up or down. To move a line left/right, you would send escape sequences for inserting or deleting characters while the cursor is at the beginning of the line.
These escape sequences are documented in the
terminfo(5)
manual page. I've mentioned these:csr
(set scrolling region)ind
(index)rin
(reverse-index)cup
(cursor-position)ich
(insert character)dch
(delete character)Further reading: