Loading ...
Sorry, an error occurred while loading the content.
 

Re: virtual marking

Expand Messages
  • Xavier de Gaye
    ... You can use a temporary file to store your marks and the quickfix window to navigate through them. For example source the script listed ... -- Xavier Les
    Message 1 of 3 , Oct 19, 2011
      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
      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
    • Yegappan Lakshmanan
      Hi, ... Instead of using the above lines, you can simply use the following: exe cfile . s:tmpfile - Yegappan cwindow ... -- You received this message from
      Message 2 of 3 , Oct 19, 2011
        Hi,


        On Wed, Oct 19, 2011 at 3:55 AM, Xavier de Gaye <xdegaye@...> 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
      • Xavier de Gaye
        On Wed, Oct 19, 2011 at 4:38 PM, Yegappan Lakshmanan ... Thanks. -- Xavier Les Chemins de Lokoti: http://lokoti.alwaysdata.net -- You received this message
        Message 3 of 3 , Oct 19, 2011
          On Wed, Oct 19, 2011 at 4:38 PM, Yegappan Lakshmanan
          <yegappanl@...> wrote:
          > Hi,
          >
          > On Wed, Oct 19, 2011 at 3:55 AM, Xavier de Gaye <xdegaye@...> 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_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
        Your message has been successfully submitted and would be delivered to recipients shortly.