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
17 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 ...
user avatar
  • 111
0 votes
0 answers
24 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 ...
user avatar
  • 581
1 vote
1 answer
51 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 ...
user avatar
  • 111
0 votes
1 answer
26 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, ...
user avatar
  • 257
2 votes
1 answer
65 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, ...
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-...
user avatar
0 votes
1 answer
70 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
52 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?
user avatar
  • 1,392
0 votes
2 answers
35 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 ...
user avatar
2 votes
1 answer
52 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 ...
user avatar
  • 91
1 vote
1 answer
49 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.
user avatar
  • 215
0 votes
3 answers
66 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 ...
user avatar
  • 715
3 votes
2 answers
148 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 ...
user avatar
  • 651
1 vote
1 answer
163 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 ...
user avatar
2 votes
0 answers
16 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 ...
user avatar
0 votes
1 answer
198 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 ...
user avatar
  • 1,102
3 votes
1 answer
169 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-...
user avatar
  • 31
0 votes
3 answers
70 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 ...
user avatar
  • 169
0 votes
1 answer
41 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 avatar
  • 113
0 votes
0 answers
156 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 ...
user avatar
0 votes
0 answers
204 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 &...
user avatar
2 votes
2 answers
58 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. ...
user avatar
  • 1,102
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 ...
user avatar
2 votes
1 answer
108 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 ...
user avatar
0 votes
2 answers
148 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, ...
user avatar
  • 715
1 vote
1 answer
40 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 "<...
user avatar
  • 7,069
1 vote
1 answer
147 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 ...
user avatar
0 votes
1 answer
67 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 ...
user avatar
0 votes
1 answer
17 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 ...
user avatar
  • 439
3 votes
0 answers
44 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); ...
user avatar
3 votes
1 answer
68 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 ...
user avatar
2 votes
1 answer
39 views

Make forward-list search for specific symbol only

Is there a way to make forward-list and backward-listsearch for specific symbols (such as 「」『』) only? I have code that make use of these functions to iterate through 「」『』 pairs in plain text. But ...
user avatar
  • 635
3 votes
3 answers
336 views

Move point inwards while counting number of nested parentheses without throwing an error

I would like to write a function that counts the number of nested parentheses while moving the cursor to the innermost bracket without throwing an error. (defun count-and-move () (interactive) ...
user avatar
  • 635
5 votes
2 answers
299 views

org: move point to beginning of an item

When in org-mode, how to move point to the beginning of the current item? (in similar fashion like back-to-indentation) Example: Imagine following org buffer content * headline - [ ] Z this is an ...
user avatar
  • 4,211
0 votes
2 answers
321 views

How do I capitalize the first words of sentences in some buffer text?

I know how to convert a string to upper case, to lower case, or to title case. But the operation I do most frequently writing English text is to fix up capitalization so a sentence or group of ...
user avatar
  • 285
0 votes
1 answer
183 views

Automatic "push-mark" when navigating with xref, find-grep, etc?

There seem to be a lot of situations, where a command changes the cursor location (point), but no mark is pushed, making navigating back by popping the mark with C-u SPC impossible. For isolated use-...
user avatar
  • 1,481
0 votes
2 answers
455 views

How to navigate in a Dired buffer?

window 10, Emacs 26.1, Dired+ Suppose I open in Dired+ mode some folder: d:/TEMP/test_folder/folder2/ I need next: When press button "End" then go to the last file in the folder. Like this: When ...
user avatar
  • 3,395
2 votes
1 answer
240 views

How to jump multiple lines in emacs?

Suppose I want to jump x amount of lines up or down. Is there a convenient command for it?
user avatar
0 votes
1 answer
61 views

Move specified lines down with C-(N) C-n

I could move next 4 lines with C-u C-n, Additionally, try to move next 6 lines with C-6 C-n, but it did only one line down in effect. What's wrong with my usage?
user avatar
  • 1,089
2 votes
1 answer
81 views

How to tell Occur to show the line in the top of the buffer

I usually use occur to make an index of the beginning of different things. When I jump to the occurrence, Occur shows the line in the middle of the buffer. How can I instruct occur to show the ...
user avatar
3 votes
1 answer
75 views

How to calculate a point N lines from another point in elisp?

Given a point, how can I get the point N lines before/after it? Will post own answer, but I'm not sure it's optimal.
user avatar
  • 7,069
1 vote
1 answer
192 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 ...
user avatar
1 vote
0 answers
71 views

decrease initial delay for line-up/line-down movement

so every time I press C-n or C-p for moving the point up and down and keep pressing n or p I move several lines. However, after the first line move, there is a delay before the point is moving down in ...
user avatar
  • 419
5 votes
2 answers
351 views

Is there an emacs command to go to end of code line (before line comment and whitespaces start)

say you have that: stuff indented stuff # commented stuff We already got move-beginning-of-line and back-to-indentation for the left side. Now, for the right side... I'd love to know if you ...
user avatar
  • 153
1 vote
2 answers
614 views

how to define an evil-operator to move forward/backward a text-object?

I am trying to define a function that moves to the begin/end of current text-object. First - I define an operator: (evil-define-operator evil-forward-text-object (beg end type) "move to end of ...
user avatar
  • 66
1 vote
1 answer
245 views

Jump to non-whitespace characters along a column

I'd like to have a command that moves down to the first line of the next string of nonwhitespace characters along the current column, and the analogous commands that move upward, and to the last line ...
user avatar
  • 1,392
0 votes
1 answer
121 views

How can I get working motion keys with `emacs -nw`?

when I start Emacs without windowing system (-nw), the motion keys are not working. Instead, I get (parts of) the escape sequences, like: ;; This buffer is for text that is not saved, and for Lisp ...
user avatar
1 vote
1 answer
44 views

Move to beginning of line when top arrow is pressed in beg-of-buffer line

Like in all modern editors, including the SE Q&A fields, I'd like my cursor to move to the beginning of the first line, when I press the Up arrow on the first line of a buffer. Currently, it stays ...
user avatar
4 votes
1 answer
223 views

Ignore tags in `org-end-of-line` and similar motions

Is there a convenient function for jumping to the last non-tag character in the line of an org-mode heading? For instance... * This is |my header :tag1:tag2: I would like a command that moves ...
user avatar
1 vote
0 answers
140 views

Slowness opening and moving around within large files

I'm running spacemacs 0.200.13 on emacs 25.3.1 from a macOS 10.12 machine. In some scenarios, things feel very sluggish. They get worse as a dozen buffers or so are opened during the day. From the ...
user avatar