Wednesday, October 31, 2012

Re: saving code browsing history

On Wednesday, October 31, 2012 2:32:49 AM UTC-5, Asis Hallab wrote:
> 2012/10/31 happyFace <happyface...@gmail.com>
>
> > I have been using vim for sometime now but I am completely new to writing
> > vim plugins. I would like to write a plugin that record all the file
> > locations we jump to (with tags or cscope symbols) and save them in a file.
> > So that we can later review the "code browsing session" and be able to
> > conveniently revisit the same tags we browsed.
>
>
> Vim already has that feature. It's called the jumplist.
> Couldn't be better explained than by Drew Neil:
> http://vimcasts.org/episodes/using-the-changelist-and-jumplist/
>
>
>
> There is also a switch to make Vim save its history. 
> So after restarting it, you still have your old jumplist.
> You can set it in your vimrc, unfortunately I can't remember it right now..
>

Vim saves the jumplist in the .viminfo file, if the "'" included by default in
the 'viminfo' option is still present.

However, the .viminfo file may not be as persistent a storage location as you
might like. Additionally, according to the help only 100 jumps are stored in the
list, and each window has its own jump list. The :jumps command will list out
the current jump list (presumably for the current window). Potentially you could
use :redir to capture and parse the output of this command and store it to a
file of your choosing. I don't see any functions to get the jumplist in a
script, but perhaps I just missed them.

Actually, rather than parsing the output of :jumps, it is probably better to set
'viminfo' to the desired setting, use the :wviminfo command with a file
argument, then restore 'viminfo'.

I don't know of a better way to accomplish your task than using the jump list,
even with the caveats I mention above. Hopefully 100 jumps will be sufficient
for you.

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments: