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

Re: Where to put "set iskeyword+=_" or remove "iskeyword-=_

Expand Messages
  • Gary Johnson
    ... Yes. If you want that setting to apply to just you, put it in ~/vimfiles/after/syntax/tex.vim. If you want that setting to apply to all users of that
    Message 1 of 16 , Jun 19, 2013
    • 0 Attachment
      On 2013-06-19, Paul wrote:
      > Tim, JR, coot,
      >
      > Here is the output from ":verbose set isk?"
      >
      > iskeyword=@,48-57,192-255
      > Last set from C:/Program Files (x86)/Vim/vim73/syntax/tex.vim
      >
      > Note that the above path to tex.vim is the same as that returned
      > by suggested command
      >
      > :echo globpath(&rtp, 'syntax/tex.vim')
      >
      > Thanks for cluing me in to the fact that searching for iskeyword
      > won't find the short form "isk". It looks like tex.vim gets
      > called when I enable syntax highlighting. The chunk of code that
      > sets isk-=_ is:
      >
      > " (La)TeX keywords: only use the letters a-zA-Z {{{1
      > " but _ is the only one that causes problems.
      > if version < 600
      > set isk-=_
      > if b:tex_stylish
      > set isk+=@
      > endif
      > else
      > setlocal isk-=_
      > if b:tex_stylish
      > setlocal isk+=@
      > endif
      > endif
      >
      > If I did not want to change the files in the install tree, is
      > there somewhere else I can put "setl isk+=_" so that my tex file
      > edit sessions/files/buffers always treat underscore as a keyword
      > character?

      Yes. If you want that setting to apply to just you, put it in
      ~/vimfiles/after/syntax/tex.vim. If you want that setting to apply
      to all users of that computer, put it in
      "C:/Program Files (x86)/Vim/vimfiles/after/syntax/tex.vim".

      > I tried putting it into "/c/Program Files
      > (x86)/Vim/vimfiles/syntax/tex.vim", but that doesn't seem to do
      > it.

      Right. That's because that file is sourced before
      $VIMRUNTIME/syntax/tex.vim so your setting was being made first and
      was being overridden by the setting in $VIMRUNTIME/syntax/tex.vim.
      ($VIMRUNTIME in your case is "C:/Program Files (x86)/Vim/vim73".)

      Regards,
      Gary

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

      ---
      You received this message because you are subscribed to the Google Groups "vim_use" group.
      To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
      For more options, visit https://groups.google.com/groups/opt_out.
    • Paul
      Coot, I think the problem is that I am working with vim 7.3, patches 1-46. It is a locked down environment, so I ve given up trying to upgrade for the next
      Message 2 of 16 , Jun 19, 2013
      • 0 Attachment
        Coot, I think the problem is that I am working with vim 7.3, patches 1-46. It is a locked down environment, so I've given up trying to upgrade for the next few years (which is not to say that I haven't submitted a request). There is no tex_isk in .../doc/syntax.txt in my install. The commands

        echo tex_isk
        echo g:tex_isk

        yield the error messages:

        E121: Undefined variable: tex_isk
        E15: Invalid expression: tex_isk

        E121: Undefined variable: g:tex_isk
        E15: Invalid expression: g:tex_isk
        --------------------------------------------------
        Ben, Gary,

        I don't have the authority to write to system-wide files. I tried autocommands and ~/vimfiles/after/syntax/tex.vim. No luck so far. In both cases, the result is that "setg isk?" and "setl isk?" show an underscore *before* enabling syntax, but the local version loses underscore after enabling syntax. I can tell that the local version takes precedence because underscore is no longer a keyword character, based on the fact that i_ctlr-p and i_ctrl-n does word completion only upto an underscore.

        Here are the details behind my attempt at using autocommand and ~/vimfiles/after/syntax/tex.vim.

        1 ~/vimfiles/after/syntax/tex.vim
        2 -------------------------------
        3 setg isk+=_
        4 setlocal isk+=_
        5
        6 ~/.vim/after/syntax/tex.vim
        7 ---------------------------
        8 setg isk+=_
        9 setlocal isk+=_
        10
        11 ~/_vimrc
        12 --------
        13 autocmd BufNewFile,BufRead,BufWinEnter *.tex setl isk+=_ | setg isk+=_
        14 autocmd BufNewFile,BufRead,BufWinEnter *.bib setg isk+=_ | setl isk+=_
        15 filetype on
        16 au Syntax * setl isk+=_

        I bastardized lines 13-14 from code higher up in the _vimrc, not sure if it is kosher.

        Thanks for any other suggestions.

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

        ---
        You received this message because you are subscribed to the Google Groups "vim_use" group.
        To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
        For more options, visit https://groups.google.com/groups/opt_out.
      • Ben Fritz
        ... How do you enable syntax? Are you setting it on manually? Or do you have a syntax on somewhere in your _vimrc? ... This should have worked. Can you check
        Message 3 of 16 , Jun 19, 2013
        • 0 Attachment
          On Wednesday, June 19, 2013 3:42:37 PM UTC-5, Paul wrote:
          > Coot, I think the problem is that I am working with vim 7.3, patches 1-46. It is a locked down environment, so I've given up trying to upgrade for the next few years (which is not to say that I haven't submitted a request). There is no tex_isk in .../doc/syntax.txt in my install. The commands
          >
          > echo tex_isk
          > echo g:tex_isk
          >
          > yield the error messages:
          >
          > E121: Undefined variable: tex_isk
          > E15: Invalid expression: tex_isk
          >
          > E121: Undefined variable: g:tex_isk
          > E15: Invalid expression: g:tex_isk
          > --------------------------------------------------
          > Ben, Gary,
          >
          > I don't have the authority to write to system-wide files. I tried autocommands and ~/vimfiles/after/syntax/tex.vim. No luck so far. In both cases, the result is that "setg isk?" and "setl isk?" show an underscore *before* enabling syntax, but the local version loses underscore after enabling syntax. I can tell that the local version takes precedence because underscore is no longer a keyword character, based on the fact that i_ctlr-p and i_ctrl-n does word completion only upto an underscore.
          >

          How do you enable syntax? Are you setting it on manually? Or do you have a "syntax on" somewhere in your _vimrc?

          > Here are the details behind my attempt at using autocommand and ~/vimfiles/after/syntax/tex.vim.
          >
          > 1 ~/vimfiles/after/syntax/tex.vim
          > 2 -------------------------------
          > 3 setg isk+=_
          > 4 setlocal isk+=_
          > 5

          This should have worked. Can you check with :scriptnames whether this file actually gets sourced? Hod did you determine the ~ directory? Maybe Vim is looking in a place you didn't expect for $HOME.

          > 6 ~/.vim/after/syntax/tex.vim
          > 7 ---------------------------
          > 8 setg isk+=_
          > 9 setlocal isk+=_
          > 10

          This should work on Unix-like systems but not on Windows, IIUC.

          > 11 ~/_vimrc
          > 12 --------
          > 13 autocmd BufNewFile,BufRead,BufWinEnter *.tex setl isk+=_ | setg isk+=_
          > 14 autocmd BufNewFile,BufRead,BufWinEnter *.bib setg isk+=_ | setl isk+=_
          > 15 filetype on
          > 16 au Syntax * setl isk+=_
          >

          Line 16 should work, at least if "syntax on" is set somewhere above. You should actually be able to be more selective, with "au Syntax tex setl isk+=_" instead of matching ALL syntaxes.

          > I bastardized lines 13-14 from code higher up in the _vimrc, not sure if it is kosher.
          >

          They look fine to me, and the BufWinEnter should even take care of overriding any modelines.

          In summary: you are using 3 methods simultaneously that each ought to be working if the files are actually being sourced. Double-check that these files are being sourced using :scriptnames. If the files do actually show up, try the :verbose set isk? command again. Maybe you can find a specific problematic line.

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

          ---
          You received this message because you are subscribed to the Google Groups "vim_use" group.
          To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
          For more options, visit https://groups.google.com/groups/opt_out.
        • Marcin Szamotulski
          ... You re right, there is not g:tex_isk in your version. You can grab the latest tex syntax file and put it in your vimfiles/syntax/tex.vim and add g:tex_isk
          Message 4 of 16 , Jun 19, 2013
          • 0 Attachment
            On 13:42 Wed 19 Jun , Paul wrote:
            > Coot, I think the problem is that I am working with vim 7.3, patches 1-46. It is a locked down environment, so I've given up trying to upgrade for the next few years (which is not to say that I haven't submitted a request). There is no tex_isk in .../doc/syntax.txt in my install. The commands
            >
            > echo tex_isk
            > echo g:tex_isk
            >
            > yield the error messages:
            >
            > E121: Undefined variable: tex_isk
            > E15: Invalid expression: tex_isk
            >
            > E121: Undefined variable: g:tex_isk
            > E15: Invalid expression: g:tex_isk
            > --------------------------------------------------

            You're right, there is not g:tex_isk in your version. You can grab the
            latest tex syntax file and put it in your vimfiles/syntax/tex.vim and
            add g:tex_isk in your vimrc file. Then new syntax file have many more
            options which you might be interested in. It can conceal stuff, and it
            also have g:tex_fast setting with which you can set which syntax groups
            are defined - this is very cool for slower machines since the tex syntax
            file is really big. The tex syntax file you can get from:
            http://www.drchip.org/astronaut/vim/
            or directly from vim ftp site:
            ftp://ftp.vim.org/pub/vim/runtime
            (here you can also get the doc file (doc/syntax.txt) to read how to use
            the new tex syntax script.

            By the way, which LaTeX plugin are you using?

            Best regards,
            Marcin

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

            ---
            You received this message because you are subscribed to the Google Groups "vim_use" group.
            To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
            For more options, visit https://groups.google.com/groups/opt_out.
          • Paul
            Marcin, I d like to keep the information you provided as reference. If I can get over this small hurdle with the least customization, I ll take it for now
            Message 5 of 16 , Jun 20, 2013
            • 0 Attachment
              Marcin,

              I'd like to keep the information you provided as reference. If I can get over this small hurdle with the least customization, I'll take it for now simply because I've been banging at this for a while (with your much appreciated help).
              --------------------------------------------------
              Ben,

              It turns out that the following works:

              syntax on
              au Syntax tex setl isk+=_

              I didn't even need the autocmd lines:

              autocmd BufNewFile,BufRead,BufWinEnter *.tex setl isk+=_ | setg isk+=_

              autocmd BufNewFile,BufRead,BufWinEnter *.bib setg isk+=_ | setl isk+=_

              The problem is essentially solved that this point. What follows describes what I did in response to your advice on checking whether $HOME/vimfiles/after/syntax/tex.vim runs -- it does not. The word "after" doesn't even show up in the :scriptnames listing below. I think I will save that for another day. But if you have any suggestions (without going out of your way to dig), I'd be happy to follow up to the extent that I can.

              Thanks !!
              --------------------------------------------------
              "~" is my short hand for $HOME, which I set in my personal _vimrc via:

              let $HOME=$USERPROFILE."/Documents"
              set rtp^=$HOME/vimfiles

              I copied the vimfiles directory tree to .vim just as a desparate act, it didn't make any rational sense.

              In the code above, $USERPROFILE is C:\Users\MyUserAccount, which makes $HOME become C:\Users\MyUserAccount\Documents. I had to explicitly set up $HOME above because the default points at a network drive, which I don't have access to unless I'm connected on-site. However, explicitly setting $HOME in _vimrc means that $HOME is set only when my personal _vimrc is run. Since $HOME is not properly set prior to executing my personal _vimrc, I used VIMINIT to ensure that it would be _vimrc be initially executed

              Windows 7 user variable VIMINIT
              -------------------------------
              source %USERPROFILE%\Documents\_vimrc

              I'm sure that my $HOME is as expected because changes to _vimrc take place right away, e.g.:

              command TEST echo "YES TEST IS WORKING"

              Furthermore, :scriptnames shows a number of accesses to files in my personal vimfiles directory tree:

              1: C:/Users/MyUserAccount/Documents/_vimrc
              2: C:/Users/MyUserAccount/Documents/vimfiles/colors/mine.vim
              3: C:/Program Files (x86)/Vim/vim73/filetype.vim
              4: C:/Program Files (x86)/Vim/vim73/menu.vim
              5: C:/Program Files (x86)/Vim/vim73/autoload/paste.vim
              6: C:/Program Files (x86)/Vim/vim73/ftplugin.vim
              7: C:/Users/MyUserAccount/Documents/vimfiles/plugin/bufexplorer.vim
              8: C:/Program Files (x86)/Vim/vim73/plugin/getscriptPlugin.vim
              9: C:/Program Files (x86)/Vim/vim73/plugin/gzip.vim
              10: C:/Program Files (x86)/Vim/vim73/plugin/matchparen.vim
              11: C:/Program Files (x86)/Vim/vim73/plugin/netrwPlugin.vim
              12: C:/Program Files (x86)/Vim/vim73/plugin/rrhelper.vim
              13: C:/Program Files (x86)/Vim/vim73/plugin/spellfile.vim
              14: C:/Program Files (x86)/Vim/vim73/plugin/tarPlugin.vim
              15: C:/Program Files (x86)/Vim/vim73/plugin/tohtml.vim
              16: C:/Program Files (x86)/Vim/vim73/plugin/vimballPlugin.vim
              17: C:/Program Files (x86)/Vim/vim73/plugin/zipPlugin.vim
              18: C:/Program Files (x86)/Vim/vim73/ftplugin/tex.vim
              19: C:/Program Files (x86)/Vim/vim73/ftplugin/plaintex.vim
              20: C:/Program Files (x86)/Vim/vim73/ftplugin/initex.vim
              21: C:/Program Files (x86)/Vim/vim73/syntax/syntax.vim
              22: C:/Program Files (x86)/Vim/vim73/syntax/synload.vim
              23: C:/Program Files (x86)/Vim/vim73/colors/blue.vim
              24: C:/Program Files (x86)/Vim/vim73/syntax/syncolor.vim
              25: C:/Program Files (x86)/Vim/vim73/syntax/tex.vim
              26: C:/Program Files (x86)/Vim/vim73/scripts.vim
              27: C:/Program Files (x86)/Vim/vim73/ftplugin/help.vim
              28: C:/Program Files (x86)/Vim/vim73/syntax/help.vim
              29: C:/Program Files (x86)/Vim/vim73/ftplugin/vim.vim
              30: C:/Program Files (x86)/Vim/vim73/syntax/vim.vim
              31: C:/Program Files (x86)/Vim/vim73/autoload/netrw.vim
              32: C:/Users/MyUserAccount/Documents/vimfiles/.netrwhist
              33: C:/Program Files (x86)/Vim/vim73/syntax/netrw.vim

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

              ---
              You received this message because you are subscribed to the Google Groups "vim_use" group.
              To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
              For more options, visit https://groups.google.com/groups/opt_out.
            • Ben Fritz
              ... AHA! Note from :help runtimepath that the after directory is only used normally, because the default value of runtimepath contains
              Message 6 of 16 , Jun 20, 2013
              • 0 Attachment
                On Thursday, June 20, 2013 10:33:52 AM UTC-5, Paul wrote:
                >
                > The problem is essentially solved that this point. What follows describes what I did in response to your advice on checking whether $HOME/vimfiles/after/syntax/tex.vim runs -- it does not. The word "after" doesn't even show up in the :scriptnames listing below. I think I will save that for another day. But if you have any suggestions (without going out of your way to dig), I'd be happy to follow up to the extent that I can.
                >
                > Thanks !!
                > --------------------------------------------------
                > "~" is my short hand for $HOME, which I set in my personal _vimrc via:
                >
                > let $HOME=$USERPROFILE."/Documents"
                > set rtp^=$HOME/vimfiles
                >

                AHA!

                Note from :help 'runtimepath' that the "after directory" is only used normally, because the default value of 'runtimepath' contains $HOME/vimfiles/after as the last entry.

                Since you have moved your $HOME directory after Vim started up, you wisely re-inserted the new vimfiles location into the runtimepath. But, you did NOT re-insert the vimfiles/after directory!

                If you do not have other programs that pay attention to the HOME environment variable, you may be better off setting it directly on your system. Otherwise, you could modify your Vim shortcuts and .bat files and such to set HOME for you just before launching Vim. Or continue in the way you are doing things, but add a "set rtp+=$HOME/vimfiles/after" to your .vimrc.

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

                ---
                You received this message because you are subscribed to the Google Groups "vim_use" group.
                To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
                For more options, visit https://groups.google.com/groups/opt_out.
              • Gary Johnson
                ... I agree with everything you said, but I was wondering why just setting $HOME in _vimrc didn t work to set rtp . :help startup says that _vimrc is
                Message 7 of 16 , Jun 20, 2013
                • 0 Attachment
                  On 2013-06-20, Ben Fritz wrote:
                  > On Thursday, June 20, 2013 10:33:52 AM UTC-5, Paul wrote:
                  > >
                  > > The problem is essentially solved that this point. What follows
                  > > describes what I did in response to your advice on checking
                  > > whether $HOME/vimfiles/after/syntax/tex.vim runs -- it does not.
                  > > The word "after" doesn't even show up in the :scriptnames
                  > > listing below. I think I will save that for another day. But
                  > > if you have any suggestions (without going out of your way to
                  > > dig), I'd be happy to follow up to the extent that I can.
                  > >
                  > > Thanks !!
                  > > --------------------------------------------------
                  > > "~" is my short hand for $HOME, which I set in my personal _vimrc via:
                  > >
                  > > let $HOME=$USERPROFILE."/Documents"
                  > > set rtp^=$HOME/vimfiles
                  > >
                  >
                  > AHA!
                  >
                  > Note from :help 'runtimepath' that the "after directory" is only
                  > used normally, because the default value of 'runtimepath' contains
                  > $HOME/vimfiles/after as the last entry.
                  >
                  > Since you have moved your $HOME directory after Vim started up,
                  > you wisely re-inserted the new vimfiles location into the
                  > runtimepath. But, you did NOT re-insert the vimfiles/after
                  > directory!
                  >
                  > If you do not have other programs that pay attention to the HOME
                  > environment variable, you may be better off setting it directly on
                  > your system. Otherwise, you could modify your Vim shortcuts and
                  > .bat files and such to set HOME for you just before launching Vim.
                  > Or continue in the way you are doing things, but add a "set
                  > rtp+=$HOME/vimfiles/after" to your .vimrc.

                  I agree with everything you said, but I was wondering why just
                  setting $HOME in _vimrc didn't work to set 'rtp'.

                  ":help startup" says that _vimrc is sourced in step 3 and plugins
                  are sourced according to 'rtp' in step 4. I would think that 'rtp'
                  would be evaluated at step 4 according to the current value of
                  $HOME, which in the present case was set in step 3. That's not what
                  happens, though.

                  I set up an experiment. I created two "HOME" directories in my
                  actual $HOME directory. In each I created a minimal .vim hierarchy.
                  In one I put a .vimrc file that set $HOME to the other directory.
                  Then I executed vim with HOME set to the first directory and
                  executed :scriptnames to see which value of $HOME was used by 'rtp'
                  when the plugin was sourced.

                  $ cd
                  $ mkdir -p a/.vim/after/plugin
                  $ touch a/.vim/after/plugin/foo.vim
                  $ mkdir -p b/.vim/after/plugin
                  $ touch b/.vim/after/plugin/foo.vim
                  $ echo 'let $HOME="/home/gary/b"' > a/.vimrc
                  $ HOME=/home/gary/a vim
                  :scriptnames

                  I expected the last item in the output of ":scriptnames" to be

                  /home/gary/b/.vim/after/plugin/foo.vim

                  but instead it was

                  /home/gary/a/.vim/after/plugin/foo.vim

                  I even changed /home/gary/a/.vimrc to this:

                  let $HOME="/home/gary/b"
                  set rtp=
                  set rtp&

                  to force 'rtp' to be re-set with the current value of $HOME, but the
                  results were the same.

                  This doesn't seem right. Does anyone have an explanation.

                  I was using Vim 7.3.882 on Fedora 11.

                  Regards,
                  Gary

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

                  ---
                  You received this message because you are subscribed to the Google Groups "vim_use" group.
                  To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
                  For more options, visit https://groups.google.com/groups/opt_out.
                • Paul
                  Ben, thanks for pointing out the need to modify my rtp after setting $HOME: let $HOME=$USERPROFILE. /Documents set rtp^=$HOME/vimfiles set
                  Message 8 of 16 , Jun 21, 2013
                  • 0 Attachment
                    Ben, thanks for pointing out the need to modify my rtp after setting $HOME:

                    let $HOME=$USERPROFILE."/Documents"
                    set rtp^=$HOME/vimfiles
                    set rtp+=$HOME/vimfiles/after

                    The file $HOME/vimfiles/after/syntax/tex.vim is now executed when syntax is enabled in a tex file:

                    setg isk+=_
                    setlocal isk+=_

                    I don't want to mess around with $HOME in the larger Windows 7 environment because I don't control how IT works around here. If it doesn't break something now, it could break something in the distant future when I've all but forgotten about this little customization. So I will localize the customization to vim.

                    Gary, being the weekend warrior that I am, I don't think I can respond authoritatively about when rtp is set relative to the sourcing of _vimrc, but here's my take.

                    In ":help startup", step 4 uses :runtime. The help for :runtime sounds like it presumes that rtp is already set. So it looks like there isn't really basis for assuming that rtp is set at step 4. I can't find documentation on where it is set, but it could very well be set before any of the numbered startup steps. For that matter, the default value for rtp might be captured early on as well, which could explain why "set rtp&" still gets you the rtp resulting from the $HOME that is in effect when vim is executed.

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

                    ---
                    You received this message because you are subscribed to the Google Groups "vim_use" group.
                    To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
                    For more options, visit https://groups.google.com/groups/opt_out.
                  Your message has been successfully submitted and would be delivered to recipients shortly.