Emacs: keep cursor column automatically when move up/down (add spaces if required)
Imagine I'm editing this text:
this is my long line|
this is my other long line
How can I keep cursor on current column when moving up and down (this is common behavour for many text editors)?
Like in picture-mode but without other features (for example when C-e is pressing cursor should be moved to the actual end of line)
PS This question looks like duplicate to others but probably isn't.
Upd1: The artist-mode and picture-mode has problems:
add extra spaces when I move cursor beyond the end-of-line (and document became to be "modified". Not cool)
C-e actually not moves cursor to the end of line
cursor movement works with surprices in visual-line-mode (for example not moved to the "previous "part" of the long line
Upd2: set-goal-column is cool but not understood which way it could be used. I just want to move cursor visually down from current column position where cursor is.
Here an answer near to request. It doesn't insert spaces just to reach a certain column - may you tell a use-case for this?
(defvar ar-move-line-this-column nil) (defun ar-move-line-keep-column-intern (arg) (unless (eq last-command this-command) (setq ar-move-line-this-column (current-column))) (forward-line arg) (while (and (not (eolp)) (< (current-column) ar-move-line-this-column)) (forward-char 1))) (defun ar-forward-line-keep-column (&optional arg) "Go to current column of next line. If line is shorter, go to end of line" (interactive "p") (ar-move-line-keep-column-intern (or arg 1))) (defun ar-backward-line-keep-column (&optional arg) "Go to current column of line above. If line is shorter, go to end of line" (interactive "p") (ar-move-line-keep-column-intern (- arg)))
Move to goal-column inserting spaces if necessary, sign up log in automatically insert the appropriate number of spaces if there weren't enough (when goal-column (move-to-column goal-column t))) (advice-add the cursor and typeing M-+ ;; Then move to another line and type M-=, of text without tabs. ;; tab-column is a silly name; I need a better one. While editing a simple text file where every line is nearly to the end of screen, I was expecting vim to retain the column position as I used j and k to move up and down. Surprisingly, it does not
set-goal-column, bound to C-x C-n will set the current column as the target column when moving up or down.
You can cancel this feature with a prefix argument C-u C-x C-n.
GNU Emacs Manual, Here is advice that should do what you want: (defun goal-column-advice (&rest _args) "Advice inserting spaces when needed to obey Typing DEL when the cursor is at the beginning of a line deletes the preceding newline, thus joining the line with the preceding line. Emacs can split lines automatically when they become too long, if you turn on a special minor mode called Auto Fill mode. See section Filling Text, for how to use Auto Fill mode.
Mac OS X Tiger in a Nutshell: A Desktop Quick Reference, Scrolling means moving text up or down in the window so that different parts of Scrolling happens automatically if you move point past the bottom or top of the Some users like the full-screen scroll commands to keep point at the same With a positive argument n , it repositions text to put point n lines down from the top. How to control cell cursor in Excel Once the new window opens up, move to the "Advanced" tab in it. Move to the "Editing" options section and under the "After pressing Enter, move selection
The quarter-plane-mode was also suggested as close solution
The Termcap Library, Action Place cursor and mark around whole paragraph. in when the file was last saved (or auto-saved). Save file. (If terminal hangs, C-q restarts.) Exit Emacs. Excel up and down arrow keys move page instead of cell Updated: 11/16/2019 by Computer Hope When the scroll lock feature is turned on, pressing an arrow key causes Microsoft Excel to move the entire spreadsheet in that direction, instead of moving to the next cell .
Open Source Messaging Application Development: Building and , For example, the `rp' capability is a command that requires two parameters; a space erases a character position even if the terminal supports overstriking. `up': String of commands to move the cursor vertically up one line. Some terminals wrap automatically when a graphic character is output in the last column, while You can use the arrow keys or C-p/C-n to move up and down between candidates. You can also use C-<down> and C-<up>; as you move the selection between tags inside the Helm Semantic buffer, the point moves between tag locations as well.
GNU Emacs Manual, vi also allows you to navigate the file with cursor keys, but most people the keys shown in first four rows of Table 3-6 so that you can keep your hands in place. Like Emacs, vican navigate through a file more than one character at a time. left one column. j Moves the cursor down one line. k Moves the cursor up one line. l Take note, the cursor may skip or jump while you are using it or even when you might be just typing and not using the cursor at all. One may find this to be quite annoying both at the time of
Moving Point, If the text in the buffer is `FOOBAR' , with the cursor before the `B' , then if you type If you need to insert a control character or a character whose code is above 200 It counts screen lines down from the top of the window (zero for the top line). Henceforth, those commands always move to this column in each line moved Typing DEL when the cursor is at the beginning of a line deletes the preceding newline, thus joining the line with the preceding line. Emacs can split lines automatically when they become too long, if you turn on a special minor mode called Auto Fill mode. See section Filling Text, for how to use Auto Fill mode.