Questions tagged [search-replace]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
2 votes
1 answer
175 views

Keep specific parts of a :s command in nvim

What I'm trying to do is convert between Textile and Markdown links, so it should be able to do something like :s/".*"(.*)/[.*](.*)/, which is to say, keep the stuff that is matched by the .*...
user avatar
  • 25
1 vote
0 answers
16 views

Search and replace with regex in the replacement [duplicate]

I would like to replace all instances of match("something") with match("something", source). However, using :%s/match(.*)/match(.*,\ source)/g replaces it by match(.*, source). ...
user avatar
1 vote
2 answers
40 views

Vim find and replace with filename as variable

Is it possible to use vim find and replace to replace a variable with the current filename? for example, fancyFileName.txt contains this is the VARIABLE to replace in this fancyFileName.txt and I am ...
user avatar
  • 147
1 vote
1 answer
39 views

add quotes to each string and change the delimiter for a comma

I have this string: private | public-read | public-read-write | authenticated-read | aws-exec-read | bucket-owner-read | bucket-owner-full-control I would like to find a mnemonic or easy pattern that ...
user avatar
  • 111
0 votes
0 answers
12 views

search-replace see number of changes [duplicate]

Is there an easy way to configure search-replace to show the number of changes that a search and replace made? My current way of doing it is to do the search and replace, and then undo and redo the ...
user avatar
0 votes
1 answer
90 views

VIM search and replace regex - how to keep the search string intact and adding to it?

I'd like to learn how to search and replace in VIM - keeping the search string intact and adding to it. Take this as a simple example. See image below. I copied a simple python script written for ...
user avatar
3 votes
1 answer
303 views

Match one regex pattern if not preceded by another one

I'm trying to match \item \macro{this\var}.% YYYY-MM-01 where 01 can be 1 and replace with \item The Month is MM \item \macro{this\var}.% YYYY-MM-01 when NOT this case: \item MonthYY \item \macro{...
user avatar
0 votes
1 answer
56 views

Transform text that matches a pattern to uppercase

Searching /<pattern> in a document highlights text in some places like this: some text ... match1 some text ... some text match2 ... match3 text match4 ... Is there a way to make all the ...
user avatar
3 votes
2 answers
430 views

How do I replace single whitespaces without affecting multi-whitespace such as indentation in Vim?

I have textfiles with paths that have lost underscores between words inline in an OCR process. I want to keep the indentation and put back the underscores in the paths. I have a path like this: /...
user avatar
4 votes
1 answer
184 views

Search and Replace on odd/even numbered lines using g

I was looking for ways to search and replace on even/odd numbered lines in vim and I came across some solution on google groups https://groups.google.com/g/comp.editors/c/xk9DMoszgq4. To search and ...
user avatar
0 votes
1 answer
31 views

Interrupt a global search and replace with confirmation

Far too often, I've started a global search replace with confirmation, and discovered part way thru that I should have done a different search. Here's a silly example he he1 he the2 he them ...
user avatar
  • 635
0 votes
2 answers
55 views

Illegal back reference when trying to delete \1

I have a bunch of expressions (matlab anonymous functions) of the form, for example `f\^I = @(x,y,z) x^y + z`, `g1\^I\^I = @(z,b,c) z^b + c` (where \^I means a tab, but I can't just write that in ...
user avatar
  • 635