vim nerdtree vs "E:" explorer?
Asked Answered
M

2

6

I am new to VIM. Please help me with this - or please give me a link, thank you! I found the Nerdtree very useful. i also found an article about using the command ":E", which gives a similar (or the same) look as the Nerdtree shows.

May I ask, which one to use (Nerdtree-plugin or :E)? Are there functionalities that Nerdtree shows while not :E?

Thank you and please sorry if that's really basic; i can't find a comparison if it in the web; and as a 'newbie' i do not see the difference (yet).

Mirabel answered 17/2, 2015 at 19:25 Comment(0)
M
5

While this may be a bit "off-topic" on SO, I'll say that I prefer to use Ctrl-E. Here's my script for it (that I got from somewhere else):

" Toggle Vexplore with Ctrl-E
function! ToggleVExplorer()
    if exists("t:expl_buf_num")
        let expl_win_num = bufwinnr(t:expl_buf_num)
        if expl_win_num != -1
            let cur_win_nr = winnr()
            exec expl_win_num . 'wincmd w'
            close
            exec cur_win_nr . 'wincmd w'
            unlet t:expl_buf_num
        else
            unlet t:expl_buf_num
        endif
    else
        exec '1wincmd w'
        Vexplore
        let t:expl_buf_num = bufnr("%")
    endif
endfunction
map <silent> <C-E> :call ToggleVExplorer()<CR>

" Hit enter in the file browser to open the selected
" file with :vsplit to the right of browser
"let g:netrw_brows_split = 4
"let g:netrow_altv = 1

" Default to tree mode
let g:netrw_liststyle = 3

Just throw that in your .vimrc and you should be fine.

I prefer this because it's very simple. It doesn't take up much resources and isn't computationally expensive. That's just personal preference.

Try them against each other and see what you like.

Regarding differences, I think NerdTree is more full-featured, though I'm not completely familiar with it, as I removed it a couple hours after implementing it. I just remember it taking a bit longer to respond than this.

Markle answered 17/2, 2015 at 19:29 Comment(4)
Thank you for your answer, and that quick :). Off-topic or not, that's great. Thank you for the file. - since i haven't enough points yet to do 'upvote', i will accept this answer. As also, I was interested if people than would use the :E .. as i found Nerdtree all over the web, while :E only one time mentioned. Such, the topic for me is answered.Mirabel
You only need nnoremap <C-e> :Lexplore<CR> to do what the function is doingDustheap
say I wanted to open up my current directory. typing vim . will do that, but the netrw explorer doesnt open on the side and once I pick a file, the explorer is showing at the bottom of the screen. How do you start you workflow?Dystopia
I prefer not using Plugins but it seems that NERDTree is working much better with splits I will switch if they can give me the same functionality in netrwEbonieebonite
S
10

The :Explore command is provided by the netrw plugin that ships with Vim. It provides a (highly configurable) file explorer, plus functionality to read / write files in remote locations. (If you just like the hierarchical tree that NERDTree defaults to, that can be configured in netrw, too: let g:netrw_liststyle = 3)

The NERDTree plugin provides a (also highly configurable) hierarchical file tree as a sidebar, plus extension points for custom file commands. The plugin by default "grabs" the directory listing functionality from netrw (cp. :help NERDTreeHijackNetrw), but the plugins can also coexist peacefully. NERDTree also has some secondary plugins that automatically show (and sync) the sidebar in multiple tabs etc.

If you like NERDTree, just give it a try. Also, read through the :help of both plugins, and see which offers configuration you like / or which appeals more to you. You can always change your mind later.

Strychnine answered 17/2, 2015 at 19:50 Comment(1)
Since Nov 9, 2013, netrw (:Explore) also provides a sidebar directory listing (ie. v150 or later) via :LexploreAfebrile
M
5

While this may be a bit "off-topic" on SO, I'll say that I prefer to use Ctrl-E. Here's my script for it (that I got from somewhere else):

" Toggle Vexplore with Ctrl-E
function! ToggleVExplorer()
    if exists("t:expl_buf_num")
        let expl_win_num = bufwinnr(t:expl_buf_num)
        if expl_win_num != -1
            let cur_win_nr = winnr()
            exec expl_win_num . 'wincmd w'
            close
            exec cur_win_nr . 'wincmd w'
            unlet t:expl_buf_num
        else
            unlet t:expl_buf_num
        endif
    else
        exec '1wincmd w'
        Vexplore
        let t:expl_buf_num = bufnr("%")
    endif
endfunction
map <silent> <C-E> :call ToggleVExplorer()<CR>

" Hit enter in the file browser to open the selected
" file with :vsplit to the right of browser
"let g:netrw_brows_split = 4
"let g:netrow_altv = 1

" Default to tree mode
let g:netrw_liststyle = 3

Just throw that in your .vimrc and you should be fine.

I prefer this because it's very simple. It doesn't take up much resources and isn't computationally expensive. That's just personal preference.

Try them against each other and see what you like.

Regarding differences, I think NerdTree is more full-featured, though I'm not completely familiar with it, as I removed it a couple hours after implementing it. I just remember it taking a bit longer to respond than this.

Markle answered 17/2, 2015 at 19:29 Comment(4)
Thank you for your answer, and that quick :). Off-topic or not, that's great. Thank you for the file. - since i haven't enough points yet to do 'upvote', i will accept this answer. As also, I was interested if people than would use the :E .. as i found Nerdtree all over the web, while :E only one time mentioned. Such, the topic for me is answered.Mirabel
You only need nnoremap <C-e> :Lexplore<CR> to do what the function is doingDustheap
say I wanted to open up my current directory. typing vim . will do that, but the netrw explorer doesnt open on the side and once I pick a file, the explorer is showing at the bottom of the screen. How do you start you workflow?Dystopia
I prefer not using Plugins but it seems that NERDTree is working much better with splits I will switch if they can give me the same functionality in netrwEbonieebonite

© 2022 - 2024 — McMap. All rights reserved.