How to install nerdtree plugin on linuxmint for vim74
Asked Answered
H

5

8

I am relatively new to the linux world and have started recently exploring the options it provides and I am fascinated by the power of vim editor.I have recently installed vim74 (the latest version of vim editor for linux)on my mintlinux machine. And tried tutorials that ship along with it and i am pretty comfortable with them.

Now, I want to add a new plugin called NERDTree for vim. I have gone through a lot of examples on google to search for a proper tutorial on the same but I see that they point to a relatively different file structure (Probably those tutorials were made for a different version of vim, if I understand it correctly) and that confuses me.

As I understand there is a plug-in manager called pathogen for vim which has to be placed in autoload directory under vim. But I don’t see any such directory called "autoload".

Helvetii answered 5/2, 2015 at 9:58 Comment(1)
Pathogen installation guide: github.com/tpope/vim-pathogen#installationVary
E
9

You don't need a plugin manager; it just makes management and updates easier [when you have several plugins]. The simplest (and still perfectly valid) way is to just unzip the plugin(s) into a ~/.vim directory.

  1. Go to the plugin's GitHub page, and click "Download ZIP".
  2. Unzip to ~/.vim:
$ mkdir ~/.vim
$ unzip path/to/nerdtree-master.zip -d /tmp
$ mv /tmp/nerdtree-master/* ~/.vim/
$ rmdir /tmp/nerdtree-master

Ensure that the directory structure (autoload, plugin etc.) is directly inside ~/.vim!

Plugin managers

A plugin manager will allow you to keep the plugins in separate directories. Pathogen is one of the simplest and earliest. You can use git to directly clone and update from GitHub; Pathogen extends Vim's 'runtimepath' so that these additional directories (called bundles) are considered.

Other plugin managers include capabilities for automatically locating and downloading plugins (from sources like GitHub, vim.org, etc.) They are more comfortable (especially if you don't know Git well), but also add complexity.

Evaleen answered 5/2, 2015 at 10:16 Comment(5)
Ok let me try this. one quick question though.. Should i create a .vim directory under the root (superuser) or under user home directory.... sorry if this sounds silly...Helvetii
I did as you told and now I can see the nerdtree-master under .vim directory under my home directory. I have restarted my terminal and started vim... but it seems like the plugin doesn't work. The plugin command :Helptags as mentioned on the github page gives error "E492 Not and editor command: Helptags". Am i doing something wrong?Helvetii
Thanks Ingo.. I finally managed to fix this. I was not extracting the files properly. I retried what you told and this works now. Thanks for your help..Helvetii
Glad you've figured it out! It is recommended to not work under the root account. Use sudo / sudoedit instead. So, the configuration should go into your user's home.Evaleen
The mv line you gave won't work if the user already has an autoload directory. (the mv command chooses to fail saying it's non-empty). The user could put the contents of the zip into ~/.vim , whatever files and directories, in more manually.Creon
G
9

step1: First install pathogen

Pathogen

step2: run it in the terminal

git clone https://github.com/scrooloose/nerdtree.git ~/.vim/bundle/nerdtree

source

step3: if you what to open a NERDTree automatically when vim starts up add:

autocmd vimenter * NERDTree

to your .vimrc file in (~/.vimrc). from same source as step 2

Goodtempered answered 25/9, 2016 at 18:41 Comment(0)
S
5

I install my vim plugins using Plug. First install Plug using the command:
curl -fLo ~/.vim/autoload/plug.vim --create-dirs \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim (refer to their installation page if required).

Next in your ~/.vimrc add these lines:
call plug#begin() Plug 'scrooloose/nerdtree' call plug#end() autocmd VimEnter * NERDTree

Now from your vim execute the command :PlugInstall nerdtree (or just :PlugInstall which will install all plugins listed). This should do the trick. In the .vimrc file 'scrooloose/nerdtree' comes from their github url.

Spate answered 27/5, 2017 at 23:31 Comment(4)
:PlugStatus doesn't list NerdTree and if I try vi vimrc, after saving vimrc, I get error detected while processing VimEnter Autocommands for "*": . Also I can't see where nerdtree's vim files would be stored, looking at your commands. This is my ~/.vim/vimrc pastebin.com/raw/jb2zFHzjCreon
@bar it's .vimrc (starts with a dot) Ideally it's in your home ~/.vimrc and for macos it is in ~/.vim/vimrc (don't quote me here) Part of my .vimrc ``` call plug#begin() Plug 'scrooloose/nerdtree' call plug#end() autocmd VimEnter * NERDTree ```Spate
actually you have use ~/.vim/vimrc vimways.org/2018/from-vimrc-to-vim . "~/.vimrc or ~/.vim/vimrc startup files. "Creon
I managed to get it working with Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' } and without any autocmd line, as mentioned in my answerCreon
B
0

Try vim-plug instead as a vim plugin manager. Installation and usage is really simple and outlined in the README.

As you can see in the README, the nerdtree plugin is already there as an example.

Bullnecked answered 5/2, 2015 at 10:2 Comment(0)
C
0

You can do it manually like ingo's method.. copying the files and directories within the nerdtree zip into ~/.vim though that isn't that neat.

Or, you can use a vim plugin manager like Plug (which is like a package manager but for vim plugins). https://github.com/junegunn/vim-plug/ . Sand's method didn't quite work for me.

To use plug, you need a directory for the plugins that plug will be managing. I called mine something like ~/.vim/plug_plugins/

And you need to install Plug - instructions here https://github.com/junegunn/vim-plug/blob/master/README.md i.e. you need to get the file plug.vim and put it in ~/.vim/autoload

This line they give here will create a directory ~/.vim/autoload if it doesn't exist already, and put plug.vim in there

curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim`

Things in the autoload directory don't load automatically, but are called with a 'call' line in vimrc.

As the readme mentions, you need a call begin line, then however many lines to install plugins, then a call end line. And the call line should be passed the directory where the packages will be stored.

call plug#begin('~/.vim/plug_plugins')

Plug 'scrooloose/nerdtree', { 'on':  'NERDTreeToggle' }

call plug#end()

save your vimrc,

run the command :PlugInstall, and it should install NERDTree,

That will automatically put a nerdtree directory in ~/.vim/plug_plugins with all the relevant files, what'd be there if you had extracted the zip there.

and you can test that it is installed with :NERDTree which also starts it.

Also, you can run :PlugStatus to show what plugins are installed.

If you look in the readme for Plug, you'll see it lists NERDTree, even though as of writing, NERDTree's git page doesn't mention Plug in its readme. The plug readme is better for installing nerdtree in plug, than the nerdtree readme.

And this line helps as a shortcut to start it nnoremap <leader>ne :NERDTree <cr>

Creon answered 25/5, 2019 at 18:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.