You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be rad if :NERDTreeFind would open NERDTree and focus on the parent directory when I run it in a buffer that has a new file that doesn't yet exist on disk.
Elaboration
I have several custom commands :EditFiletypePlugin, :EditSyntaxPlugin, :EditIndentPlugin that open my local ~/.vim/{ftplugin,syntax,indent}/&ft.vim. Sometimes there's no local plugin for this filetype, but vim's global one includes a different (like syntax/git.vim includes syntax/diff.vim), and I have a local override for that one.
So when I :EditSyntaxPlugin and I get a new file ~/.vim/syntax/git.vim, but I want to instead edit ~/.vim/syntax/diff.vim (which exists), I try to use :NERDTreeFind so I could look at the files in the same folder.
Unfortunately :NERDTreeFind tells me "NERDTree: invalid path".
I could do :NERDTreeFind %:h, but
I have a mapping f for :NERDTreeFind, and I'd have to come up with a different key for the :%h variation (or construct elaborate mappings that check for the existence of the file, hmmm)
I would like NERDTree to also open the directory and show me what's inside, which the %:h version doesn't currently do
The text was updated successfully, but these errors were encountered:
If file path doesn't exist, :NERDTreeFind its parent directory instead
This still errs on empty unnamed buffers (new tabs, diffs, etc). I wanted NERDTreeFind to fallback to NERDTree in any case, so I came up with this snippet:
nmap<mykey>:call NERDTreeFindOrOpen()<CR>function!NERDTreeFindOrOpen()
if &modifiable&&!empty(expand('%:p'))
NERDTreeFind
else
NERDTree
endifendfunction
&modifiable makes it ignore help/etc buffer paths
%:p means file path
You may experiment with NERDTreeFocus or NERDTreeVCS instead of NERDTree
Description
It would be rad if :NERDTreeFind would open NERDTree and focus on the parent directory when I run it in a buffer that has a new file that doesn't yet exist on disk.
Elaboration
I have several custom commands :EditFiletypePlugin, :EditSyntaxPlugin, :EditIndentPlugin that open my local ~/.vim/{ftplugin,syntax,indent}/&ft.vim. Sometimes there's no local plugin for this filetype, but vim's global one includes a different (like syntax/git.vim includes syntax/diff.vim), and I have a local override for that one.
So when I :EditSyntaxPlugin and I get a new file ~/.vim/syntax/git.vim, but I want to instead edit ~/.vim/syntax/diff.vim (which exists), I try to use :NERDTreeFind so I could look at the files in the same folder.
Unfortunately :NERDTreeFind tells me "NERDTree: invalid path".
I could do :NERDTreeFind %:h, but
The text was updated successfully, but these errors were encountered: