Selecting next occurrence of word incrementallyquery-replace in keyboard macroHighlighting text in open (displayed) buffers/windows — searching for text from one buffer in anotherhow to search and replace an entire word?What changed with Mark/Region behavior between GNU Emacs 24.3.1 and 24.5.1?How to match only a word when using `re-search-backward` functionReplace word causes buffer issueReplace word at point preserving the case patternhow can i do for replace a part of a regexpMake region(s) invisible (not evaluated) to query-replacy and similar commands
Is there a higher incidence of electoral fraud in states that use all-mail voting?
Reimbursed more than my travel expenses for interview
Why do some AFBs have planes parked at 45 degrees to others?
What's the meaning of "411 on the late-night drop box"?
Looking for a SciFi RPG I played in my childhood about a girl who is a hologram who fights aliens
Why did George Lucas set Star Wars in the past instead of the future?
Key takeaways in German in a presentation
Simulating these special dice on more regular dice
writing Vec compare in a more compact way
Toy Vector Library - Magnitude & Unit Vector Functions
Smallest Fibonacci Multiples
Is using Swiss Francs (CHF) cheaper than Euros (EUR) in Switzerland?
Isn't Social Security set up as a Pension Fund as opposed to a Direct Transfers Scheme?
Can you marry a girl in Stardew Valley if you are a girl?
Why is JavaScript not compiled to bytecode before sending over the network?
Is the speed of light in all media independent of reference frame?
Can I leave my car sitting outside for about 5 years?
Parsing and meaning of まいとしているふう
How do planes maintain constant speeds at cruise altitudes?
How can I unscrew the faucet nuts in the tight space behind my sink basin?
Why should you have travel insurance?
Is it possible to duplicate an item in Stardew Valley?
Biggest Irreducible Hello World
Fourier transform is an isomorphism...but we don’t get when each frequency appears?
Selecting next occurrence of word incrementally
query-replace in keyboard macroHighlighting text in open (displayed) buffers/windows — searching for text from one buffer in anotherhow to search and replace an entire word?What changed with Mark/Region behavior between GNU Emacs 24.3.1 and 24.5.1?How to match only a word when using `re-search-backward` functionReplace word causes buffer issueReplace word at point preserving the case patternhow can i do for replace a part of a regexpMake region(s) invisible (not evaluated) to query-replacy and similar commands
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty
margin-bottom:0;
I want to make changes inside a paragraph of a large text file.
If I have the cursor at the word "foo", what key combination would get the cursor at the next occurrences of this word? The cursor could be at the beginning, end, or highlight the word.
I'm looking to replace "foo" with "bar" in a paragraph.
This is similar to Sublime Text's Ctrl-D
search replace
add a comment
|
I want to make changes inside a paragraph of a large text file.
If I have the cursor at the word "foo", what key combination would get the cursor at the next occurrences of this word? The cursor could be at the beginning, end, or highlight the word.
I'm looking to replace "foo" with "bar" in a paragraph.
This is similar to Sublime Text's Ctrl-D
search replace
Yes it was what I said in the second sentence. By "at" I mean "at the beginning" or "at the end". Have rephrased the question so it is clearer and doesn't risk being closed.
– Saurabh
Sep 29 at 23:21
add a comment
|
I want to make changes inside a paragraph of a large text file.
If I have the cursor at the word "foo", what key combination would get the cursor at the next occurrences of this word? The cursor could be at the beginning, end, or highlight the word.
I'm looking to replace "foo" with "bar" in a paragraph.
This is similar to Sublime Text's Ctrl-D
search replace
I want to make changes inside a paragraph of a large text file.
If I have the cursor at the word "foo", what key combination would get the cursor at the next occurrences of this word? The cursor could be at the beginning, end, or highlight the word.
I'm looking to replace "foo" with "bar" in a paragraph.
This is similar to Sublime Text's Ctrl-D
search replace
search replace
edited Sep 30 at 1:09
Drew
53.2k4 gold badges70 silver badges127 bronze badges
53.2k4 gold badges70 silver badges127 bronze badges
asked Sep 29 at 22:13
SaurabhSaurabh
1376 bronze badges
1376 bronze badges
Yes it was what I said in the second sentence. By "at" I mean "at the beginning" or "at the end". Have rephrased the question so it is clearer and doesn't risk being closed.
– Saurabh
Sep 29 at 23:21
add a comment
|
Yes it was what I said in the second sentence. By "at" I mean "at the beginning" or "at the end". Have rephrased the question so it is clearer and doesn't risk being closed.
– Saurabh
Sep 29 at 23:21
Yes it was what I said in the second sentence. By "at" I mean "at the beginning" or "at the end". Have rephrased the question so it is clearer and doesn't risk being closed.
– Saurabh
Sep 29 at 23:21
Yes it was what I said in the second sentence. By "at" I mean "at the beginning" or "at the end". Have rephrased the question so it is clearer and doesn't risk being closed.
– Saurabh
Sep 29 at 23:21
add a comment
|
2 Answers
2
active
oldest
votes
With point at the beginning of the word you want to replace, e.g.,
foo:C-s C-w M-%Then type the replacement word, e.g.
bar, thenRET.Then follow the prompts to query-replace subsequent occurrences of
foo. (You can use!to replace all of them, for instance.)
To limit query-replace to a paragraph, you can narrow to it (C-x n n). Alternatively, just quit query-replace after that paragraph (using q), or quit it at the last replacement (.).
Explanation:
C-s starts Isearch (incremental search). An immediate C-w yanks the text from point to the end of the word at point (e.g. foo) to the search string, so C-s C-w searches for that word.
M-% while searching switches to query-replace, using the search-string as the text to replace.
A minor shortcut for this question: you can use M-% M-n instead of C-s C-w M-% if you use library Replace+ (replace+.el)
With Replace+, query-replace and similar commands provide this behavior out of the box. Just use M-n to insert the word at point - it's the default FROM pattern.
Actually, the default value can be more than just the word at point. (And you have control over it using options search/replace-region-as-default-flag,search/replace-2nd-sel-as-default-flag, and search/replace-default-fn.)
And option replace-w-completion-flag, if non-nil, provides for
minibuffer completion while you type the arguments. In that case, to
insert a SPC or TAB character, you will need to precede it by C-q.
add a comment
|
The multiple-cursors package is probably what you're looking for. You can install it using the melpa repository. Once installed, I believe the command mc/mark-next-like-this-work should do what you want. Then you can bind it to some custom keybinding like C-d:
(define-key global-map (kbd "C-d") 'mc/mark-next-like-this-word)
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%2f52898%2fselecting-next-occurrence-of-word-incrementally%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
With point at the beginning of the word you want to replace, e.g.,
foo:C-s C-w M-%Then type the replacement word, e.g.
bar, thenRET.Then follow the prompts to query-replace subsequent occurrences of
foo. (You can use!to replace all of them, for instance.)
To limit query-replace to a paragraph, you can narrow to it (C-x n n). Alternatively, just quit query-replace after that paragraph (using q), or quit it at the last replacement (.).
Explanation:
C-s starts Isearch (incremental search). An immediate C-w yanks the text from point to the end of the word at point (e.g. foo) to the search string, so C-s C-w searches for that word.
M-% while searching switches to query-replace, using the search-string as the text to replace.
A minor shortcut for this question: you can use M-% M-n instead of C-s C-w M-% if you use library Replace+ (replace+.el)
With Replace+, query-replace and similar commands provide this behavior out of the box. Just use M-n to insert the word at point - it's the default FROM pattern.
Actually, the default value can be more than just the word at point. (And you have control over it using options search/replace-region-as-default-flag,search/replace-2nd-sel-as-default-flag, and search/replace-default-fn.)
And option replace-w-completion-flag, if non-nil, provides for
minibuffer completion while you type the arguments. In that case, to
insert a SPC or TAB character, you will need to precede it by C-q.
add a comment
|
With point at the beginning of the word you want to replace, e.g.,
foo:C-s C-w M-%Then type the replacement word, e.g.
bar, thenRET.Then follow the prompts to query-replace subsequent occurrences of
foo. (You can use!to replace all of them, for instance.)
To limit query-replace to a paragraph, you can narrow to it (C-x n n). Alternatively, just quit query-replace after that paragraph (using q), or quit it at the last replacement (.).
Explanation:
C-s starts Isearch (incremental search). An immediate C-w yanks the text from point to the end of the word at point (e.g. foo) to the search string, so C-s C-w searches for that word.
M-% while searching switches to query-replace, using the search-string as the text to replace.
A minor shortcut for this question: you can use M-% M-n instead of C-s C-w M-% if you use library Replace+ (replace+.el)
With Replace+, query-replace and similar commands provide this behavior out of the box. Just use M-n to insert the word at point - it's the default FROM pattern.
Actually, the default value can be more than just the word at point. (And you have control over it using options search/replace-region-as-default-flag,search/replace-2nd-sel-as-default-flag, and search/replace-default-fn.)
And option replace-w-completion-flag, if non-nil, provides for
minibuffer completion while you type the arguments. In that case, to
insert a SPC or TAB character, you will need to precede it by C-q.
add a comment
|
With point at the beginning of the word you want to replace, e.g.,
foo:C-s C-w M-%Then type the replacement word, e.g.
bar, thenRET.Then follow the prompts to query-replace subsequent occurrences of
foo. (You can use!to replace all of them, for instance.)
To limit query-replace to a paragraph, you can narrow to it (C-x n n). Alternatively, just quit query-replace after that paragraph (using q), or quit it at the last replacement (.).
Explanation:
C-s starts Isearch (incremental search). An immediate C-w yanks the text from point to the end of the word at point (e.g. foo) to the search string, so C-s C-w searches for that word.
M-% while searching switches to query-replace, using the search-string as the text to replace.
A minor shortcut for this question: you can use M-% M-n instead of C-s C-w M-% if you use library Replace+ (replace+.el)
With Replace+, query-replace and similar commands provide this behavior out of the box. Just use M-n to insert the word at point - it's the default FROM pattern.
Actually, the default value can be more than just the word at point. (And you have control over it using options search/replace-region-as-default-flag,search/replace-2nd-sel-as-default-flag, and search/replace-default-fn.)
And option replace-w-completion-flag, if non-nil, provides for
minibuffer completion while you type the arguments. In that case, to
insert a SPC or TAB character, you will need to precede it by C-q.
With point at the beginning of the word you want to replace, e.g.,
foo:C-s C-w M-%Then type the replacement word, e.g.
bar, thenRET.Then follow the prompts to query-replace subsequent occurrences of
foo. (You can use!to replace all of them, for instance.)
To limit query-replace to a paragraph, you can narrow to it (C-x n n). Alternatively, just quit query-replace after that paragraph (using q), or quit it at the last replacement (.).
Explanation:
C-s starts Isearch (incremental search). An immediate C-w yanks the text from point to the end of the word at point (e.g. foo) to the search string, so C-s C-w searches for that word.
M-% while searching switches to query-replace, using the search-string as the text to replace.
A minor shortcut for this question: you can use M-% M-n instead of C-s C-w M-% if you use library Replace+ (replace+.el)
With Replace+, query-replace and similar commands provide this behavior out of the box. Just use M-n to insert the word at point - it's the default FROM pattern.
Actually, the default value can be more than just the word at point. (And you have control over it using options search/replace-region-as-default-flag,search/replace-2nd-sel-as-default-flag, and search/replace-default-fn.)
And option replace-w-completion-flag, if non-nil, provides for
minibuffer completion while you type the arguments. In that case, to
insert a SPC or TAB character, you will need to precede it by C-q.
edited Sep 30 at 14:06
answered Sep 30 at 1:06
DrewDrew
53.2k4 gold badges70 silver badges127 bronze badges
53.2k4 gold badges70 silver badges127 bronze badges
add a comment
|
add a comment
|
The multiple-cursors package is probably what you're looking for. You can install it using the melpa repository. Once installed, I believe the command mc/mark-next-like-this-work should do what you want. Then you can bind it to some custom keybinding like C-d:
(define-key global-map (kbd "C-d") 'mc/mark-next-like-this-word)
add a comment
|
The multiple-cursors package is probably what you're looking for. You can install it using the melpa repository. Once installed, I believe the command mc/mark-next-like-this-work should do what you want. Then you can bind it to some custom keybinding like C-d:
(define-key global-map (kbd "C-d") 'mc/mark-next-like-this-word)
add a comment
|
The multiple-cursors package is probably what you're looking for. You can install it using the melpa repository. Once installed, I believe the command mc/mark-next-like-this-work should do what you want. Then you can bind it to some custom keybinding like C-d:
(define-key global-map (kbd "C-d") 'mc/mark-next-like-this-word)
The multiple-cursors package is probably what you're looking for. You can install it using the melpa repository. Once installed, I believe the command mc/mark-next-like-this-work should do what you want. Then you can bind it to some custom keybinding like C-d:
(define-key global-map (kbd "C-d") 'mc/mark-next-like-this-word)
answered Sep 29 at 23:30
JesseJesse
1,7246 silver badges15 bronze badges
1,7246 silver badges15 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%2f52898%2fselecting-next-occurrence-of-word-incrementally%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
Yes it was what I said in the second sentence. By "at" I mean "at the beginning" or "at the end". Have rephrased the question so it is clearer and doesn't risk being closed.
– Saurabh
Sep 29 at 23:21