search

Home  >  Q&A  >  body text

gvim - VIM's %< variable substitution problem

How to replace %<with file name.data?

For example, replace the above %<.data with the following file name.data

为情所困为情所困2776 days ago851

reply all(4)I'll reply

  • 高洛峰

    高洛峰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
    

    reply
    0
  • 仅有的幸福

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

    I think if you can find the answer online, you don’t need to come here to ask

    reply
    0
  • PHPz

    PHPz2017-05-16 16:41:25

    Enter command line mode

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

    reply
    0
  • 阿神

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

    Use this command:

    Result after

    Enter:

    reply
    0
  • Cancelreply