Elisp: Move Cursor
Move Cursor to a Position
goto-char
-
(goto-char POSITION)
Move cursor to a given position.
;; move cursor to position 392 (goto-char 392)
Move by Char Count, by Word
forward-char
-
(forward-char &optional N)
Move cursor forward by N characters.
see also
backward-char
;; move cursor by 9 chars (forward-char 9)
forward-word
backward-word
Move by Line
forward-line
beginning-of-line
end-of-line
Move Cursor by Skip Chars
skip-chars-forward
-
(skip-chars-forward STRING &optional maxPos)
- Move cursor forward by skipping chars in STRING.
- but do not go beyond maxPos
- Returns the distance traveled, either zero or positive.
STRING is like the inside of a
[chars]
in a Regular Expression Syntax except that]
is never special and\
quotes^
,-
or\
;; move cursor, by skipping whitespace (skip-chars-forward " \n\t") ;; mover cursor, by skipping alphanumeric and hyphen lowline (skip-chars-forward "-_a-zA-Z0-9")
skip-chars-backward
-
(skip-chars-backward STRING &optional LIM)
similar to
skip-chars-forward
but backward.;; move cursor backward, skip space tab newline (skip-chars-backward " \t\n")
;; skip a to z and hyphen (skip-chars-backward "-a-z")
Move Cursor by Search Text
These search functions are used for searchinng text and find replace, but they also move cursor and return cursor position:
search-forward
•search-backward
re-search-forward
•re-search-backward
(using regex)
Reference
Elisp, text processing functions
- Elisp: Cursor Position Functions
- Elisp: Move Cursor
- Elisp: Text Editing Functions
- Elisp: Search Text
- Elisp: Find Replace Text in Buffer
- Elisp: Mark, Region, Active Region
- Elisp: Cut Copy Paste, kill-ring
- Elisp: Get Buffer String
- Elisp: Functions on Line
- Elisp: thing-at-point
- Elisp: Get Text Block 🚀
- Elisp: Save narrow-to-region