gvim - VIM的%<变量替换问题
为情所困
为情所困 2017-05-16 16:39:25
[PhpStudy讨论组]

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

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

为情所困
为情所困

全部回复(4)
高洛峰

: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
仅有的幸福

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

PHPz

进入命令行模式

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

用这个命令:

Enter之后的结果:

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号