Linked Questions

3 votes
4 answers
988 views

Vim search and replace "/" only from string between round bracket [duplicate]

I have string lets say count number of elecment when tra(XYixe0/en_in/old)='mid/2' rise='corse/2' I want to replace / from (XYixe0/en_in/old) to . My output string should look like count number of ...
Nikhilesh Sarish Kulkarni's user avatar
3 votes
2 answers
1k views

Multiple or divide number under cursor with given amount and replace it with the result

I can increment the number under the cursor (by e.g. 10) by doing 10<C-a> But how do I multiply the number under the cursor with x amount and the replace it in the same way I do when ...
Sebastian Nielsen's user avatar
1 vote
1 answer
865 views

Replace a character multiple times but within pattern

I am creating a yml file out of some variables. I have like 80 lines and they all have the pattern: my-first-command-line-var: {{ my-first-command-line-var }}, my-second-cli-var: {{ {{ my-second-cli-...
transient_loop's user avatar
5 votes
1 answer
169 views

Can I replace two distinct old strings with two distinct new strings using a single :s command?

Suppose I have the following line of text in vim: hello, it will be sunny today and I want to change it to: goodbye, it will be sunny tomorrow I could put my cursor on the line and type :s/hello/...
user38475's user avatar
2 votes
1 answer
150 views

Increment numbers found in search results, using search result number as an iterator

Suppose I have a file and littered throughout are a bunch of placeholder strings for images, they all have img1.gif at present. Is there a way to search for that string and increment the number each ...
Ben Frain's user avatar
  • 217
3 votes
2 answers
73 views

Is it possible to make a substitution command that preserves the case of the matched pattern?

Consider the following constant definition: define("_TBL_USERS","users"); Now, I want to transform it into: define("_TBL_USER_ITEMS","user_items"); I tried ...
l00p's user avatar
  • 253
1 vote
1 answer
94 views

Configure Vim 8 behavior regarding substitution in visual selection

When I select a section of text within a line, then indicate I want to substitute on that line with :s, the result is that the entire line is affected. In order to actually do what I intend, I have to ...
chb's user avatar
  • 136
1 vote
1 answer
113 views

Vim decremental replace not working

I want to replace the lines : https://www.dailymotion.com/video/whatever_1 # The Serie - S2 E4 - Grin and Bear It https://www.dailymotion.com/video/whatever_2 # The Serie - S2 E3 - Betty's Wait ...
SebMa's user avatar
  • 2,878
1 vote
1 answer
82 views

Is it possible to apply substitutions on parts of lines, instead of whole lines?

I have some text like this. a x="true" i q={1} That is, a line of text prefixed with 4 space characters. Then letters with spaces in between. I'd like to transform the text to this a x="...
425nesp's user avatar
  • 586
1 vote
1 answer
54 views

Substitution within substitution? Replace with the result of a substitution operation on matched group

I would like to turn a list like this these are custom regex expressions 4 syntax? syntax weird one 3 there are many many many many words in this line 3 into this these are custom {4}regex {4}...
minseong's user avatar
  • 2,291
0 votes
1 answer
34 views

Substitute in multiple isolated parts of a string

I have this string: b'32^"Strings" c32 d32 c32 b32 r8. \break I want to replace [a-z] (except r) with r and remove ' everywhere outside "..". I want to ignore \break. Final output ...
kargirwar's user avatar
  • 145