Skip to main content
OverflowAI is here! AI power for your Stack Overflow for Teams knowledge community. Learn more

Questions tagged [motion]

is for moving the cursor around the buffer. Emacs provides key-bindings for alternative ways of moving the cursor interactively: by syntactical elements such as characters and words; by forward and backward searches; by arbitrary lines; by units such as sentences, paragraphs, and s-expressions; and by other methods unique to certain modes.

Filter by
Sorted by
Tagged with
0 votes
1 answer
48 views

Spacemacs kept repositioning the cursor when there's unmatched parenthesis

I'm new to Emacs, and there's one thing I don't understand. Suppose there's a file called test.el, which have the following contents: (setq Yes, the parenthesis is not closed, because I haven't ...
0 votes
1 answer
101 views

Evil cursor moves one position right after exiting append mode, how to let it stay?

Similarly to the question Cursor moves one position left after exiting insert mode? I would like to know the similar thing, but now for the append command. I want the cursor to stay when exiting both ...
10 votes
3 answers
2k views

How to persistently move the cursor in a buffer other than the current one?

NB: The post How to move point to the end of another buffer, using `with-current-buffer` and `goto-char`? presumably asks the same question as this one, but the answers given to it do not readily ...
4 votes
3 answers
1k views

Moving cursor to the middle of the line where it currently is

Is there a way to define a function that, when called, would move the cursor to the middle (or close to the middle) of the current line, similarly to how we can move it to the beginning and end of the ...
0 votes
1 answer
281 views

How to make backward-kill-word and kill-word stop after it kills a newline character?

kill-word and backward-kill-word deletes too much text: foo(bar) <point> Now if I press C-<backspace>: foo(<point> What I want is: foo(bar)<point> after pressing C-<...
1 vote
1 answer
68 views

Jump/Goto next highlighted symbol in lsp-mode

Lsp-mode has a function lsp-document-highlight bound by default to s-l a h which picks the symbol at point and highlights all (semantic) occurrences. Is there a goto-next-highlight. I checked the ...
1 vote
1 answer
135 views

How can I move to the next logical line with the arrow keys?

When I KEY_DOWN, it invokes next-line from simple.el This next-line moves to the same line, if that line spans multiple lines. I don't want this to happen. I want to move to the next logical line;) I ...
0 votes
1 answer
59 views

moving cursor forward-sexp goes one char further in evil mode

When I want to highlight the following region (a ( b ( c ) ) ) ) I get (a ( b ( c ) ) ) ) I mark the beginning and do forward-sexp (or sp-forward-sexp, which results in the same outcome) In, insert ...
0 votes
2 answers
49 views

how to move past a drawer when point is on an org mode headline?

In org mode, say I'm on a headline, and just below that is a PROPERTIES drawer: *** this is my headline, I want to move past the closed PROPERTIES drawer :PROPERTIES: :CREATED: [2024-01-31T10:54:33-...
0 votes
0 answers
50 views

How quick jump to specific lines in differents buffers?

Linux Mint 21 Emacs 27.1 Suppose I open 3 different text files. As result open 3 differents buffers. E.g. text_1.txt text_2.txt text_3.txt Is it possible to jump using keybinding to the next lines? ...
0 votes
0 answers
27 views

Move point from a hook in EMMS playlist doesn't work

