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.

9 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
2
votes
0answers
150 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
1answer
29 views

in-place replacement of code in HTML documents with TOhtml?

I'm working on some old HTML documentation, where are multiple code snippets (several lines long). I need to replace this old HTML-ized code with new one using modern styling. What I have now: ... ... ...
1
vote
1answer
53 views

Is there any way to position the cursor in a :substitute replace pattern?

I have the following line: return err And would like to replace that to: return fmt.Errorf(": %w", \1) Which is done easily with something like: :s/return \v(\k+)/return fmt.Errorf(": %w", \1)/ ...
1
vote
0answers
36 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
0answers
67 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
0answers
39 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
0answers
43 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
0answers
46 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 ...
0
votes
0answers
33 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 ...