Skip to main content

Questions tagged [replace]

Overwriting text with the r or R commands. For search-and-replace operations, use the [substitute] tag.

Filter by
Sorted by
Tagged with
1 vote
2 answers
112 views

I have many files with lists of words like this: list word1 word2 word3 word4 which I would like to transform to a single line, like this list word1, word2, word3, word4 I would like to do this ...
cdek's user avatar
  • 23
1 vote
1 answer
65 views

This expression, run interactively within Vim: :%s/ \v(\w+('\w+)*)\_s\1/ \1/gi It removes needless repetition of words. In this way it turns this: the the it it them them it's it's then then and this ...
Kes's user avatar
  • 729
1 vote
3 answers
376 views

I want to paste data from clipboard. But instead of insert the data, I want to overwrite (like using R).
Andy A.'s user avatar
  • 233
1 vote
1 answer
88 views

Is it possible to transform: John Apple Red 3 John Apple Green 5 John Radish White 2 John Radish Red 7 Tom Apple Red 3 Tom Apple Green 5 Tom Radish White 2 Tom Radish Red 7 to: John Apple Red 3 ...
athos's user avatar
  • 359
0 votes
5 answers
1k views

I'm a new Vim user, so please bear with me. A while ago I wanted to be able to replace a pattern with user input, and I stumbled upon this question on StackOverflow, and its answer worked beautifully. ...
Szpilman's user avatar
1 vote
3 answers
478 views

I have UTF-8 encoded HTML with id(s) and href(s) encoded as hex values like %D0%B0%D0%B1 or .D0.B0.D0.B1. Can I convert such strings into readable form using Vim?
hobo-mts's user avatar
  • 133
-1 votes
1 answer
28 views

To match the string behind the : : TE: trailer The expression will convert the string into trailer: :1s/\v(.{-}):\s{1,}(.{-})/\2/ Why 1s/\v(.{-}):\s{1,}(.{-})/\2""/ convert the string ...
showkey's user avatar
  • 1,146
1 vote
2 answers
1k views

In this clip, From visual mode here after selecting im.g.mat I trigger my vnoremap <m-/> y:%s/<c-r>0//g<left><left> bind. The purpose of this bind is to initiate a global file ...
Steven Lu's user avatar
  • 2,331
3 votes
1 answer
76 views

I have a file that has so many persian/arabic digits in it. I would like to replace them with their English counterparts. How is that possible?
yukashima huksay's user avatar
0 votes
1 answer
518 views

I have a tsv file that has the header separated by tabs but each row is separated by one or more tabs. The parser/viewer I'd like to use doesn't understand that the values are separated by a series of ...
Charles Coulter's user avatar
0 votes
4 answers
578 views

I'll try to illustrate as clear as I can. Suppose I have the following text open in vim/nvim _________ | | | 9999 | | | --------- If select 9999 visually and then hit r8, this ...
Diwas's user avatar
  • 145
1 vote
0 answers
35 views

I have such codes: int flag1 = GetWidget(widget); flag1.append(widget); delete widget; I'm willing to swap every flag1 and widget in the whole text, i.e.: int widget = GetWidget(flag1); widget.append(...
Mactarvish's user avatar
2 votes
1 answer
5k views

I have used curl to grab a website's code and put it in a text file. I'd like to delete all text that isn't a link! Lucky for me, all links are inside quotes, so I just need to delete all lines ...
ex7lted's user avatar
  • 37
0 votes
1 answer
42 views

I have the following string, where I want to change the number "merged_boris_20220712.boris". If instead of underscores it had dashes, I would just go to the numbers and do ciw and type the ...
fbence's user avatar
  • 739
1 vote
1 answer
103 views

I have some inoremap's in my vimrc, such as inoremap \c <c-v>u2705 which enters a ✅ emoji for when I am writing checklists. However, I noticed that while I am able to use it when in insert mode ...
WalksB's user avatar
  • 527
1 vote
1 answer
62 views

I am using vim to write a document in Latex. I have to replace a regex with the italic code, which is \textit{regex}. I use the Vim code: :%s/regex/\textit\{regex\}/g But the \t expression is ...
Drosera_capensis's user avatar
0 votes
1 answer
2k views

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 ...
tre332sju's user avatar
1 vote
1 answer
73 views

what is the global command that will join lines that start with more than one space? I have tried this but it does not work as expected: :g/ \{2,}//J Example: I want to turn this: 01:001:001 In the ...
Jan P's user avatar
  • 31
0 votes
1 answer
98 views

I would like to have something in .vimrc where when I type (( in insert mode, it automatically converts that into \left( | \right) with the cursor position at | in insert mode. Any ideas? I also would ...
Tom's user avatar
  • 379
3 votes
2 answers
626 views

It is possible in vanilla vim to: visual select some number of characters, e.g. a variable name in code type c to begin replacing selection in insert mode type a replacement (variable name) exit ...
Steven Lu's user avatar
  • 2,331
5 votes
1 answer
2k views

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 ...
Ramanjaneyulu Gudipati's user avatar
2 votes
3 answers
667 views

In Python, I am trying to update my code from typed dict to dataclass. Language is just indicated as a reference, it is a pure Vim question. I need to replace my_params["some_property"] ...
Lionel Hamayon's user avatar
0 votes
1 answer
736 views

Why does replacement of something by using :%s/,/\n/gc in vim gives me ^@ instead of giving me newline. Sed replacement works perfectly sed s/,/'\n'/g. Any idea how to do sed thingy in Vim and save ...
Machinexa's user avatar
  • 103
0 votes
2 answers
84 views

So I have a case where I have some unicode letters say [B, Ḅ, Ḃ] and when I have my mouse selected over the B, (in normal mode) I want some way of cycling through the list. Like pressing some command ...
N3buchadnezzar's user avatar
1 vote
1 answer
47 views

My file working.txt has 1000's of lines, which repeat in a simple pattern as follows: name date_ax name date_cd name date_ed name date_dc ...etc I need to replace each instance of name with the ...
Kes's user avatar
  • 729

1
2 3 4 5 6