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
1 vote
1 answer
41 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 ...
Lorenzo Marcantonio's user avatar
1 vote
1 answer
29 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-...
Edman's user avatar
  • 1,143
0 votes
1 answer
40 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? ...
Zaz's user avatar
  • 113
1 vote
1 answer
32 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-...
Claudio's user avatar
  • 350
0 votes
2 answers
51 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 ...
Robert's user avatar
  • 103
0 votes
1 answer
59 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 (...
Jason Hunter's user avatar
0 votes
2 answers
65 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 ...
Paolo's user avatar
  • 21
1 vote
2 answers
66 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 ...
C4ffeine Add1ct's user avatar
0 votes
1 answer
33 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 ...
Evan Aad's user avatar
  • 1,461
0 votes
1 answer
68 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 "...
Alessandro Bertulli's user avatar
1 vote
1 answer
48 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 ...
tinlyx's user avatar
  • 1,250
3 votes
2 answers
199 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: ...
tinlyx's user avatar
  • 1,250
1 vote
1 answer
53 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 ...
konmi's user avatar
  • 217
0 votes
1 answer
35 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 ...
godblessfq's user avatar
  • 1,175
0 votes
0 answers
18 views

How to stop the point from moving when interrupting zone?

I'd like to use zone-when-idle because it looks fun, but the point moves hundreds of lines away when I click on the frame to stop it. The problem is already here with emacs -Q (GNU Emacs 29.0.50). I ...
elyuku's user avatar
  • 67
1 vote
1 answer
31 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 ...
Pedro Delfino's user avatar
0 votes
1 answer
119 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 ...
Pedro Delfino's user avatar
0 votes
1 answer
61 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 ...
Rareform's user avatar
  • 197
0 votes
1 answer
45 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 ...
Shahin's user avatar
  • 121
1 vote
1 answer
38 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 ...
Emmanuel Goldstein's user avatar
0 votes
0 answers
33 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 ...
PRouleau's user avatar
  • 724
2 votes
1 answer
140 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 ...
Xaphanius's user avatar
  • 121
0 votes
1 answer
96 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, ...
BuddhiLW's user avatar
  • 257
2 votes
1 answer
168 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, ...
BuddhiLW's user avatar
  • 257
1 vote
1 answer
28 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-...
Daniil Iaitskov's user avatar
0 votes
1 answer
167 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-<...
user avatar
1 vote
1 answer
99 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?
Arch Stanton's user avatar
  • 1,515
0 votes
2 answers
75 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 ...
Pedro Delfino's user avatar
2 votes
1 answer
85 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 ...
tefkah's user avatar
  • 101
1 vote
1 answer
63 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.
David's user avatar
  • 281
0 votes
3 answers
159 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 ...
scribe's user avatar
  • 896
3 votes
2 answers
249 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 ...
jcubic's user avatar
  • 681
1 vote
1 answer
267 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 ...
telephon's user avatar
2 votes
0 answers
17 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 ...
Ott Toomet's user avatar
0 votes
1 answer
304 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 ...
alper's user avatar
  • 1,140
4 votes
1 answer
272 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-...
shigi's user avatar
  • 41
0 votes
3 answers
96 views

Search for text, print a message about it, and then return cursor to original position

I want to write an Elisp command that searches for a specific string in the backward direction, pauses the cursor there for a second, echoes a message about that occurrence, and then returns the ...
linuxfan's user avatar
  • 189
0 votes
1 answer
44 views

Emacs ignore \n in buffer

I would like to change the default behavior in emacs when '\n' meta-characters are encountered by the cursor. The default behavior is such that at '\n', (1) right-key sends the cursor to the beginning ...
user's user avatar
  • 123
0 votes
0 answers
408 views

Copy/Paste&Cut with Spacemacs on Terminal

I'm new with emacs, and I'm a developer that uses IDE to develop, and I want to learn emacs. I choose Spacemacs as customization because I think has a good keybinding for me, but now I miss a feature ...
vincenzopalazzo's user avatar
0 votes
0 answers
356 views

Problem with org-agenda view when going forward 1 week

I have my org-agenda to start on a Sunday. Hence I have this code in my .emacs file: (setq org-agenda-start-on-weekday 0) org-agenda opens with the cursor on the current day of the week. If I press &...
Edman's user avatar
  • 1,143
2 votes
2 answers
60 views

Is it possible to ignore paste operation during `C-x C-x` to jump back?

This question is related to Is it possible to bind C-u C-x C-xs behavior into C-x C-x. My main goal is to jump top of the file, type import and paste a package name and jump back where I was. ...
alper's user avatar
  • 1,140
2 votes
0 answers
42 views

Is (forward-char N)'s runtime complexity O(N)?

Internally, the text of a buffer is stored as a char array. The encoding used is based on UTF-8, which may use a variable number of bytes to represent different code points. Does the variable-length ...
alexgiorev's user avatar
3 votes
1 answer
146 views

What is the difference between `M-f` and `C-right`?

The documentation states the following: (forward-word &optional ARG) is bound to M-f (right-word &optional N) is bound to C-right Could there be any difference between the two? It just doesn't ...
Chanhee Jeong's user avatar
0 votes
2 answers
223 views

How to move the cursor to the end of the read only text?

Say I have text: This read only text ends here>*********************| The This read only text ends here> is read only while the asterisks are are not. When the (move-to-read-only-end) is called, ...
scribe's user avatar
  • 896
1 vote
1 answer
43 views

How to customize scrolling for any action that moves the point?

Say I have an action that moves the point (adds 100 to it for example). It should be possible to wrap this with a function or macro that gives additional behavior, eg: (global-set-key (kbd "<...
ideasman42's user avatar
  • 8,187
1 vote
1 answer
214 views

Forward, backward etc sexp not working

I want to use the forward-sexp function in Emacs, which on my Spacemacs for Mac is bound to C-M-f. Similarly for the backward-sexp. However, upon pressing C- for Control, and then the Meta key, which ...
zendevil.eth's user avatar
0 votes
1 answer
75 views

C-e to end of Headline

Something has changed for me, since I upgraded to newer org-mode If I have this * foo ** bar... ** baz... If I put point on "**", then hit C-e to go to the end of line, it only moves point ...
Jason Hunter's user avatar
0 votes
1 answer
34 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 ...
Searene's user avatar
  • 469
3 votes
0 answers
62 views

Is there a way to move region with arrow keys or similar?

Say I have a function int calc(int that, int this); I want to mark int that and then move it right across words by hitting modifier arrow key (or similar) twice to get int calc(int this, int that); ...
young_souvlaki's user avatar
3 votes
1 answer
72 views

How can I find corresponding balanced parentheses?

I have this LaTeX code: \caption{Lorem ipsum dolor sit amet: foo), bar), baz) and qux) consectetuer adipiscing elit.} I want to put a marker immediately before the first { and one immediately after ...
Onner Irotsab's user avatar