gpt4 book ai didi

vim - 仅复制不带扩展名的文件名到系统剪贴板

转载 作者:行者123 更新时间:2023-12-02 15:30:19 24 4
gpt4 key购买 nike

有没有办法只将文件名复制/拉到剪贴板?根据这些来源:
Yank file name / path of current buffer in Vim
How can I expand the full path of the current file to pass to a command in Vim?
Get name of the current file in Vim
很明显 expand() 是要使用的函数,可以定义以下内容:

" Full path
nnoremap <leader><leader>f :let @* = expand("%:p")<CR>
" File name, with extension.
nnoremap <leader><leader>n :let @* = expand("%:t")<CR>
" Extension.
nnoremap <leader><leader>e :let @* = expand("%:t:e")<CR>
" Parent directory, full.
nnoremap <leader><leader>p :let @* = expand("%:p:h")<CR>

但是,我没有找到只复制文件名的方法。我的意思是文件名没有扩展名。这可能吗?我尝试了 "%""%:。都没有用。

最佳答案

expand("%:t:r")

做你想做的事,但凯文提出了非常好的观点。

参见:help filename-modifiers

关于vim - 仅复制不带扩展名的文件名到系统剪贴板,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27448157/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com