AI编程助手
AI免费问答

gvim - VIM的%<变量替换问题

怎么将%<替换成文件名.data?

例如将上面的%<.data替换成下面的文件名.data

# PhpStudy
为情所困 为情所困 2981 天前 1009 次浏览

全部回复(4) 我要回复

  • 高洛峰

    高洛峰2017-05-16 16:41:25

    :call append(line("."), expand('%') . ' and something append')

        %       current file name
        #       alternate file name
        #n      alternate file name n
        <cfile>     file name under the cursor
        <afile>     autocmd file name
        <abuf>      autocmd buffer number (as a String!)
        <amatch>    autocmd matched name
        <sfile>     sourced script file name
        <slnum>     sourced script file line number
        <cword>     word under the cursor
        <cWORD>     WORD under the cursor
        <client>    the {clientid} of the last received
                message |server2client()|
    
    Modifiers:
        :p      expand to full path
        :h      head (last path component removed)
        :t      tail (last path component only)
        :r      root (one extension removed)
        :e      extension only
    

    回复
    0
  • 仅有的幸福

    仅有的幸福2017-05-16 16:41:25

    我觉得,网上能找到答案的,就不用来这里问了

    回复
    0
  • PHPz

    PHPz2017-05-16 16:41:25

    进入命令行模式

    :%s/%<.data/.data/g
    

    回复
    0
  • 阿神

    阿神2017-05-16 16:41:25

    用这个命令:

    Enter之后的结果:

    回复
    0
  • 取消 回复 发送