以下に例を示します。
img http://dl.dropboxusercontent.com/u/62862049/Screenshots/j6.png
実行するマッピングを作成する方法はrm contas.ls
?
以下に例を示します。
img http://dl.dropboxusercontent.com/u/62862049/Screenshots/j6.png
実行するマッピングを作成する方法はrm contas.ls
?
: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
ただし、ドキュメントを読んでください。保存場所などを教えてくれます。付属のスクリプトファイルを突き破ることもできます。すべて折りたたんだときに非常に簡単にスキャンできる折り目に設定されています.
NERDTree にはメニュー システムがあります。Nerdtree buffer pressm
にメニューが表示されます。
したがって、次のようなマッピングを作成できます。
map <buffer> ,d mdy
選択したファイルを削除します。これにより、実際にメニューがトリガーされます。
メニューを起動せずに静かにファイルを削除したい場合は、次のことができます。
map <buffer> ,d :call g:NERDTreeFileNode.GetSelected().delete()|call NERDTreeRender()<cr>
nerdtree バッファーのみに影響するように、autocmd にマッピングを配置することができます。
質問のような最も単純なケースでは、次のことができます。
:!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
) を試しましたか?