• nerdtree.md


    The NERDTree

    Introducation 介绍

    The NERDTree is a file system explorer for the Vim editor. Using this plugin,
    users can visually browse complex directory hierarchies, quickly open files for
    reading or editing, and perform basic file system operations.

    NERDTree是vim编辑器的一个文件系统浏览器。用户使用这个插件,可以可视化地浏览复杂的目录层次结构,快速打开文件进行阅读或编辑,以及执行文件系统操作。

    This plugin can also be extended with custom mappings using a special API. The
    details of this API and of other NERDTree features are described in the
    included documentation.

    这个插件也可以通过使用特定API的自定义映射来扩展。在所包含的文档中对这个API的细节和其它的NERDTree特性进行了描述。

    NERDTree Screenshot

    Installation 安装

    Below are just some of the methods for installing NERDTree. Do not follow all of these instructions; just pick your favorite one. Other plugin managers exist, and NERDTree should install just fine with any of them.

    以下是一些安装NERDTree的一些方法。不要跟着所有的这些介绍,只需要挑选你最喜欢的一个即可。其它的插件管理器存在,使用它们中的任意一个,NERDTree应该安装的很好。

    Vim 8+ packages Vim 8+包

    If you are using VIM version 8 or higher you can use its built-in package management; see :help packages for more information. Just run these commands in your terminal:

    如果你正在使用的vim 8 版本或者更高版本,可以使用它内建的包管理器;详见:help packages。仅仅在你的终端运行这些命令:

    git clone https://github.com/scrooloose/nerdtree.git ~/.vim/pack/vendor/start/nerdtree
    vim -u NONE -c "helptags ~/.vim/pack/vendor/start/nerdtree/doc" -c q
    

    Otherwise, these are some of the several 3rd-party plugin managers you can choose from. Be sure you read the instructions for your chosen plugin, as there typically are additional steps you nee d to take.

    反之,以下是您可以从中选择的一些第三方插件管理器。请先确认您阅读过您选择的插件介绍,因为通常都需要额外的步骤。

    pathogen.vim

    In the terminal,

    在终端中,

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

    In your vimrc,

    在你的vimrc里,

    call pathogen#infect()
    syntax on
    filetype plugin indent on
    

    Then reload vim, run :helptags ~/.vim/bundle/nerdtree/doc/ or :Helptags.

    任何重新加载vim,运行:helptags ~/.vim/bundle/nerdtree/doc/orHelptags

    Vundle.vim

    call vundle#begin()
    Plugin 'scrooloose/nerdtree'
    call vundle#end()
    

    vim-plug

    call plug#begin()
    Plug 'scrooloose/nerdtree'
    call plug#end()
    

    apt-vim

    apt-vim install -y https://github.com/scrooloose/nerdtree.git
    

    F.A.Q. (here, and in the Wiki)

    Is there any support for git flags? 是否支持git标志?

    Yes, install nerdtree-git-plugin.

    是的。安装 nerdtree-git-plugin


    Can I have the nerdtree on every tab automatically? 我可以在每个标签上自动地拥有 nerdtree吗?

    Nope. If this is something you want then chances are you aren't using tabs and
    buffers as they were intended to be used. Read this
    http://stackoverflow.com/questions/102384/using-vims-tabs-like-buffers

    不。 (不会翻译)

    If you are interested in this behaviour then consider vim-nerdtree-tabs

    如果你对这个行为感兴趣,可以考虑使用 vim-nerdtree-tabs


    How can I open a NERDTree automatically when vim starts up? 当vim启动时如何自动化打开NERDTree?

    Stick this in your vimrc: autocmd vimenter * NERDTree

    在你的vimrc粘贴:autocmd vimenter * NERDTree


    How can I open a NERDTree automatically when vim starts up if no files were specified? 当启动没有指定文件的vim时如何自动开启NERDTree?

    Stick this in your vimrc:

    在你的vimrc中粘贴:

    autocmd StdinReadPre * let s:std_in=1
    autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif
    

    Note: Now start vim with plain vim, not vim .

    注意:现在启动使用简单的vim,不是vim .


    What if I'm also opening a saved session, for example vim -S session_file.vim? I don't want NERDTree to open in that scenario.

    如果我已经打开一个被保存的会话,例如vim -S session_file.vim,但我并不想在那种情况下开启NERDTree,怎么办?

    autocmd StdinReadPre * let s:std_in=1
    autocmd VimEnter * if argc() == 0 && !exists("s:std_in") && v:this_session == "" | NERDTree | endif
    

    man vim

    -S {file} {file} will be sourced after the first file has been read. This is equivalent to -c "source {file}". {file} cannot start with '-'. If {file} is omitted "Session.vim" is used (only works when -S is the last argument).[^1]

    ​ 在首次读取{file}后获取它。等价于 -c "source file"。{file}名字不能以“-”开始。如果{file}被忽略,将使用“Session.vim”。(仅在 -S 是最后一个参数时有效)。


    How can I open NERDTree automatically when vim starts up on opening a directory? 当vim在打开一个目录时启动时,如何使NERFTree自动启动?

    autocmd StdinReadPre * let s:std_in=1
    autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists("s:std_in") | exe 'NERDTree' argv()[0] | wincmd p | ene | exe 'cd '.argv()[0] | endif
    

    This window is tab-specific, meaning it's used by all windows in the tab. This trick also prevents NERDTree from hiding when first selecting a file.

    这个窗口是指定tab的,这意味着其将作用于所有使用这个tab的窗口。没看懂 这个技巧也避免NErdtree在首次选择文件时隐藏。

    Note: Executing vim ~/some-directory will open NERDTree and a new edit window. exe 'cd '.argv()[0] sets the pwd of the new edit window to ~/some-directory

    小贴士:执行 vim ~/some-directory会打开NERDTree和一个新的编辑窗口。exe 'cd '.argv()[0] 会设置新的编辑窗口的pwd~/some-directory下。


    How can I map a specific key or shortcut to open NERDTree? 我如何映射指定键或快捷键来打开NERDTree?

    Stick this in your vimrc to open NERDTree with Ctrl+n (you can set whatever key you want):

    在你的vimrc中粘贴这个以使用Ctrl+n打开NERDTree(你可以设定你想要的任何键位)

    map <C-n> :NERDTreeToggle<CR>
    

    How can I close vim if the only window left open is a NERDTree? 如果留下的窗口只有NERDTree时我如何关闭vim?

    Stick this in your vimrc:

    在你的vimrc粘贴:

    autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
    

    Can I have different highlighting for different file extensions? 我可以针对不同的文件扩展显示不同的高亮吗?

    See here: https://github.com/scrooloose/nerdtree/issues/433#issuecomment-92590696

    详见:https://github.com/scrooloose/nerdtree/issues/433#issuecomment-92590696


    How can I change default arrows? 我如何更改默认箭头?

    Use these variables in your vimrc. Note that below are default arrow symbols

    在你的vimrc中使用这些变量。注意以下为默认箭头标识

    let g:NERDTreeDirArrowExpandable = '▸'
    let g:NERDTreeDirArrowCollapsible = '▾'
    
  • 相关阅读:
    NodeJS简介
    SQL学习笔记(1)
    Linux常用命令03
    Linux常用命令02
    Linux常用命令01
    Java接口和抽象类的区别
    Optional解决空指针
    JVM的内存管理机制-转载
    mysql explain详解-转载
    rabbitmq消息处理-转载
  • 原文地址:https://www.cnblogs.com/nsfoxer/p/16321387.html
Copyright © 2020-2023  润新知