From 0a91f3511e4ed216f811aeaf14a9627aae4669bc Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Sun, 8 Jun 2008 17:57:13 +1200 Subject: [PATCH] add functions and :commands to read/write marks to a file --- plugin/NERD_tree.vim | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index 1c930c4..fcf05cc 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -1436,11 +1436,31 @@ function! s:InitNerdTree(dir) call s:RenderView() endfunction +" Function: s:ReadMarks() {{{2 +function! s:ReadMarks() + let marks = s:GetMarks() + let markStrings = readfile(expand('$HOME') . '/.NERDTreeMarks') + for i in markStrings + let key = substitute(i, '^\(\w.\{-}\) .*$', '\1', '') + let path = substitute(i, '^\w.\{-} \(.*\)$', '\1', '') + let marks[key] = s:oPath.New(path) + endfor + call s:RenderView() +endfunction " Function: s:TreeExistsForTab() {{{2 " Returns 1 if a nerd tree root exists in the current tab function! s:TreeExistsForTab() return exists("t:NERDTreeRoot") endfunction +" Function: s:WriteMarks() {{{2 +function! s:WriteMarks() + let marks = s:GetMarks() + let markStrings = [] + for k in keys(marks) + call add(markStrings, k . ' ' . marks[k].StrForOS(0)) + endfor + call writefile(markStrings, expand('$HOME') . '/.NERDTreeMarks') +endfunction " SECTION: Public Functions {{{1 "============================================================ @@ -2485,6 +2505,8 @@ function! s:BindMappings() command! -buffer -complete=customlist,s:FindMarks -nargs=+ ClearMarks call ClearMarks('') command! -buffer -complete=customlist,s:FindMarks -nargs=+ MarkToRoot call MarkToRoot('') command! -buffer -nargs=0 ClearAllMarks call ClearAllMarks() call RenderView() + command! -buffer -nargs=0 ReadMarks call ReadMarks() + command! -buffer -nargs=0 WriteMarks call WriteMarks() endfunction "FUNCTION: s:CheckForActivate() {{{2