Update directory .vimdc readme example (#961)

* set pwd for new window

* adding 'cd '.argv()[0] explination

* spacing

* exe

* [0]
This commit is contained in:
Spencer 2019-03-05 09:25:49 -07:00 committed by Phil Runninger
parent 84737f2ebe
commit e1916d6fe7

View File

@ -64,10 +64,12 @@ Note: Now start vim with plain `vim`, not `vim .`
> How can I open NERDTree automatically when vim starts up on opening a directory? > How can I open NERDTree automatically when vim starts up on opening a directory?
autocmd StdinReadPre * let s:std_in=1 autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists("s:std_in") | exe 'NERDTree' argv()[0] | wincmd p | ene | endif autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists("s:std_in") | exe 'NERDTree' argv()[0] | wincmd p | ene | exe 'cd '.argv()[0] | endif
This window is tab-specific, meaning it's used by all windows in the tab. This trick also prevents NERDTree from hiding when first selecting a file. This window is tab-specific, meaning it's used by all windows in the tab. This trick also prevents NERDTree from hiding when first selecting a file.
Note: Executing `vim ~/some-directory` will open NERDTree and a new edit window. `exe 'cd '.argv()[0]` sets the `pwd` of the new edit window to `~/some-directory`
--- ---
> How can I map a specific key or shortcut to open NERDTree? > How can I map a specific key or shortcut to open NERDTree?