En realidad, mi última respuesta no funciona porque una vez que el NERDTree haber sido abierto, no se abre de nuevo en el nuevo directorio de búfer. Debe funcionar de manera similar a NERDTreeFind, pero no tiene una característica de Alternar.
Hice una función y la asigné a mi clave y ahora funciona perfectamente incluso al abrir el proyecto Ruby si tiene el plugin vim-rails.
Agregar a su vimrc:
function! NTFinderP()
"" Check if NERDTree is open
if exists("t:NERDTreeBufName")
let s:ntree = bufwinnr(t:NERDTreeBufName)
else
let s:ntree = -1
endif
if (s:ntree != -1)
"" If NERDTree is open, close it.
:NERDTreeClose
else
"" Try to open a :Rtree for the rails project
if exists(":Rtree")
"" Open Rtree (using rails plugin, it opens in project dir)
:Rtree
else
"" Open NERDTree in the file path
:NERDTreeFind
endif
endif
endfunction
"" Toggles NERDTree
map <silent> <F1> :call NTFinderP()<CR>
Debería funcionar ahora.
continuación
respuesta anterior:
Se puede asignar la clave que se utiliza para abrir NERDTree como esto (en .vimrc):
map <silent> <F1> :NERDTreeToggle %:p:h<CR>
Esto mapea mi tecla F1 para alternar (abrir/cerrar) NERDTree utilizando la ruta del búfer activo actualmente. Si no hay ningún búfer abierto, se abre en el directorio Macvim actualmente en ejecución.
1 mucho solución más limpia que la mía :) – kfl62