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
7
votes
0
answers
373
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 ...
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 ...
2
votes
0
answers
512
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 ...
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 "...
1
vote
0
answers
72
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 ...
1
vote
0
answers
96
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])(_)?...
1
vote
0
answers
73
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 ...
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 ...
0
votes
0
answers
34
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 ...
0
votes
0
answers
1k
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/...
0
votes
0
answers
36
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 ...
-2
votes
1
answer
68
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