I have decided to learn
vim and want to give it a go for a month. I am about a week in, and it has been OK. I say "OK" because I do run into the usual frustrations that a n00b might run into.
vim, I used Visual Studio Code, and let's say I am in my project's directory:
Whilst in that directory in the terminal I would run
code . and that would open Visual Studio code with all my files in the left pane.
I read that
NERDTree can give me that, so I've installed it and I have tried to configure it, but I must be doing something wrong, cause it isn't giving me that workflow that VS Code gave me.
According to the NERDTree docs, I need:
" Start NERDTree when Vim is started without file arguments. autocmd StdinReadPre * let s:std_in=1 autocmd VimEnter * if argc() == 0 && !exists('s:std_in') | NERDTree | endif
That comment sounds like what I want! Unless it thinks the dot
vim . counts as a file argument, in which case maybe that doesn't apply!? I'm not sure.
Anyways, I went ahead and tried it. In my
~/.config/nvim/init.vim I have:
fun! TrimWhitespace() let l:save=winsaveview() keeppatterns %s/\s\+$//e call winrestview(l:save) endfun augroup custom_group autocmd! autocmd BufWritePre * :call TrimWhitespace() autocmd StdinReadPre * let s:std_in=1 autocmd VimEnter * if argc() == 0 && !exists('s:std_in') | NERDTree | endif augroup end
I believe it is OK to have it in the
augroup since that rus automatically, at least that's the understanding I have.
So I saved that and exited
vim and restarted it. But I don't get
NERDTree with a pane to the right, I just get what I believe is
vim's own file browser.
What am I doing wrong?