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

Re: Having trouble using conceal

Expand Messages
  • Tony Mechelynck
    ... Try sourcing it from an autocommand, as follows: au VimEnter * au Syntax * source ~/.vim/ownsyntax.vim The VimEnter autocommand is there to add the Syntax
    Message 1 of 7 , Jan 1, 2013
    • 0 Attachment
      On 02/01/13 07:13, HarleyPig wrote:
      > Hmm ... I thought I could have a global syntax. I wanted this to work across any syntax and/or filetype.
      >
      > If I manually source the file it works, or if I make a after/syntax/perl.vim file it will work in my perl files, at least partially--I can't seem to make it work when the timestamp is part of a comment.
      >
      > I'll have to experiment further.
      >

      Try sourcing it from an autocommand, as follows:

      au VimEnter * au Syntax * source ~/.vim/ownsyntax.vim

      The VimEnter autocommand is there to add the Syntax autocommand as late
      as possible among Syntax autocommands (I hope it will add it late
      enough, I didn't check); the Syntax autocommand (defined by the VimEnter
      autocommand) will then be triggered (and source the script) by setting
      the 'syntax' option for any file. This ownsyntax.vim script should then
      change only settings local to the current editfile (using :setlocal,
      :map <buffer>, etc.).

      Best regards,
      Tony.
      --
      Have an adequate day.

      --
      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
    • HarleyPig
      ... That didn t work, but this did: if ! exists( autocmds_loaded ) let autocmds_loaded = 1 autocmd BufEnter * source endif if has( conceal ) How
      Message 2 of 7 , Jan 2, 2013
      • 0 Attachment
        On Wednesday, January 2, 2013 12:24:05 AM UTC-7, Tony Mechelynck wrote:
        > Try sourcing it from an autocommand, as follows:
        >
        > au VimEnter * au Syntax * source ~/.vim/ownsyntax.vim

        That didn't work, but this did:

        if ! exists( "autocmds_loaded" )

        let autocmds_loaded = 1
        autocmd BufEnter * source <sfile>

        endif

        if has( 'conceal' )

        " How can I use variables for the patterns?
        "syntax region myTimeStamp start="__TS:" end="|" conceal
        syntax match myTimeStamp "__TS:.*|" conceal
        highlight myTimeStamp ctermfg=red ctermbg=blue
        set conceallevel=2

        endif


        Thank you.

        My remaining problems are how to use a variable in the match (or region, I'm not sure which is better) and how to make the syntax work in commented sections.

        --
        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
      • Charles Campbell
        ... variable in the match/region: :help execute syntax work in (whatever) section: :help syn-containedin To figure out what section you re in... see
        Message 3 of 7 , Jan 2, 2013
        • 0 Attachment
          HarleyPig wrote:
          > <snip>
          > My remaining problems are how to use a variable in the match (or
          > region, I'm not sure which is better) and how to make the syntax work
          > in commented sections.
          variable in the match/region: :help execute
          syntax work in (whatever) section: :help syn-containedin

          To figure out what section you're in... see
          http://www.drchip.org/astronaut/vim/index.html#HILINKS

          Regards,
          Chip Campbell

          --
          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
        • HarleyPig
          ... Oh! Thanks ... I was looking for eval and it just wasn t making any sense for what I was trying to do. Now I ve got execute syntax match myTimeStamp .
          Message 4 of 7 , Jan 2, 2013
          • 0 Attachment
            On Wednesday, January 2, 2013 2:11:46 PM UTC-7, Charles Campbell wrote:
            > variable in the match/region: :help execute
            > syntax work in (whatever) section: :help syn-containedin

            Oh! Thanks ... I was looking for eval and it just wasn't making any sense for what I was trying to do. Now I've got

            execute 'syntax match myTimeStamp "' . g:timestamp_format_begin . '.*' . g:timestamp_format_delim . '" conceal containedin=.*Comment.*'

            and it's working fine. Thanks.

            > http://www.drchip.org/astronaut/vim/index.html#HILINKS

            Interesting plugin ... along with some others. I don't suppose you have these in a publicly available repo somewhere?

            Nice ... I'm already using Align. Didn't realize you were the author.

            --
            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
          Your message has been successfully submitted and would be delivered to recipients shortly.