Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/vim/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何获取:bwipe*.ext以擦除与vim中的通配符匹配的所有人_Vim - Fatal编程技术网

如何获取:bwipe*.ext以擦除与vim中的通配符匹配的所有人

如何获取:bwipe*.ext以擦除与vim中的通配符匹配的所有人,vim,Vim,我经常想擦除加载了给定扩展名的所有缓冲区(通常是补丁程序生成的.rej文件)。正在做:bw[!]*。如果有多场比赛,rej会抱怨。有人有什么好的建议吗?目前,我反复使用:bw*.rej+tab complete,或者,如果有很多缓冲区,则使用:ls和:bw一组按编号排列的缓冲区。在vim中进行全局绑定有点困难(除了文件系统上的文件)。因此,最好的方法似乎是将通配符转换为正则表达式,然后检查缓冲区列表中的每个缓冲区是否匹配。大概是这样的: " A command to make invocatio

我经常想擦除加载了给定扩展名的所有缓冲区(通常是补丁程序生成的.rej文件)。正在做:bw[!]*。如果有多场比赛,rej会抱怨。有人有什么好的建议吗?目前,我反复使用:bw*.rej+tab complete,或者,如果有很多缓冲区,则使用:ls和:bw一组按编号排列的缓冲区。

在vim中进行全局绑定有点困难(除了文件系统上的文件)。因此,最好的方法似乎是将通配符转换为正则表达式,然后检查缓冲区列表中的每个缓冲区是否匹配。大概是这样的:

" A command to make invocation easier
command! -complete=buffer -nargs=+ BWipe call BWipe(<f-args>)

function! BWipe(...)
    let bufnames = []
    " Get a list of all the buffers
    for bufnumber in range(0, bufnr('$'))
        if buflisted(bufnumber)
            call add(bufnames, bufname(bufnumber))
        endif
    endfor
    for argument in a:000
        " Escape any backslashes, dots or spaces in the argument
        let this_argument = escape(argument, '\ .')
        " Turn * into .* for a regular expression match
        let this_argument = substitute(this_argument, '\*', '.*', '')

        " Iterate through the buffers
        for buffername in bufnames
            " If they match the provided regex and the buffer still exists
            " delete the buffer
            if match(buffername, this_argument) != -1 && bufexists(buffername)
                exe 'bwipe' buffername
            endif
        endfor
    endfor
endfunction
或:


在vim中进行全局绑定有点困难(除了文件系统上的文件)。因此,最好的方法似乎是将通配符转换为正则表达式,然后检查缓冲区列表中的每个缓冲区是否匹配。大概是这样的:

" A command to make invocation easier
command! -complete=buffer -nargs=+ BWipe call BWipe(<f-args>)

function! BWipe(...)
    let bufnames = []
    " Get a list of all the buffers
    for bufnumber in range(0, bufnr('$'))
        if buflisted(bufnumber)
            call add(bufnames, bufname(bufnumber))
        endif
    endfor
    for argument in a:000
        " Escape any backslashes, dots or spaces in the argument
        let this_argument = escape(argument, '\ .')
        " Turn * into .* for a regular expression match
        let this_argument = substitute(this_argument, '\*', '.*', '')

        " Iterate through the buffers
        for buffername in bufnames
            " If they match the provided regex and the buffer still exists
            " delete the buffer
            if match(buffername, this_argument) != -1 && bufexists(buffername)
                exe 'bwipe' buffername
            endif
        endfor
    endfor
endfunction
或:


顺便说一句,我最终选择了一个技术含量很低的解决方案(我个人喜欢尽可能少地修改vim,这样我就可以在任何机器上都能自如地使用):

我添加了一个映射:

:map:bw*.rej

然后我反复按

顺便说一句,我最终选择了一个技术含量非常低的解决方案(我个人喜欢尽可能少地修改vim,这样我就可以在任何机器上都能自如地使用):

我添加了一个映射:

:map:bw*.rej

然后我反复按

听起来您可能需要编写(或找到)一个插件来完成此操作:bwipe只接受您体验过的
bufname
。听起来您可能需要编写(或找到)一个插件来完成此操作:bwipe只接受您所经历的
bufname
。听起来很合理。我通过将整个
.vim
(或Windows上的vim文件)和vimrc置于可用的anywhere版本控制下,解决了“任何机器都在家”的问题。这样,我所做的任何更改都会被推送到我正在使用的任何一台机器(或U盘)上。听起来很合理。我通过将整个
.vim
(或Windows上的vim文件)和vimrc置于可用的anywhere版本控制下,解决了“任何机器都在家”的问题。这样,我所做的任何更改都会被推送到我正在使用的任何一台机器(或U盘)。
:BWipe *.c *.h