简体   繁体   中英

How to install nerdtree plugin on linuxmint for vim74

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".

After doing hours of researches and ending up completely confused on what to do I have decided to ask this question.

Please help me or provide me some reference which i can follow for this latest version (vim74).

Please let me know if I should provide any more details.

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.

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

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.

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.

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 ie 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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM