V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
deyilee
V2EX  ›  问与答

vscode 中 vim 的换行替换

  •  
  •   deyilee · 2020 年 7 月 1 日 · 2286 次点击
    这是一个创建于 2028 天前的主题,其中的信息可能已经有所发展或是发生改变。

    一直习惯在 vscode 中使用 vim 模式,但是有个问题直接很困扰,就是无法替换换行符。

    比如在 normal 模式下,我可以匹配换行符“/\n”,但是无法替换换行符“:%s/\n/qwe/g”。

    请问有人知道怎么在 vscode 的 vim 模式下替换\n 吗?

    8 条回复    2021-01-26 15:47:09 +08:00
    JackieMe
        1
    JackieMe  
       2020 年 7 月 1 日
    Debian 下试了一下我可以哈

    ```
    VIM - Vi IMproved 8.2 (2019 Dec 12, compiled May 12 2020 02:37:13)
    Included patches: 1-716
    Modified by [email protected]
    Compiled by [email protected]
    ```
    Guosch
        2
    Guosch  
       2020 年 7 月 1 日 via Android
    替换的时候试试用 \r 匹配换行符
    justgodlike1993
        3
    justgodlike1993  
       2020 年 7 月 1 日
    试试 %s/\r\n//g 或者%s/\r//g
    volvo007
        4
    volvo007  
       2020 年 7 月 2 日
    同意楼上,win/Linux/Mac 的换行符都不同,win 下可以试试 \r\n
    deyilee
        5
    deyilee  
    OP
       2020 年 7 月 3 日
    @volvo007 都不行哦...
    deyilee
        6
    deyilee  
    OP
       2020 年 7 月 3 日
    @justgodlike1993 都不行哦...
    deyilee
        7
    deyilee  
    OP
       2020 年 7 月 3 日
    @Guosch 都不行哦...
    xianyukang
        8
    xianyukang  
       2021 年 1 月 26 日
    vscode 总是有各种让人抓狂的毛病 (让强迫症想砸屏幕的垃圾设计)
    ① vscode vim 不支持换行符 :%s/\n/fuck/g 替换
    ② vscode 的 ctrl+z 撤销粒度太大, 撤销过头了, 又得重写一遍
    ③ vscode 不支持关闭程序重启后恢复 undo history (vim 就能通过设置支持)
    关于   ·   帮助文档   ·   自助推广系统   ·   博客   ·   API   ·   FAQ   ·   Solana   ·   955 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 21:32 · PVG 05:32 · LAX 13:32 · JFK 16:32
    ♥ Do have faith in what you're doing.