1

I was trying to configure vim to have a file explorer on the side with no plugins. I found the following script:

function! ToggleNetrw()
  if g:NetrwIsOpen
    let i = bufnr("$")
    while (i >= 1)
        if(getbufvar(i,"&filetype") == "netrw")
            silent exe "bwipeout " . i
        endif
        let i-=1
    endwhile
    let g:NetrwIsOpen=0
 else
    let g:NetrwIsOpen=1
    silent Lexplore
 endif
endfunction

I have barely written any vimrc code so I'm not 100% sure what this function does, but from my understanding this should open Netrw if it isn't already open and do nothing if it is.

However I'm getting the following error message when the vimrc folder is re-initialized:

Not an editor command :Lexplore

Does this have something to do with my vim version, my linux distro (which is CentOS) or something else?

9
  • 1
    Does Lexplore work when you run it manually from the command line?
    – B Layer
    Jun 16 at 9:53
  • 1
    Okay, that's weird. Everyone should have that. Try it after launching vim with flag --clean.
    – B Layer
    Jun 16 at 9:55
  • 1
    How old of a version of Vim is this? And is it actually Vim or is it vi?
    – B Layer
    Jun 16 at 10:06
  • 1
    Yeah, that's about 8 years old I think. I don't know if netrw was a default inclusion for that version. Regardless an upgrade would be of great benefit. :)
    – B Layer
    Jun 16 at 10:12
  • 1
    @BLayer you were indeed correct, it was the version. I answered the question. Thank you! Jun 16 at 10:36
0

The problem was the version of Vim installed on my system (7.4). At that time, Netrw might not have been a default inclusion with Vim.

I didn't know at the time, but the official repositories of CentOS don't yet have the latest version of vim. Once i installed it using this guide: https://phoenixnap.com/kb/how-to-install-vim-centos-7 (version 8.2), i got Lexplore working

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.