V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
Liam1997
V2EX  ›  问与答

Vim 如何给一个单词首尾添加符号?

  •  
  •   Liam1997 · Jan 29, 2021 · 1692 views
    This topic created in 1917 days ago, the information mentioned may be changed or developed.

    例如,在写 Markdown 格式的技术博客的时候,写了一个单词:const,后来发现需要用 `` 符号包裹起来更加规范一点。想知道用 Vim 最快给一个单词首尾添加符号的操作是什么

    7 replies    2021-01-29 12:57:26 +08:00
    dullwit
        1
    dullwit  
       Jan 29, 2021
    :%s/const/`const`/g
    Liam1997
        2
    Liam1997  
    OP
       Jan 29, 2021
    @dullwit 这个功能是实现了,但是感觉还没我现在直接用 b 、w 移动光标直接添加快
    jdhao
        3
    jdhao  
       Jan 29, 2021 via Android
    vim-surround 或者 vim-sandwich,高效添加,删除,更新各种符号,别再自己发明轮子了
    tachikomachann
        4
    tachikomachann  
       Jan 29, 2021 via Android
    vim-surround 就有了,但是由于用的太少我老是记不住按键。。
    vicesa
        5
    vicesa  
       Jan 29, 2021   ❤️ 2
    ciw""<ESC>P
    xell
        6
    xell  
       Jan 29, 2021
    如果不想为了单单这个功能装插件的话,用我这条命令吧

    vnoremap 你喜欢的快捷键 "zc`<C-R>Z`<Esc>
    Leviathann
        7
    Leviathann  
       Jan 29, 2021 via iPhone   ❤️ 1
    ysiw`
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2579 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 38ms · UTC 15:28 · PVG 23:28 · LAX 08:28 · JFK 11:28
    ♥ Do have faith in what you're doing.