第十章 个人渣翻译 spf13插件---nerdtree 使用教程(中)

不得不说,nerdtree的官方文档挺长的,因此要分成上中下三篇文章来详写。

关于书签


2.2. Bookmarks *NERDTreeBookmarks*

Bookmarks in the NERD tree are a way to tag files or directories of interest.

For example, you could use bookmarks to tag all of your project directories.

------------------------------------------------------------------------------

2.2.1. The Bookmark Table *NERDTreeBookmarkTable*

If the bookmark table is active (see |NERDTree-B| and

|'NERDTreeShowBookmarks'|), it will be rendered above the tree. You can double

click bookmarks or use the |NERDTree-o| mapping to activate them. See also,

|NERDTree-t| and |NERDTree-T|

------------------------------------------------------------------------------

2.2.2. Bookmark commands *NERDTreeBookmarkCommands*

Note that the following commands are only available in the NERD tree buffer.

:Bookmark [<name>]

Bookmark the current node as <name>. If there is already a <name>

bookmark, it is overwritten. <name> must not contain spaces.

If <name> is not provided, it defaults to the file or directory name.

For directories, a trailing slash is present.

:BookmarkToRoot <bookmark>

Make the directory corresponding to <bookmark> the new root. If a treenode

corresponding to <bookmark> is already cached somewhere in the tree then

the current tree will be used, otherwise a fresh tree will be opened.

Note that if <bookmark> points to a file then its parent will be used

instead.

:RevealBookmark <bookmark>

If the node is cached under the current root then it will be revealed

(i.e. directory nodes above it will be opened) and the cursor will be

placed on it.

:OpenBookmark <bookmark>

<bookmark> must point to a file. The file is opened as though |NERDTree-o|

was applied. If the node is cached under the current root then it will be

revealed and the cursor will be placed on it.

:ClearBookmarks [<bookmarks>]

Remove all the given bookmarks. If no bookmarks are given then remove all

bookmarks on the current node.

:ClearAllBookmarks

Remove all bookmarks.

:ReadBookmarks

Re-read the bookmarks in the |'NERDTreeBookmarksFile'|.

See also |:NERDTree| and |:NERDTreeFromBookmark|.

------------------------------------------------------------------------------

2.2.3. Invalid Bookmarks *NERDTreeInvalidBookmarks*

If invalid bookmarks are detected, the script will issue an error message and

the invalid bookmarks will become unavailable for use.

These bookmarks will still be stored in the bookmarks file (see

|'NERDTreeBookmarksFile'|), down the bottom. There will always be a blank line

after the valid bookmarks but before the invalid ones.

Each line in the bookmarks file represents one bookmark. The proper format is:

<bookmark name><space><full path to the bookmark location>

After you have corrected any invalid bookmarks, either restart vim, or go

:ReadBookmarks from the NERD tree window.

 

个人渣翻译:

2.2 书签

nerd tree中的书签是一种标记你感兴趣的文件或目录的方式。

例如,你可以使用书签来标记你的所有项目目录。

 

2.2.1 书签表

如果书签表是激活的,(参考 |NERDTree-B| and |'NERDTreeShowBookmarks'| 两项)。

它会呈现该树,你可以在书签上双击鼠标或者使用|NERDTree-o|映射来激活它们。

也可参见  |NERDTree-t| and |NERDTree-T| 项。

 

2.2.2  书签命令

注意以下命令只在nerd tree缓冲区提供

 

:Bookmark [<name>]

把当前节点,做成书签名name。如果书签已经有名字了,会覆盖重写。

name名不能包含空格,如果没有给出name,默认值为文件或目录名。

对于目录来说,斜杠是存在的。

 

:BookmarkToRoot <bookmark>

以bookmark作为新树根产生目录,如果对应bookmark的一个节点已经存储在树的其他地方,

那么使用当前树,否则打开一个新树。

注意如果bookmark指向的是一个文件,那么该文件的父节点会被替换。

 

:RevealBookmark <bookmark>

如果节点存储在当前根目录之下,那么它会被显示(即在它之上的目录节点会打开),光标会放在这。

 

:OpenBookmark <bookmark>

<bookmark>必须指向一个文件。

文件打开就像应用了|NERDTree-o|一样,如果节点存储在当前根目录之下,那么它会被显示(即在它之上的目录节点会打开),光标会放在这

 

:ClearBookmarks [<bookmarks>]

删除所有给定的书签,如果没有给定书签,那么删除所有在当前节点之上的书签。

 

:ClearAllBookmarks

删除所有书签

 

:ReadBookmarks

在|'NERDTreeBookmarksFile'|项里重新读取书签。

 

2.2.3  无效书签

如果发现了无效书签,脚本会发布一个错误信息,并且无效书签会变得不可用。

在书签文件里这些书签仍将被保存,总是有一个空白行在有效书签之后,在无效书签之前就没有。

 

在书签文件里的每一行都代表了一个书签,正确的格式为:

<bookmark name><space><full path to the bookmark location>

在你纠正了任何无效书签之后,或者重启vim,或者在nerd tree 窗口执行:ReadBookmarks

 

个人总结:

书签对我们来说,是很重要的功能,有了它就能在不同的文件或目录之间进行快速跳转。

注意,未建立nerdtree时,新建的书签必须是以目录为根节点,文件是无法作为根节点的。

在一个已经建好的nerdtree中,书签既可以指向某个目录,也可以指向某个文件。


所有的书签命令只能在nerd tree缓冲区有效,这句话的意思是必须要【ctrl+e】切换到nerd tree,命令才有效。

尽管看起来很像EX命令,但在vim的普通模式也同样无效。


如图所示,我建立了一个书签名叫 mybook,它仅包含用户区的桌面这个目录(书签里没有任何文件)。

                         书签 mybook == ~/桌面/



但事实上我们用的最多还是指向目录功能 ,除非某个文件你经常频繁使用,才有必要单独做成书签。       

想删除该书签 :ClearAllBookmarks


如果想回去继续编写代码,有两种方式,第一是用鼠标点选vim编辑区,这样可以保证nerd tree窗口存在,需要再次nerd tree操作时,又用鼠标点选nerd tree 窗口;或者使用ctrl+w+w切换窗口。

第二就是反复使用【ctrl+e】进行切换,同一时间vim编辑区和nerd tree窗口只能保留一个。

理想情况下当然是第一种更好,方便我们观察项目的组成,并且在nerdtree中添加或者删除文件。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值