-1

举个例子:

img http://dl.dropboxusercontent.com/u/62862049/Screenshots/j6.png

如何创建将执行的映射rm contas.ls

4

3 回答 3

2
:h NERDTreeKeymapAPI

4.1. Key map API                                           *NERDTreeKeymapAPI*

NERDTreeAddKeyMap({options})                             *NERDTreeAddKeyMap()*
    Adds a new keymapping for all NERD tree buffers.
    {options} must be a dictionary, and must contain the following keys:
    "key" - the trigger key for the new mapping
    "callback" - the function the new mapping will be bound to
    "quickhelpText" - the text that will appear in the quickhelp (see
    |NERDTree-?|)

    Additionally, a "scope" argument may be supplied. This constrains the
    mapping so that it is only activated if the cursor is on a certain object.
    That object is then passed into the handling method. Possible values are:
        "FileNode" - a file node
        "DirNode" - a directory node
        "Node" - a file or directory node
        "Bookmark" - A bookmark
        "all" - the keymap is not constrained to any scope (default). When
        thei is used, the handling function is not passed any arguments.


    Example: >
        call NERDTreeAddKeyMap({
            \ 'key': 'foo',
            \ 'callback': 'NERDTreeCDHandler',
            \ 'quickhelpText': 'echo full path of current node' })
            \ 'scope': 'DirNode'

        function! NERDTreeCDHandler(dirnode)
            call a:dirnode.changeToDir()
        endfunction
<
    This code should sit in a file like ~/.vim/nerdtree_plugin/mymapping.vim.
    It adds a (redundant) mapping on 'foo' which changes vim's CWD to that of
    the current dir node. Note this mapping will only fire when the cursor is
    on a directory node.

帮助文档示例代码中有一些拼写错误('echo full path...' 如果没有,则提前结束调用一行),但这是一个工作示例:

call NERDTreeAddKeyMap({
    \ 'key': '<F3>',
    \ 'callback': 'NERDTreeExample',
    \ 'quickhelpText': 'echo full path of current node',
    \ 'scope': 'FileNode' })

function! NERDTreeExample(filenode)
    echo a:filenode.path._strForGlob()
endfunction

NERDTree中有很多功能。你可以把上面的函数改成这个来探索一下:

function! NERDTreeExample(filenode)
    echo keys(a:filenode)
endfunction

之前使用的示例path._strForGlob,我发现使用这个,一旦我确定“路径”是一个可能的候选者(那里还有很多其他内容):

function! NERDTreeExample(filenode)
    echo keys(a:filenode.path)
endfunction

不过,请阅读文档。他们告诉你在哪里保存东西,等等。你也可以浏览它附带的脚本文件。它全部设置在折叠中,折叠时很容易扫描。

于 2013-05-08T01:51:28.807 回答
2

NERDTree 有一个菜单系统。在 Nerdtree buffer pressm中,您将看到菜单。

因此,您可以创建如下映射:

map <buffer> ,d mdy

删除选定的文件。这实际上会触发菜单。

如果您想在不触发菜单的情况下静默删除文件,您可以:

map <buffer> ,d :call g:NERDTreeFileNode.GetSelected().delete()|call NERDTreeRender()<cr>

您可能希望将映射放在 autocmd 中,以便它只影响 nerdtree 缓冲区。

于 2013-05-07T22:32:55.120 回答
1

对于最简单的情况,例如您的问题,您可以执行以下操作:

:!rm filename       " works with tab completion

或者

:!rm <C-r><C-f>     " inserts the filename under the cursor

NERDTree 提供了内置 Netrw 功能的一小部分,其中不包括D用于删除文件或目录的映射。您在安装 NERDTree 之前尝试过 netrw ( :EX, :Vex, :Sex, ) 吗?:h netrw

于 2013-05-08T06:12:55.667 回答