vim-NERDTree: order bookmarks?
Asked Answered
H

3

11

Is there a way to order the bookmarks I see with the NERDTree vim plugin?

I feel like this should be simple, but I don't know how to do this. I vim'ed ~/.NERDTreeBookmarks and saw that in that file, the bookmarks are in the right order, but it seems to continuously reorganize the bookmarks according to the order I use them -- which is not what I want. I also did :ReadBookmarks command and that didn't seem to change order.

Huron answered 4/7, 2011 at 9:48 Comment(0)
E
10

I had the same problem, and managed to turn off NERDTree's wacky bookmark sorting. Open the NERD_tree.vim plugin file (usually ~/.vim/plugin/NERD_tree.vim). Search for this line:

call s:Bookmark.Sort()

There should be two instances of the line (in NERDTree version 4.2.0 they're on lines 209 and 286). Comment out both lines by adding " in front of them like this:

"call s:Bookmark.Sort()

Now you can edit ~/.NERDTreeBookmarks and your bookmarks will show up in NERDTree in the same order as in the file. You can use :ReadBookmarks to refresh your bookmarks list after editing the file.

Evonneevonymus answered 12/1, 2012 at 23:21 Comment(1)
Yay! I gave up a long time ago, but I'm so glad someone noticed this question and answered it :)Huron
T
5

As an update to alxm's excellent answer above, the line(s) have been moved into a new file. On my hard drive it's in ~/.vim/bundle/nerdtree/lib/nerdtree/bookmark.vim (I use vundle). In a vanilla vim installation it would most likely be in ~/.vim/plugin/nerdtree/lib/nerdtree/bookmark.vim.

1. Edit your bookmark.vim file

I commented out the line that starts with call sort... (line 246), like this:

" This is in ~/.vim/<PLUGINDIR>/nerdtree/lib/nerdtree/bookmark.vim

" FUNCTION: Bookmark.Sort() {{{1
" Class method that sorts all bookmarks
function! s:Bookmark.Sort()
    let CompareFunc = function("nerdtree#compareBookmarks")
    "call sort(s:Bookmark.Bookmarks(), CompareFunc)
endfunction

2. Quit vim

Exit out of vim because you want to reload your plugins, specifically NERDTree.

3. Edit your ~/.NERDTreeBookmarks file.

Put them in the order you want them in. NERDTree now respects your wishes. Your solemn, heartfelt bookmark sorting wishes.

4. Fire up vim again

Of course everyone already knows this, but I thought this answer needed a fourth step.

Tiu answered 2/6, 2014 at 4:33 Comment(0)
B
4

Not sure since when though, you can now set NERDTreeBookmarksSort instead.

let g:NERDTreeBookmarksSort=0

Then edit ~/.NERDTreeBookmarks as you want to order.

Check :help NERDTreeBookmarksSort for more detail.

Bromate answered 12/9, 2017 at 6:34 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.