Get Emacs to jump to the start of a word after isearchHow can I configure incremental search to put my cursor at the start of whitespace rather than the end?Customize isearch to start from buffer startMake forward-word not to jump over newline characterGet word at pointSelecting (i.e., as the region) the current match in incremental searchisearch but don't move the cursor until I ask to searchclear highlighted matches of an isearchMake isearch commands search only at the beginning of wordsJump to word in another window
What explains the Genie's fate?
Owner keeps cutting corners and poaching workers for his other company
Explaining "向けてじゃないよ"
A PEMDAS issue request for explanation
What is the purpose of the rotating plate in front of the lock?
How can faith be maintained in a world of living gods?
Are personality traits, ideals, bonds, and flaws required?
If every star in the universe except the Sun were destroyed, would we die?
I multiply the source, you (probably) multiply the output!
Contour plot of a sequence of spheres with increasing radius
Is it right to use the ideas of non-winning designers in a design contest?
When calculating averages, why can we treat exploding die as if they're independent?
Why did Tony's Arc Reactor do this?
Is mountain bike good for long distances?
Word for something that used to be popular but not anymore
What is the delta-v required to get a mass in Earth orbit into the sun using a SINGLE transfer?
Why are UK MPs allowed to abstain (but it counts as a no)?
How to run NPCs with complicated mechanics?
Why do the Brexit opposition parties not want a new election?
How can I hint that my character isn't real?
Why would an airport be depicted with symbology for runways longer than 8,069 feet even though it is reported on the sectional as 7,200 feet?
After a few interviews, What should I do after told to wait?
Strategies for dealing with chess burnout?
Problem with listing a directory to grep
Get Emacs to jump to the start of a word after isearch
How can I configure incremental search to put my cursor at the start of whitespace rather than the end?Customize isearch to start from buffer startMake forward-word not to jump over newline characterGet word at pointSelecting (i.e., as the region) the current match in incremental searchisearch but don't move the cursor until I ask to searchclear highlighted matches of an isearchMake isearch commands search only at the beginning of wordsJump to word in another window
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
If I use isearch to search for the word "accommodating" in my document, I have to type acc before the cursor jumps to the word. When I press enter the cursor is on the the second "c" as in acCommodating. This strikes me as rather unintuitive because I have to go back two characters to begin editing the word. In Vim, search puts the cursor at the start of the word. Can I replicate this behaviour in Emacs?
isearch words
add a comment |
If I use isearch to search for the word "accommodating" in my document, I have to type acc before the cursor jumps to the word. When I press enter the cursor is on the the second "c" as in acCommodating. This strikes me as rather unintuitive because I have to go back two characters to begin editing the word. In Vim, search puts the cursor at the start of the word. Can I replicate this behaviour in Emacs?
isearch words
add a comment |
If I use isearch to search for the word "accommodating" in my document, I have to type acc before the cursor jumps to the word. When I press enter the cursor is on the the second "c" as in acCommodating. This strikes me as rather unintuitive because I have to go back two characters to begin editing the word. In Vim, search puts the cursor at the start of the word. Can I replicate this behaviour in Emacs?
isearch words
If I use isearch to search for the word "accommodating" in my document, I have to type acc before the cursor jumps to the word. When I press enter the cursor is on the the second "c" as in acCommodating. This strikes me as rather unintuitive because I have to go back two characters to begin editing the word. In Vim, search puts the cursor at the start of the word. Can I replicate this behaviour in Emacs?
isearch words
isearch words
edited 11 hours ago
Drew
51.2k4 gold badges65 silver badges115 bronze badges
51.2k4 gold badges65 silver badges115 bronze badges
asked 12 hours ago
devcomdevcom
801 silver badge8 bronze badges
801 silver badge8 bronze badges
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
As Drew pointed in his answer you can also end the search with another key such as M-b
or M-f
, which for words boundaries works good, but my solution is kind of more general: define a key to put the cursor at the beginning (or end) of the pattern I'm searching:
(use-package isearch
:bind (:map isearch-mode-map
("C-<return>" . isearch-done-opposite))
:init (defun isearch-done-opposite (&optional nopush edit)
"End current search in the opposite side of the match."
(interactive)
(funcall #'isearch-done nopush edit)
(when isearch-other-end (goto-char isearch-other-end))))
Basically, map C-Ret
to another function isearch-done-opposite
which checks the variable isearch-other-end
which is defined in isearch.el
as:
(defvar isearch-other-end nil) ; Start (end) of match if forward (backward).
This will work with forward and backward searches.
add a comment |
There's really nothing to replicate, I think. You somehow have to tell Isearch that you're done typing text for the search string - you have to hit some key to tell it that. So at a minimum you have C-s acc <SOME KEY>
.
You can end Isearch with any key that is not already bound to something in isearch-mode-map
. (And even then, you can rebind any keys that are already bound.) And the key that ends Isearch can do whatever you like, including move back to a word beginning.
So you can end it with M-b
(that key isn't bound for Isearch, by default), which goes back to the beginning of the current word:
C-s acc M-b
That's not so hard. Whether you find it "intuitive" probably has to do with what you're already used to. There are a zillion use cases for Isearch, only one of which is wanting to move to the beginning of a matching word.
C-h k M-b
tells you:
M-b
runs the commandbackward-word
(found inglobal-map
), which is an
interactive compiled Lisp function insimple.el
.
It is bound to
M-b
,ESC left
.
(backward-word &optional ARG)
Move backward until encountering the beginning of a word.
With argument
ARG
, do this that many times.
IfARG
is omitted ornil
, move point backward one word.
The word boundaries are normally determined by the buffer’s
syntax table and character script (according to
char-script-table
), butfind-word-boundary-function-table
,
such as set up bysubword-mode
, can change that. If a Lisp
program needs to move by words determined strictly by the syntax
table, it should usebackward-word-strictly
instead. See Info
node (elisp) Word Motion for details.
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "583"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2femacs.stackexchange.com%2fquestions%2f52549%2fget-emacs-to-jump-to-the-start-of-a-word-after-isearch%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
As Drew pointed in his answer you can also end the search with another key such as M-b
or M-f
, which for words boundaries works good, but my solution is kind of more general: define a key to put the cursor at the beginning (or end) of the pattern I'm searching:
(use-package isearch
:bind (:map isearch-mode-map
("C-<return>" . isearch-done-opposite))
:init (defun isearch-done-opposite (&optional nopush edit)
"End current search in the opposite side of the match."
(interactive)
(funcall #'isearch-done nopush edit)
(when isearch-other-end (goto-char isearch-other-end))))
Basically, map C-Ret
to another function isearch-done-opposite
which checks the variable isearch-other-end
which is defined in isearch.el
as:
(defvar isearch-other-end nil) ; Start (end) of match if forward (backward).
This will work with forward and backward searches.
add a comment |
As Drew pointed in his answer you can also end the search with another key such as M-b
or M-f
, which for words boundaries works good, but my solution is kind of more general: define a key to put the cursor at the beginning (or end) of the pattern I'm searching:
(use-package isearch
:bind (:map isearch-mode-map
("C-<return>" . isearch-done-opposite))
:init (defun isearch-done-opposite (&optional nopush edit)
"End current search in the opposite side of the match."
(interactive)
(funcall #'isearch-done nopush edit)
(when isearch-other-end (goto-char isearch-other-end))))
Basically, map C-Ret
to another function isearch-done-opposite
which checks the variable isearch-other-end
which is defined in isearch.el
as:
(defvar isearch-other-end nil) ; Start (end) of match if forward (backward).
This will work with forward and backward searches.
add a comment |
As Drew pointed in his answer you can also end the search with another key such as M-b
or M-f
, which for words boundaries works good, but my solution is kind of more general: define a key to put the cursor at the beginning (or end) of the pattern I'm searching:
(use-package isearch
:bind (:map isearch-mode-map
("C-<return>" . isearch-done-opposite))
:init (defun isearch-done-opposite (&optional nopush edit)
"End current search in the opposite side of the match."
(interactive)
(funcall #'isearch-done nopush edit)
(when isearch-other-end (goto-char isearch-other-end))))
Basically, map C-Ret
to another function isearch-done-opposite
which checks the variable isearch-other-end
which is defined in isearch.el
as:
(defvar isearch-other-end nil) ; Start (end) of match if forward (backward).
This will work with forward and backward searches.
As Drew pointed in his answer you can also end the search with another key such as M-b
or M-f
, which for words boundaries works good, but my solution is kind of more general: define a key to put the cursor at the beginning (or end) of the pattern I'm searching:
(use-package isearch
:bind (:map isearch-mode-map
("C-<return>" . isearch-done-opposite))
:init (defun isearch-done-opposite (&optional nopush edit)
"End current search in the opposite side of the match."
(interactive)
(funcall #'isearch-done nopush edit)
(when isearch-other-end (goto-char isearch-other-end))))
Basically, map C-Ret
to another function isearch-done-opposite
which checks the variable isearch-other-end
which is defined in isearch.el
as:
(defvar isearch-other-end nil) ; Start (end) of match if forward (backward).
This will work with forward and backward searches.
edited 7 hours ago
answered 7 hours ago
AnlerAnler
1695 bronze badges
1695 bronze badges
add a comment |
add a comment |
There's really nothing to replicate, I think. You somehow have to tell Isearch that you're done typing text for the search string - you have to hit some key to tell it that. So at a minimum you have C-s acc <SOME KEY>
.
You can end Isearch with any key that is not already bound to something in isearch-mode-map
. (And even then, you can rebind any keys that are already bound.) And the key that ends Isearch can do whatever you like, including move back to a word beginning.
So you can end it with M-b
(that key isn't bound for Isearch, by default), which goes back to the beginning of the current word:
C-s acc M-b
That's not so hard. Whether you find it "intuitive" probably has to do with what you're already used to. There are a zillion use cases for Isearch, only one of which is wanting to move to the beginning of a matching word.
C-h k M-b
tells you:
M-b
runs the commandbackward-word
(found inglobal-map
), which is an
interactive compiled Lisp function insimple.el
.
It is bound to
M-b
,ESC left
.
(backward-word &optional ARG)
Move backward until encountering the beginning of a word.
With argument
ARG
, do this that many times.
IfARG
is omitted ornil
, move point backward one word.
The word boundaries are normally determined by the buffer’s
syntax table and character script (according to
char-script-table
), butfind-word-boundary-function-table
,
such as set up bysubword-mode
, can change that. If a Lisp
program needs to move by words determined strictly by the syntax
table, it should usebackward-word-strictly
instead. See Info
node (elisp) Word Motion for details.
add a comment |
There's really nothing to replicate, I think. You somehow have to tell Isearch that you're done typing text for the search string - you have to hit some key to tell it that. So at a minimum you have C-s acc <SOME KEY>
.
You can end Isearch with any key that is not already bound to something in isearch-mode-map
. (And even then, you can rebind any keys that are already bound.) And the key that ends Isearch can do whatever you like, including move back to a word beginning.
So you can end it with M-b
(that key isn't bound for Isearch, by default), which goes back to the beginning of the current word:
C-s acc M-b
That's not so hard. Whether you find it "intuitive" probably has to do with what you're already used to. There are a zillion use cases for Isearch, only one of which is wanting to move to the beginning of a matching word.
C-h k M-b
tells you:
M-b
runs the commandbackward-word
(found inglobal-map
), which is an
interactive compiled Lisp function insimple.el
.
It is bound to
M-b
,ESC left
.
(backward-word &optional ARG)
Move backward until encountering the beginning of a word.
With argument
ARG
, do this that many times.
IfARG
is omitted ornil
, move point backward one word.
The word boundaries are normally determined by the buffer’s
syntax table and character script (according to
char-script-table
), butfind-word-boundary-function-table
,
such as set up bysubword-mode
, can change that. If a Lisp
program needs to move by words determined strictly by the syntax
table, it should usebackward-word-strictly
instead. See Info
node (elisp) Word Motion for details.
add a comment |
There's really nothing to replicate, I think. You somehow have to tell Isearch that you're done typing text for the search string - you have to hit some key to tell it that. So at a minimum you have C-s acc <SOME KEY>
.
You can end Isearch with any key that is not already bound to something in isearch-mode-map
. (And even then, you can rebind any keys that are already bound.) And the key that ends Isearch can do whatever you like, including move back to a word beginning.
So you can end it with M-b
(that key isn't bound for Isearch, by default), which goes back to the beginning of the current word:
C-s acc M-b
That's not so hard. Whether you find it "intuitive" probably has to do with what you're already used to. There are a zillion use cases for Isearch, only one of which is wanting to move to the beginning of a matching word.
C-h k M-b
tells you:
M-b
runs the commandbackward-word
(found inglobal-map
), which is an
interactive compiled Lisp function insimple.el
.
It is bound to
M-b
,ESC left
.
(backward-word &optional ARG)
Move backward until encountering the beginning of a word.
With argument
ARG
, do this that many times.
IfARG
is omitted ornil
, move point backward one word.
The word boundaries are normally determined by the buffer’s
syntax table and character script (according to
char-script-table
), butfind-word-boundary-function-table
,
such as set up bysubword-mode
, can change that. If a Lisp
program needs to move by words determined strictly by the syntax
table, it should usebackward-word-strictly
instead. See Info
node (elisp) Word Motion for details.
There's really nothing to replicate, I think. You somehow have to tell Isearch that you're done typing text for the search string - you have to hit some key to tell it that. So at a minimum you have C-s acc <SOME KEY>
.
You can end Isearch with any key that is not already bound to something in isearch-mode-map
. (And even then, you can rebind any keys that are already bound.) And the key that ends Isearch can do whatever you like, including move back to a word beginning.
So you can end it with M-b
(that key isn't bound for Isearch, by default), which goes back to the beginning of the current word:
C-s acc M-b
That's not so hard. Whether you find it "intuitive" probably has to do with what you're already used to. There are a zillion use cases for Isearch, only one of which is wanting to move to the beginning of a matching word.
C-h k M-b
tells you:
M-b
runs the commandbackward-word
(found inglobal-map
), which is an
interactive compiled Lisp function insimple.el
.
It is bound to
M-b
,ESC left
.
(backward-word &optional ARG)
Move backward until encountering the beginning of a word.
With argument
ARG
, do this that many times.
IfARG
is omitted ornil
, move point backward one word.
The word boundaries are normally determined by the buffer’s
syntax table and character script (according to
char-script-table
), butfind-word-boundary-function-table
,
such as set up bysubword-mode
, can change that. If a Lisp
program needs to move by words determined strictly by the syntax
table, it should usebackward-word-strictly
instead. See Info
node (elisp) Word Motion for details.
edited 11 hours ago
answered 12 hours ago
DrewDrew
51.2k4 gold badges65 silver badges115 bronze badges
51.2k4 gold badges65 silver badges115 bronze badges
add a comment |
add a comment |
Thanks for contributing an answer to Emacs Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2femacs.stackexchange.com%2fquestions%2f52549%2fget-emacs-to-jump-to-the-start-of-a-word-after-isearch%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown