简体   繁体   English

如何在linuxmint上为vim74安装nerdtree插件

[英]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. 我对linux世界相对较新,最近开始探索它提供的选项,我对vim编辑器的强大功能着迷。我最近在我的mintlinux机器上安装了vim74(最新版本的vim编辑器)。 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. 现在,我想为vim添加一个名为NERDTree的新插件。 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. 我在谷歌上经历了很多例子来搜索相同的教程,但我发现他们指的是一个相对不同的文件结构(可能那些教程是针对不同版本的vim制作的,如果我理解正确的话)那让我很困惑。

As I understand there is a plug-in manager called pathogen for vim which has to be placed in autoload directory under vim. 据我所知,有一个名为vogen的病原体的插件管理器,必须放在vim下的自动加载目录中。 But I don't see any such directory called "autoload". 但我没有看到任何名为“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). 请帮助我或提供一些我可以关注的最新版本(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. 最简单(并且仍然完全有效)的方法是将插件解压缩到~/.vim目录中。

  1. Go to the plugin's GitHub page , and click "Download ZIP". 转到插件的GitHub页面 ,然后单击“下载ZIP”。
  2. Unzip to ~/.vim : 解压缩到~/.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 ! 确保目录结构( autoloadplugin等)直接在~/.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; 您可以使用git直接从GitHub克隆和更新; Pathogen extends Vim's 'runtimepath' so that these additional directories (called bundles ) are considered. 病原体扩展了Vim的'runtimepath'以便考虑这些额外的目录(称为bundle )。

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. 其他插件管理器包括自动定位和下载插件的功能(来自GitHub,vim.org等来源)。它们更舒适(特别是如果你不熟悉Git),但也增加了复杂性。

step1: First install pathogen 第一步:首先安装病原体

Pathogen 病原

step2: run it in the terminal step2:在终端中运行它

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: step3:如果你在vim启动时自动打开NERDTree,请添加:

autocmd vimenter * NERDTree

to your .vimrc file in (~/.vimrc). 到(〜/ .vimrc)的.vimrc文件。 from same source as step 2 来自同一来源的第2步

I install my vim plugins using Plug . 我使用Plug安装我的vim插件。 First install Plug using the command: 首先使用以下命令安装Plug
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). curl -fLo ~/.vim/autoload/plug.vim --create-dirs \\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim (如果需要,请参阅他们的安装页面)。

Next in your ~/.vimrc add these lines: 接下来在~/.vimrc添加以下行:
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). 现在从你的vim执行命令:PlugInstall nerdtree (或者只是:PlugInstall将安装列出的所有插件的:PlugInstall )。 This should do the trick. 这应该可以解决问题。 In the .vimrc file 'scrooloose/nerdtree' comes from their github url. 在.vimrc文件中,'scrooloose / nerdtree'来自他们的github网址。

Try vim-plug instead as a vim plugin manager. 尝试使用vim-plug作为vim插件管理器。 Installation and usage is really simple and outlined in the README. 安装和使用非常简单,并在README中概述。

As you can see in the README, the nerdtree plugin is already there as an example. 正如您在README中看到的那样,nerdtree插件已经在那里作为示例。

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. 你可以像ingo的方法一样手动完成..将nerdtree zip中的文件和目录复制到~/.vim虽然不是那么整洁。

Or, you can use a vim plugin manager like Plug (which is like a package manager but for vim plugins). 或者,您可以使用像Plug这样的vim插件管理器(就像包管理器一样,但对于vim插件)。 https://github.com/junegunn/vim-plug/ . https://github.com/junegunn/vim-plug/ Sand's method didn't quite work for me. Sand的方法对我来说并不适用。

To use plug, you need a directory for the plugins that plug will be managing. 要使用插件,您需要一个插件将要管理的插件的目录。 I called mine something like ~/.vim/plug_plugins/ 我称之为~/.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 你需要在这里安装插件 - 说明https://github.com/junegunn/vim-plug/blob/master/README.md即你需要获取文件plug.vim并将其放入~/.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 他们在这里给出的这一行将创建一个目录〜/ .vim / autoload(如果它已经不存在),并将plug.vim放在那里

curl -fLo ~/.vim/autoload/plug.vim --create-dirs \\ curl -fLo~ / .vim / autoload / plug.vim --create-dirs \\
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim ` 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 . 自动加载目录中的内容不会自动加载,而是在vimrc使用“call”行调用。

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, 保存你的vimrc,

run the command :PlugInstall, and it should install NERDTree, 运行命令:PlugInstall,它应该安装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. 这将自动将〜/ .vim / plug_plugins中的一个nerdtree目录与所有相关文件放在一起,如果你在那里提取了zip,那将会是什么。

and you can test that it is installed with :NERDTree which also starts it. 并且您可以测试它是否已安装:NERDTree也可以启动它。

Also, you can run :PlugStatus to show what plugins are installed. 此外,您还可以运行:PlugStatus来显示已安装的插件。

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. 如果您查看Plug的自述文件,您会看到它列出了NERDTree,即使在写作时,NERDTree的git页面也没有提到插入其自述文件。 The plug readme is better for installing nerdtree in plug, than the nerdtree readme. 插件自述文件更适合在插件中安装nerdtree,而不是nerdtree自述文件。

And this line helps as a shortcut to start it nnoremap <leader>ne :NERDTree <cr> 这行有助于启动它nnoremap <leader>ne :NERDTree <cr>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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