Hot answers tagged

29 votes
Accepted

Emacs point(cursor) movement lag

I have found an answer to my question through narrowing down the naughty bit and googling. I have managed to reduce the lag 10 TIMES!!!! I mean....It is insane on how much computing power next-line ...
user avatar
24 votes
Accepted

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

The misc package (shipped with emacs) has the built-in function forward-to-word, which does what I think you want: forward-to-word is an interactive compiled Lisp function in `misc.el'. It is bound ...
user avatar
  • 2,735
14 votes
Accepted

How to handle next-line in keyboard macro?

You have two three options: Use next-logical-line instead of next-line when defining the macro: Move cursor vertically down ARG lines. This is identical to next-line, except that it always moves ...
user avatar
  • 14.2k
14 votes

Find position in file by character number

Depending on what is that number, e.g., 47 (line, character-position, etc) you can do M-x goto-line 47 or M-x-goto-char 47.
user avatar
  • 7,324
13 votes

Why doesn't M-v following C-v move cursor back to the original position?

You can try setting scroll-preserve-screen-position to always: (setq scroll-preserve-screen-position 'always) From the documentation (C-h v scroll-preserve-screen-position): Controls if scroll ...
user avatar
12 votes
Accepted

How to move by whole line rather than within a wrapped line (emacs 23.1+)

You need to modify the line-move-visual variable. You need to set its value to nil if you want the up/down line navigation happen logically (not visually). When line-move-visual is set to nil ▮his ...
user avatar
  • 24.3k
11 votes
Accepted

Keep moving to the end of lines

I don't know of a package that would enable this behavior, but here's one way to do it. Press C-h k C-a to discover that C-a is bound to move-beginning-of-line; this is the function we need to modify ...
user avatar
  • 8,952
10 votes
Accepted

backword-sentence and forward-sentence are moving over paragraphs

You're probably using single space sentences, which is fine, but you need to tell Emacs about it. (setq sentence-end-double-space nil)
user avatar
  • 22.4k
10 votes

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

This was a pretty cool question, I learned a lot that I didn't know while trying to figure this out. What I learned was that each window has its own value for point. This is important because it means ...
user avatar
  • 1,245
9 votes

What is the correct way skip to prev/next method/function definition?

Use C-M-a (beginning-of-defun) to move backward before each "defun" (top-level sexp). Use C-M-e (end-of-defun) to move forward after each "defun". To move across several by repeating, just hold down ...
user avatar
  • 69.6k
9 votes

How to jump to matching (double or single) quote of a quoted string?

M-C-f (or M-C-right) bound to forward-sexp should do that. I suggest you try all well-known motion commands with the prefix M-C- instead of C-. M-C-b (or M-C-left) gives backward-sexp M-C-u (or M-C-...
user avatar
  • 30.2k
9 votes
Accepted

org: move point to beginning of an item

Consider to customize variable org-special-ctrl-a/e. Possibly that will ease your flow. From the documentation. Note in particular the "item" part. When t, ‘C-a’ will bring back the cursor to ...
user avatar
  • 2,646
8 votes
Accepted

Make the cursor stop at the last character of a line instead of the newline character

(This is too long for a comment, and while not literally an answer, I hope it might help the OP.) While Drew's answer covers what you literally want, this is probably not what you need. Point in ...
user avatar
  • 1,609
8 votes

Keep moving to the end of lines

Library misc-cmds.el has long had this feature. These are the relevant commands, and suggested key bindings (these bindings are made in setup-keys.el). (cond ((fboundp 'move-beginning-of-line) ...
user avatar
  • 69.6k
8 votes
Accepted

Move to the beginning of a heading smartly in Org-mode

This is supported right out-of-the-box, by setting: (setq org-special-ctrl-a/e t) As a bonus C-e handles tags similarly to C-a handling asterisks.
user avatar
7 votes
Accepted

How does previous-line/next-line "know" the column it should move to from the end of the line

next-line and previous-line are defined in simple.el, and call line-move. If you take a look at the definition of the function, you'll see that it (as well as line-move-1 and line-move-visual which ...
user avatar
7 votes
Accepted

Is there a hook I can use to run my function when point moves?

I think post-command-hook is what you wish to use. It is run every time a command has been run. And a command is basically any interactive action, such as clicking a mouse button, typing a letter (...
user avatar
6 votes

Navigate by indentation

This feature exists in Emacs. Outline mode describes a document as containing heading lines with a level, and has facilities to move among levels. We can define every line as a heading line with a ...
user avatar
6 votes

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

(Jules Tamagnan's answer identifies the problem, I'll expand on it.) Your solutions with save-excursion or save-excursion do in fact work! You can see it by checking the value of (point) in that ...
user avatar
5 votes
Accepted

How to skip forward to first whitespace character?

You can use skip-syntax-forward to skip non-whitespace. Docstring: (skip-syntax-forward SYNTAX &optional LIM) Move point forward across chars in specified syntax classes. SYNTAX is a ...
user avatar
  • 31.1k
5 votes
Accepted

Emacs flickering when using before-save-hook with gofmt

Load library simple.el (not simple.elc), then do M-x debug-on-entry RET next-line RET. Then use C-n and step through the debugger using d (or c to skip through an evaluation) to see what happens (...
user avatar
  • 69.6k
5 votes
Accepted

Is is possible to treat any symbol in the buffer as word when moving around?

Since the answer is picked from the comment from @kaushalmodi, I cannot choose the comment as an answer, so I post this as the right answer. According to comment from @kaushalmodim, syntax-subword is ...
user avatar
  • 2,559
5 votes

Make the cursor stop at the last character of a line instead of the newline character

Bind C-e to a command that puts the cursor one char to the left of the line end. (defun foo (arg) (interactive "p") (end-of-line arg) (unless (bolp) (backward-char))) (global-set-key "\C-e" '...
user avatar
  • 69.6k
5 votes
Accepted

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

The following function moves the cursor to the middle of the current line: (defun my/move-to-middle () (interactive) (let* ((begin (line-beginning-position)) (end (line-end-position)) ...
user avatar
  • 651
5 votes
Accepted

Move cursor left/right while entering isearch

You can run the command isearch-edit-string pressing M-e. See the documentation for details.
user avatar
  • 1,693
5 votes

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

Here's a quick command, lightly tested, that does what you're looking for. (defun eol-dwim () "Go to the end of the line, ignoring comments and trailing whitespace." (interactive) (let ((bol (...
user avatar
  • 31.1k
5 votes

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

This can be done using save-excursion, then moving the cursor. (defun point-calc-lines-offset (pt lines) (save-excursion (goto-char pt) (forward-line lines) (point))
user avatar
  • 7,179
5 votes
Accepted

How to scroll to the beginning of the line in Emacs

The window has been scrolled left (scroll-left) for some reason. C-x < or C-<next> can get you into this state. C-x > or C-<prior> can get you out of this state. Note those commands ...
user avatar
  • 4,231
4 votes

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

You can bind the below function to M-f and bind the original forward-word to M-F. This function simply takes the arg and passes it on to the forward-word function. So the universal arguments will work ...
user avatar
  • 24.3k
4 votes
Accepted

How to explain this strange comint behavior?

Could someone explain this behavior? The documentation of line-end-position has a note at the end that explains this behavior: This function constrains the returned position to the current field ...
user avatar
  • 8,952

Only top scored, non community-wiki answers of a minimum length are eligible