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
3 answers
110 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 ...
-1 votes
1 answer
52 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 ...
0 votes
0 answers
481 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 ...
0 votes
0 answers
501 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 &...
2 votes
2 answers
62 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. ...
1 vote
1 answer
308 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 ...
2 votes
0 answers
44 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 ...
3 votes
1 answer
185 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 ...
0 votes
2 answers
242 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, ...
1 vote
1 answer
51 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 "<...
1 vote
1 answer
271 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 ...
3 votes
2 answers
587 views

How to use a menu to jump between sections of a document?

I would like to define my own rules for what a section of a document is, then use this so I can popup a list of sections I can auto-complete or use arrow keys to jump between them. Take a simple ...
0 votes
1 answer
85 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 ...
3 votes
0 answers
79 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); ...
3 votes
1 answer
141 views

Move point to just before end of a comment

Given that the point is right in front of a comment, how do I move it to the end of the comment, but before the comment end markers? For example: for a C++ // xxx comment, I would like to move the ...
3 votes
1 answer
76 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 ...
1 vote
2 answers
880 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 ...
6 votes
2 answers
561 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 ...
4 votes
2 answers
831 views

Move to goal-column inserting spaces if necessary

I have a bunch of lines of text and I'm trying to insert text starting at a certain column on each line. For example: 'Some text' This is ok 'Another longer text' ask Ram 'weird stuff' ...
3 votes
1 answer
181 views

next/prev-imenu-item function

I would like to have a single shortcut to jump to the next item on the imenu of current buffer. E.g., if the current buffer is in org mode, next-imenu-item = org-next-visible-heading. Anyone did ...
15 votes
4 answers
7k views

Emacs point(cursor) movement lag

When running previous-line, C-p or <up> the cursor jumps up a line without any issues or lags. When running next-line, C-n or <down> the cursor properly jumps down a line, but with a ...
2 votes
1 answer
44 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 ...
3 votes
3 answers
342 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) ...
1 vote
1 answer
309 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-...
2 votes
2 answers
727 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 ...
0 votes
2 answers
998 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 ...
3 votes
1 answer
1k 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?
3 votes
1 answer
96 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 ...
0 votes
1 answer
111 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?
19 votes
5 answers
5k views

Stop at beginning of a word on `forward-word`

I often use multiple invocations of forward-word followed by a single backward-word to move point to the beginning of a word on a line. I guess I never got used to the way forward-word differs from ...
3 votes
1 answer
80 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.
6 votes
2 answers
706 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 ...
1 vote
0 answers
115 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 ...
1 vote
1 answer
128 views

goto-chg stops at undo branch point?

I'm using package goto-chg to move cursor to the last edit. It works great most of the time, but it sometimes said "No further change info" even though there were more changes. Using undo-tree's ...
2 votes
1 answer
1k views

Spacemacs visual line navigation not working

Running spacemacs 0.200.13 on emacs 25.2.2 on Kubuntu 18.04. In ~/.spacemacs, there is: (global-visual-line-mode t) (add-hook 'text-mode-hook #'visual-line-mode) So, when I open a text file, I see ...
1 vote
5 answers
317 views

Skip vertical whitespace/non-whitespace blocks (sort of vertical M-f / M-b)

Say the point is on the 0 here: as0sasasa asasasasa as1sasasa asa as3sasasa asasasasa as2sasasa I'd like to have a command – like a vertical forward-word – that when run repeatedly would jump ...
0 votes
1 answer
130 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 ...
0 votes
1 answer
284 views

Custom keybinding for jumping down 2 lines on spacemacs (evil-mode)

What I want is to have the option to scroll faster. Currently when in evil-mode normal state when I press j evil-next-visual-line is called. If I hold jthen the cursor moves down. What I want is ...
1 vote
1 answer
47 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 ...
4 votes
1 answer
295 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 ...
1 vote
0 answers
152 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 ...
0 votes
0 answers
119 views

Enable Evil jump to work across all panes instead of only active pane

Is there a way to enable evil-jump-forward and evil-jump-backward to use the jump list of all panes instead of only the active pane? In the gif below, here's what happens: Start on left pane at ...
1 vote
1 answer
260 views

Unexpected behavior using SHIFT+arrows and CTRL+arrows on emacs (orgmode) + terminal + mosh + screen

I am connecting in a machine using a terminal, mosh and then screen. Then, in my orgmode file I can't use the shortcuts like SHIFT+up, SHIFT+left or CTRL+up etc. If I press that, it produces something ...
2 votes
3 answers
95 views

is there a keybinding to save curor position for returning after viewing other section of same buffer?

when i am editing a large file, often need to view other sections of the same buffer only once. But after that I need to go back to the position I was editing at. Is there a key for doing that?
5 votes
2 answers
248 views

Move cursor left/right while entering isearch

How can I move my cursor left and right while entering my isearch text? isearch-forward Enter some text Press cursor left to edit the search text Argh! Emacs returns the cursor to the main buffer. ...
1 vote
0 answers
306 views

How can I run (recenter) after (call-interactive ...) that jumps to a buffer?

I would like to jump to a buffer using rtags for eg. Example snippet: (defun generic-lookup () "Follow link/goto line." (interactive) (cond ((string= major-mode "c-mode") (progn ...
3 votes
1 answer
389 views

Make evil paragraphs behave like vim paragraphs

I have moved from vim to emacs using evil-mode. I've found that I prefer emacs (as long as I can edit text vim style), but I have one small inconvenience. I've found, mainly while writing prose, but ...
3 votes
1 answer
281 views

New line in cursor-intangible area and line-beginning position

I want to make the beginning of a line uneditable, which I can achieve by applying the read-only and cursor-intangible properties. But I have the problem, that line-beginning-position moves point not ...
0 votes
1 answer
59 views

Make prelude C-a go to the absolute beginning of the line

Emacs prelude "smartens" C-a by rebinding it to "crux-move-beginning-of-line" My muscle memory likes the vanilla emacs setting better, where C-a moves point to the absolute beginning of the line. ...
2 votes
1 answer
270 views

Navigating lisp

I want to programmatically navigate emacs lisp (and similar "nested paren code"). Specific functions I want: Go to first child (which errors if there are no children (maybe lispy-outline-goto-child ...