What Vim command(s) can be used to quote/unquote words?

前端 未结 16 888
余生分开走
余生分开走 2020-12-12 08:36

How can I quickly quote/unquote words and change quoting (e.g. from \' to \") in Vim? I know about the surround.vim plugin, but I would like to use

16条回答
  •  春和景丽
    2020-12-12 09:31

    In addition to the other commands, this will enclose all words in a line in double quotes (as per your comment)

    :s/\(\S\+\)/"\1"/
    

    or if you want to reduce the number of backslashes, you can put a \v (very-magic) modifier at the start of the pattern

    :s/\v(\S+)/"\1"/
    

提交回复
热议问题