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

vscode 中 vim 的换行替换

  •  
  •   deyilee · 2020-07-01 17:37:59 +08:00 · 1551 次点击
    这是一个创建于 1393 天前的主题,其中的信息可能已经有所发展或是发生改变。

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

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

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

    8 条回复    2021-01-26 15:47:09 +08:00
    JackieMe
        1
    JackieMe  
       2020-07-01 18:50:57 +08:00
    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-07-01 19:34:27 +08:00 via Android
    替换的时候试试用 \r 匹配换行符
    justgodlike1993
        3
    justgodlike1993  
       2020-07-01 21:41:59 +08:00
    试试 %s/\r\n//g 或者%s/\r//g
    volvo007
        4
    volvo007  
       2020-07-02 10:29:47 +08:00
    同意楼上,win/Linux/Mac 的换行符都不同,win 下可以试试 \r\n
    deyilee
        5
    deyilee  
    OP
       2020-07-03 09:24:54 +08:00
    @volvo007 都不行哦...
    deyilee
        6
    deyilee  
    OP
       2020-07-03 09:25:00 +08:00
    @justgodlike1993 都不行哦...
    deyilee
        7
    deyilee  
    OP
       2020-07-03 09:25:05 +08:00
    @Guosch 都不行哦...
    xianyukang
        8
    xianyukang  
       2021-01-26 15:47:09 +08:00
    vscode 总是有各种让人抓狂的毛病 (让强迫症想砸屏幕的垃圾设计)
    ① vscode vim 不支持换行符 :%s/\n/fuck/g 替换
    ② vscode 的 ctrl+z 撤销粒度太大, 撤销过头了, 又得重写一遍
    ③ vscode 不支持关闭程序重启后恢复 undo history (vim 就能通过设置支持)
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3747 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 04:30 · PVG 12:30 · LAX 21:30 · JFK 00:30
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.