Find and replace with a newline in Visual Studio Code

后端 未结 9 840
囚心锁ツ
囚心锁ツ 2020-12-04 04:43

I am trying out the new Microsoft Visual Studio Code editor in Linux Fedora environment. I would like to know how to replace new line (\\n) in place of some other text.

相关标签:
9条回答
  • 2020-12-04 05:15

    With VS Code release 1.38 you can press CTRL + Enter in the editor find box to add a newline character.

    With VS Code release 1.30 you can type Shift + Enter in the search box to add a newline character without needing to use regex mode.

    Since VS Code release 1.3, the regex find has supported newline characters. To use this feature set the find window to regex mode and use \n as the newline character.

    0 讨论(0)
  • 2020-12-04 05:19

    with v1.31.1 in RegEx mode the Replace All functionality is broken. clicking that button replaces only one instance

    0 讨论(0)
  • 2020-12-04 05:22

    Also note, after hitting the regex icon, to actually replace \n text with a newline, I had to use \\n as search and \n as replace.

    0 讨论(0)
  • 2020-12-04 05:22
    • Control F for search, or Control Shift F for global search
    • Replace >< by >\n< with Regular Expressions enabled

    0 讨论(0)
  • 2020-12-04 05:25

    In version 1.1.1:

    • Ctrl+H
    • Check the regular exp icon .*
    • Search: ><
    • Replace: >\n<
    0 讨论(0)
  • 2020-12-04 05:36

    CTRL + H, then select regex (*) and write \n

    Shorter version: CTRL+H ALT+R \n

    0 讨论(0)
提交回复
热议问题