Skip to main content
Share Your Experience: Take the 2024 Developer Survey

Questions tagged [substitute]

Any operation involving regular expression based substitution of text, such as the ex-mode `:s` command. Not to be confused with the [replace] tag.

12 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
7 votes
0 answers
377 views

In a regex, why aren't the multi + and {1,} always parsed exactly the same way?

From :h /\+: \+ Matches 1 or more of the preceding atom, as many as possible. And :h /\{: \{n,} Matches at least n of the preceding atom, as many as possible It seems the multi + and {1,} have ...
user9433424's user avatar
  • 6,148
3 votes
0 answers
63 views

How do I capitalize first character after a special character?

I want to convert "abc_def_ghi ( abc_def_ghi )" to "abc_def_ghi ( abcDefGhi )". Note: If I visually select the string within (), the below command changes whole line instead of the ...
Fisher's user avatar
  • 1,086
2 votes
0 answers
551 views

neovim hlsearch not working

I'm testing neovim and for many thing it is working way faster than vim (I use many plugins ~80, and I can really tell the difference with neovim). All the same config files worked out of the box, but ...
Blasco's user avatar
  • 275
1 vote
0 answers
32 views

After `:%s` substitution the syntax highlighting of my R code has changed

Preface: VIM beginner, and I suspect this question will evolve significantly as I understand more about it (and VIM). Documenting the issue here as I was unable to find any other references to "...
Owen's user avatar
  • 111
1 vote
0 answers
75 views

Is there an `edefault` in the spirit of `gdefault` for setting the appropriate flags in vim's substitution commands?

To perform a buffer-wide substitution on all occurrences of foo (and not just the 1st one in a line), we can do %s/foo/bar/g The g flag may be omitted by setting this in the vimrc as set ...
Dr Krishnakumar Gopalakrishnan's user avatar
1 vote
0 answers
105 views

search and replace: remember case in substitute

I have to change strings: fetchrandomData to fetchReportingData FETCH_RANDOM_DATA to FETCH_REPORTING_DATA I can change ca_z and CA_Z to ca_t and CA_T respectively with command: %s/\v([Cc])([Az])(_)?...
HarshvardhanSharma's user avatar
1 vote
0 answers
74 views

parameter substitution template plugin

I would like to find a plugin, what can do the following in normal mode of vim: Parameter initialization Parameter substitution into text based on templates Suppose we have many sql query where ...
user647314's user avatar
1 vote
0 answers
45 views

mapping with multiple substitutes inserts just a newline with 'R'

I have this mapping in my vimrc: nnoremap <F3> :%s/ä/\\"{a}/g<CR> :%s/ö/\\"{o}/g<CR> :%s/ü/\\"{u}/g<CR> :%s/ß/\ss{}/g<CR> after executing it, an 'R' is inserted above ...
uuu's user avatar
  • 547
0 votes
0 answers
36 views

Custom indent minified file

At work I'm forced to work on custom mapping-files which map relations between objects of different systems. These mappings, which are basically Jinja templates, are unfortunately stored in single ...
Philipp Heller's user avatar
0 votes
0 answers
2k views

Replace with another word on the screen

Sometimes I find it convenient to Search for text I want to replace /original Start writing a substitution to replace that :s/ Use C-r C-w to put the current word hovered into the command line :s/...
minseong's user avatar
  • 2,333
0 votes
0 answers
37 views

Search and replace any number separated by : trailing with number or alphabet separated by . and / or - or _

Search pattern examples "0:4.10.5-5.el7" "0:0.7.7-13.20120626.ov7" "6:4.14.8-6.po7_3" How to search and print all occurrences like above patterns where the first number can be any number ranging ...
hellomister's user avatar
-2 votes
1 answer
69 views

How to replace *_Apple to Apple using VI?

I need to replace multiple lines using vi. For example, any numbers_Apple to Apple 0001_Apple 0010_Apple 1021_Apple … 8383_Apple to Apple
John Lee's user avatar