I want to move point with the current played song in an EMMS playlist. I tried it with this code: (defun tvd-emms-follow-playing-song() (interactive) (message (format "%s" emms-playlist-...
1 vote
1 answer
48 views

M-g M-g <nnn> to end of line (C-e)?

I often have to use this sequence: M-g M-g <nnn> C-e to get to the end of a particular line, for example to place a % or \par in TeX files. Is there some way to combine this into, say (...
1 vote
1 answer
64 views

Is there a reason for having beginning-of-defun-function/end-of-defun-function global?

I was working on a mode, setq'ed them with my functions and... emacs broke (really) For some reason these variable are global. I made them buffer-local, but is there a good reason for having them ...
1 vote
1 answer
33 views

Trouble maintaining buffer position when using re-builder

I am having trouble maintaining my current location in a document while running the re-builder command in Emacs. In a long document the buffer moves to the top of the document whenever I run the re-...
0 votes
1 answer
76 views

define a new evil command

I'm trying to reverse some words, and I have it set up where I can visually select them and hit ,rw to reverse them. How do I set it up so ,rw also works with a motion. E.g. ,rw3w to reverse 3 words? ...
0 votes
1 answer
216 views

How to move the text cursor to a given position?

How can I move the text cursor to any of these locations, using Lisp? (let ((beg (progn (skip-syntax-backward "^ " (line-beginning-position)) (point))) (end (...
1 vote
1 answer
34 views

What is the default value of TRY-VSCROLL in `(previous-line &optional ARG TRY-VSCROLL)`?

The documentation shown with Ctrl h k up states: <up> runs the command previous-line (found in global-map), which is an interactive byte-compiled Lisp function in ‘simple.el’. It is bound to C-...
0 votes
2 answers
75 views

goto-char support for hexadecimal input

I recently realized something weird regarding usability of goto-char using GNU Emacs: M-x goto-char Go to char: 0x1000 Please enter a number (OP note: didn't work) M-x goto-char Go to char: (* 4 ...
0 votes
2 answers
82 views

Jump to the end of body of headline

What is the key combination to jump directly to the end of BODY of a headline in org-mode? * Headline title A from here ▮ text text text text text text text text text text text text text text text to ...
1 vote
2 answers
85 views

Window Point Reset After Update

I have a buffer which is updated periodically using run-at-time, and in order to maintain the point in each window I use set-window-point, but I find that in sometimes when something is interrupted ...
0 votes
1 answer
118 views

Move cursor to an offset given by number of characters from the end of the buffer

This answer shows how to position the cursor at an offset of a specified number of characters from the beginning of the buffer, namely by executing M-x goto-char 47 (for an offset of 47 characters ...
0 votes
1 answer
179 views

How to leave cursor at beginning of searched text in isearch?

Say I have this text: |Lorem ipsum dolor sit amet, consectetur adipiscing elit. Where the | is the cursor, at the beginning of the line. I want to jump to the next occurrence of the sequence "...
1 vote
1 answer
67 views

How to ignore errors in the middle of a key/command sequence?

I wanted to jump to the end of the current top-level S-expression as described in this question: How to move up to the ending parenthesis of the enclosing list (if it exists)?. The goal is to position ...
3 votes
2 answers
263 views

How to move up to the ending parenthesis of the enclosing list (if it exists)?

In paredit mode, C-M-u (paredit-backward-up) is used to move the point backward up out of the enclosing list The point is parked at the beginning parenthesis of the enclosing list. My question is: ...
5 votes
1 answer
1k views

How to jump up or down to first non-whitespace character in same column

I use evil-mode with Emacs and would like to accomplish this via evil-mode, but would be fine with doing it in an Emacs-centric way too. The subject line explains it well, but here is a post in which ...
1 vote
1 answer
83 views

Keybinding for forward-page and backward-page

Have been trying to make a keybinding for forward-page and backward-page with (global-set-key (kbd "H-]") (forward-page)) (global-set-key (kbd "H-[") (backward-page)) But these ...
1 vote
1 answer
72 views

How to hide "Local Variables:" specification at the end of a file or how to prevent "M->" from get into that region

In emacs, file local variables are put at the end of the file. On appending text to a file, the user has to navigate to the exact line before the Local Variables: line - you can't not just M-> and ...
6 votes
1 answer
640 views

backword-sentence and forward-sentence are moving over paragraphs

I use markdown-mode to edit markdown, but it's missing one very useful feature. Whenever I press M-a (backward-sentence) or M-e (forward-sentence) it takes me to the start or end of the paragraph, ...
1 vote
1 answer
40 views

Lisp function to parse paragraph into sentences separated by full stops

Is there in Emacs an inbuilt function to separate text into sentences? Eg., Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard ...
1 vote
1 answer
71 views

Why is forward-sentence moving the cursor to the end of the paragraph and not working as expected and going to the end of the sentence? [duplicate]

I will provide a recipe for the problem that is happening. 1 - Open Emacs 2 - switch-buffer to the Scratch buffer 3 - Copy the following snippet Lorem Ipsum is simply dummy text of the printing and ...
0 votes
1 answer
266 views

Being inside a paragraph, how to move to the end of a sentence in Emacs? [duplicate]

I know how to move to the end of a line, the paragraph, the s-expression, the word, or even the buffer. But, I do not know how to move to the end of a sentence. Is there some way to move the end of a ...
0 votes
1 answer
124 views

restore cursor position iedit mode after narrowing with evil visul line

Iedit-mode can narrow the edit to a region, I am using evil-mode, evil-visual-line select region by whole lines, after narrowing the point is at the end of last line, is it possible to fix this ...
0 votes
1 answer
83 views

Mark up to and including the character under the cursor

By default, when I activate mark it just adds everything to the region up to the point which is behind the cursor (image below) What I want to achieve, however, is to also include - as part of my ...
0 votes
0 answers
61 views

What alternative exist to write specialized forward-sexp-function?

I'd like to write code that allows forward-sexp and backward-sexp commands to navigate across balanced keyword-based expressions, such as make files that use the if / fi keywords. It's possible to ...
2 votes
1 answer
226 views

How to go back within the ellipsis of a collapsed Org section?

I am using Emacs with evil-mode enabled. I would love to be able to move back using h when the cursor is exactly at the last character of a folded org file (as shown in the picture). However, when I ...
0 votes
1 answer
182 views

Evil mode motion: between blocks of text

Block motion I would like to quickly swape through files and j k and / aren't cutting it anymore. Is there a command to move between blocks of text? For example: What I mean by block movement, ...
2 votes
1 answer
310 views

How to move from one source block to another, in Org-mode?

Is there a key-binding, command, or even evil extension for Emacs, so that I can move from one source block to another? For example,org-forward-heading-same-level, which is bound in my system to C-j, ...
1 vote
1 answer
29 views

Need search function to navigate to last line in continuous occurrence range

I am looking for a way to improve searching by repeating pattern. Let's say some program prints lots of log messages with the same pattern: copying path '/nix/store/lqfjx7x6imy5a9xab1ff5nhg90v089rq-...
1 vote
1 answer
83 views

Key to move to next ancestor heading in org mode

I would like to jump to the next parent heading from a lower level directly. Is there a shortcut for that in org mode? * a ** b ** c * d So to jump, say, from b to d.
1 vote
1 answer
135 views

How to move to the next highlight?

How can I jump to the next beginning of a string highlighted by a command such as highlight-regexp or highlight-lines-matching-regexp?
0 votes
2 answers
112 views

How do I move the cursor to be just after the `>` character on the beggining of REPL evaluation?

I am using Emacs and Slime to work on Common Lisp code and I would like to know the most efficient way to move the cursor to the beginning of the REPL> assessment. For instance, modelling the ...
2 votes
1 answer
117 views

How to insert overlay every n visual/screen lines?

I want to insert an overlay at the beginning of every 40th or so visual/screen, to generate a WYSIWYG looking page-break overlay like so: At the moment this is done by font-locking the line-feed ...
7 votes
2 answers
1k views

Move cursor to beginning of visible text in current buffer

Is there a shortcut key combination for moving the cursor to the beginning, resp. end, of the visible text in the current buffer, i.e. to the first, resp. last, cursor position that can be seen on the ...
1 vote
1 answer
210 views

How to define a custom function that runs a command twice?

In dired mode, 'm trying to make a function that runs dired-next-line twice and then bind to SPC so that I navigate files faster in dired mode. I tried to add this in my dired.el file but it didn't ...
0 votes
3 answers
423 views

How to memorise the cursor position and return to it?

Say I was working in a big file somewhere in the middle and all of the sudden I realise that I need to edit the top of the file. I do a M-< to go to the top and make my edits. Now I want to move ...
4 votes
2 answers
436 views

How to scroll to the beginning of the line in Emacs

I have buffer and I end up at 1616 column (I have one very long line, bug string). Is there a way to scroll the beginning of the line with a single commands. Is there a way to reset the buffer without ...
1 vote
1 answer
368 views

How to use mouse click to the right or to the left of the text to move cursor to this line?

On a mouseclick to one side of the text, it can be convenient to make the cursor jump to: the beginning of the line (when clicking left of the text) the end of the line (when clicking right of the ...
2 votes
0 answers
21 views

Fields: how to avoid field-end-position to overlap with next field?

I have a text in the beginning of buffer 901 fifth avenue The word 901 is defined as field "house" and fifth (including space) as field "street". So the text with fields is ...
0 votes
1 answer
397 views

How can I jump back after `rope-goto-definition`?

I am using rope-goto-definition to jump into a module's definition, link. But I cannot jump back to where I was. xref-pop-marker-stack says Marker stack is empty. Is it possible to jump back after ...
4 votes
1 answer
402 views

How to change Emacs' word movement behaviour?

I want to do this on forward-word: (| shows the cursor position) Normal Behaviour: int main(int argc, char *args[]) { int a = 45|; printf|("%i", a); } What I want to do: //forward-...