In Vim, how to effectively search and replace "and" with ordinary double quotes

I got this code snippet from the tutorial, and I would like to search and replace all occurrences of “and”, with the usual double quote. “How can I effectively do this in Vim?

{ "runtime": { "DDP_DEFAULT_CONNECTION_URL": "http://127.0.0.1:8100" }, "import": [ " meteor-base@1.0.4 ", " mongo@1.1.14 ", " reactive-var@1.0.11 ", " jquery@1.11.10 ", " tracker@1.1.1 ", " standard-minifier-css@1.3.2 ", " standard-minifier-js@1.2.1 ", " es5-shim@4.6.15 ", " ecmascript@0.6.1 ", " shell-server@0.2.1 " ] } 

Thanks.

+5
source share
2 answers

You can show the ascii character code with ga in normal mode.
You can also set arbitrary utf8 code with Ctrl + v uhhhh for characters with code 0000 <= hhhh <= FFFF and Ctrl + v Uhhhhhhhh for the rest in insert mode and command mode, so when you start in normal mode you need to enter, like @ shash678 answer:

:%s/ Ctrl + v u201c/"/g

+5
source

In command line mode, you can use the following command to find each occurrence of " and " (in all lines) and replace them with " :

 :%s/[""]/"/g 

EDIT:

To do this (suppose the file is open in vim):

1) press the ESC key to make sure that you are in Normal mode.

2) press :, you will notice that : appeared in the field below vim (this is the command line).

3) enter the remainder of the command to search for each occurrence of " and " (in all lines) and replace both with " .

4) press the ENTER key.

5) done! The command line will say something like made 56 substitutions on 13 lines .

+3
source

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


All Articles