-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>

nerdtree バッファーのみに影響するように、autocmd にマッピングを配置することができます。

于 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 の機能の小さなサブセットを提供します。そのサブセットに含まれないものの 1 つはD、ファイルまたはディレクトリを削除するためのマッピングです。NERDTree をインストールする前にnetrw ( :EX, :Vex, :Sex, :h netrw) を試しましたか?

于 2013-05-08T06:12:55.667 に答える