In Vim: how to change a highlighted section?

cw changes the word. Similarly, if I selected partitions in vim (found / ), how to change one of the selected partitions so that I can repeat ( . ) The process in all other selected partitions.

I know that %s will do the trick. But I wanted to do this / (visual satisfaction).

Edit:
I am looking for an expander for c like w

Edit:
I want to do something like c selected section or d selected section or y selected section, etc.

Like you, cw , dw , yw or ct" , dt" or yt"

+4
source share
4 answers

Find the text with /foo , as usual, then use c//e - but make sure you use // instead of / or n to find subsequent matches.

( //e means that the last search is repeated, but the cursor is placed at the end of the word, not at the beginning. However, the e flag is remembered for the next search, so you need to use // after.)

+3
source

If you want to visually approve each change, you can make

 :%s/old/new/gc 

Edit: Of the other answers, it sounds like there is no way to get a choice easily. Perhaps you could use the capabilities of python scripts in Vim to write a command to accomplish what you want?

+1
source

Finding a line with / does not select it - it only selects it.

To select a text area, click and drag on it or use the v , v or ctrl-v keys in normal mode (to select a normal area along lines or a rectangular area, respectively), then navigate using the normal navigation keys to expand the selection. This will bring you into visual selection mode.

When you select the selected text and are in visual selection mode, you can use the usual editing commands to change the selected text, for example. c will delete the text and put you in insert mode, y gU text, gU will change the text to uppercase, g? will be ROT13 etc.

As soon as you enter the editing command, you will return to normal mode and the visual highlight will disappear. You can re-select the same area with gv .

+1
source

Try the following:

 :s//new_value 

Why downvote? You can match something like:

 :nmap \s :s///<cr>``i 

then find the text, click on it, and you will be in insert mode, where your search text was used before. You cannot use . but you can just use n\s for the next match.

There is no inline text object describing the text found by the search, as far as I know.

0
source

Source: https://habr.com/ru/post/1299883/


All Articles