Wednesday, October 19, 2011

Re: virtual marking

On Wed, Oct 19, 2011 at 4:38 PM, Yegappan Lakshmanan
<yegappanl@gmail.com> wrote:
> Hi,
>
> On Wed, Oct 19, 2011 at 3:55 AM, Xavier de Gaye <xdegaye@gmail.com> wrote:
>>
>> On Wed, Oct 19, 2011 at 7:00 AM, sinbad wrote:
>> > i want to be able to mark locations in files with some text (marking-
>> > text) of my choice.
>>
>>
>> You can use a temporary file to store your marks and the quickfix
>> window to navigate through them. For example source the script listed
>> below and mark a location with:
>>
>>    :Mark some text
>>
>> Display the quickfix window with:
>>
>>    :Getmarks
>>
>>
>> --
>> Xavier
>>
>> Les Chemins de Lokoti: http://lokoti.alwaysdata.net
>>
>>
>> ===========================================================
>> let s:tmpfile = tempname()
>>
>> " mark a location in a file with some text
>> function! s:mark(text)
>>    try
>>        let l:lines = readfile(s:tmpfile)
>>    catch /.*/
>>        let l:lines = []
>>    endtry
>>    let l:lines += [bufname("%") . ":" . line(".") . ":" . a:text]
>>    call writefile(l:lines, s:tmpfile)
>> endfunction
>>
>> " open the quickfix window
>> function! s:cwindow()
>>    let l:gp=&gp
>>    let l:gfm=&gfm
>>    let l:gp = "set gp=cat\\ " . s:tmpfile
>>    exe l:gp
>>    set gfm=%f:%l:%m
>>    grep
>>    let &gp=l:gp
>>    let &gfm=l:gfm
>
>
> Instead of using the above lines, you can simply use the following:
>     exe "cfile " . s:tmpfile
>
> - Yegappan
>>
>>    cwindow
>> endfunction
>>
>> command! -bar -nargs=1 Mark call s:mark(<f-args>)
>> command! -bar Getmarks call s:cwindow()
>> ===========================================================
>>
> --
> You received this message from the "vim_dev" 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
>


Thanks.

--
Xavier

Les Chemins de Lokoti: http://lokoti.alwaysdata.net

--
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: