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

How to save highlight?

Expand Messages
  • Jack
    Micosoft word can highlight a line in a file and save the highlight. How to do it with vim? The command v can do highlight. But if I want to save the
    Message 1 of 3 , Mar 31, 2008
    • 0 Attachment
      Micosoft word can highlight a line in a file and save the highlight.
      How to do it with vim? The command "v" can do highlight. But if I want
      to
      save the highlight in the file, how to do it? Thanks.
      --~--~---------~--~----~------------~-------~--~----~
      You received this message from the "vim_use" maillist.
      For more information, visit http://www.vim.org/maillist.php
      -~----------~----~----~----~------~----~------~--~---
    • Tim Chase
      ... When you say save the highlight , which of the following do you mean 1) select a range of text, change the background color, and Word remembers it ? For
      Message 2 of 3 , Mar 31, 2008
      • 0 Attachment
        > Micosoft word can highlight a line in a file and save the
        > highlight.

        When you say "save the highlight", which of the following do you mean

        1) "select a range of text, change the background color, and Word
        remembers it"? For the current editing session, or persistent in
        the file across re-openings?

        2) "select a range of text, move around, and then re-select the
        previously selected range of text"?

        3) "select a range of text and write that subsection of your
        document to a file"

        Word allows #1, but doesn't offer #2 or #3 to the best of my
        knowledge (though I'm sure with some automation, it would be
        possible).

        Vim allows for #2 (":help gv") and #3 (at least line-wise, using
        ":w" with a range, as described in ":help :w"; possibly
        character-wise if you use Dr. Chip's vis.vim script[1]). For #1,
        Vim easily allows you to highlight a given line according to its
        syntax, but that depends entirely on the underlying syntax of the
        file. You can highlight a particular line-number:

        :match Error /\%32l.*/

        or a range of text:

        :match Error /to be\_.\{-}question/

        and there are other such combinations. To get them to "persist"
        across vimming sessions, it's best to use a syntax-aware format
        such as HTML, LaTeX or DocBook. Because vim is a *text* editor,
        not a word-processor, there's no such thing as "highlighting" in
        the word-processor sense.


        > How to do it with vim? The command "v" can do highlight. But
        > if I want to save the highlight in the file, how to do it?
        > Thanks.

        You talk about using "v" to highlight, which is merely like
        selecting in Word, and since Word doesn't save this selection
        (last I checked), I can't make sense of your request.

        -tim

        [1] www.vim.org/scripts/script.php?script_id=1195



        --~--~---------~--~----~------------~-------~--~----~
        You received this message from the "vim_use" maillist.
        For more information, visit http://www.vim.org/maillist.php
        -~----------~----~----~----~------~----~------~--~---
      • A.Politz
        ... Nonetheless possible via call writefile([string(getmatches())],fname) and exec call setmatches( .readfile(fname)[0]. ) . Though this stuff is local to
        Message 3 of 3 , Mar 31, 2008
        • 0 Attachment
          Tim Chase wrote:

          >>Micosoft word can highlight a line in a file and save the
          >>highlight.
          >>
          >>
          > You can highlight a particular line-number:
          >
          > :match Error /\%32l.*/
          >
          >or a range of text:
          >
          > :match Error /to be\_.\{-}question/
          >
          >and there are other such combinations. To get them to "persist"
          >across vimming sessions, it's best to use a syntax-aware format
          >such as HTML, LaTeX or DocBook. Because vim is a *text* editor,
          >not a word-processor, there's no such thing as "highlighting" in
          >the word-processor sense.
          >
          >
          >
          >
          Nonetheless possible via
          call writefile([string(getmatches())],fname)
          and
          exec 'call setmatches('.readfile(fname)[0].')'
          .

          Though this stuff is local to windows, not buffer.

          -ap

          --
          :wq


          --~--~---------~--~----~------------~-------~--~----~
          You received this message from the "vim_use" maillist.
          For more information, visit http://www.vim.org/maillist.php
          -~----------~----~----~----~------~----~------~--~---
        Your message has been successfully submitted and would be delivered to recipients shortly.