1

I am using Vim 7.3 on Windows 7.

The documentation on path says

The maximum length is limited. How much depends on the system, mostly it is something like 256 or 1024 characters.

However when I execute :echo strlen($path), I get 2533. I am glad it is more than 1024. It makes me wonder if the maximum length is controlled by some other setting that is not reflected in the documentation.

This is what I have in my _vimrc file.

set path =.
set path+=../include
set path+=$WORK_DIR/include
set path+=$WORK_DIR
set path+=$WORK_DIR/source/library/cmtabstractmodel
set path+=$WORK_DIR/source/library/cmtacisgeometry
set path+=$WORK_DIR/source/library/cmtapi
set path+=$WORK_DIR/source/library/cmtcad
set path+=$WORK_DIR/source/library/cmtdesignspaceexploration
set path+=$WORK_DIR/source/library/cmtenvironment
set path+=$WORK_DIR/source/library/cmtevent
set path+=$WORK_DIR/source/library/cmtexternaltask
set path+=$WORK_DIR/source/library/cmtfield
set path+=$WORK_DIR/source/library/cmtgeometricutility
set path+=$WORK_DIR/source/library/cmtgeometry
set path+=$WORK_DIR/source/library/cmtgraphics
set path+=$WORK_DIR/source/library/cmtgraphicsutility
set path+=$WORK_DIR/source/library/cmtinertiaspecification
set path+=$WORK_DIR/source/library/cmtkernel
set path+=$WORK_DIR/source/library/cmtlibrary
set path+=$WORK_DIR/source/library/cmtmesh
set path+=$WORK_DIR/source/library/cmtmultibodydynamics
set path+=$WORK_DIR/source/library/cmtnastranutility
set path+=$WORK_DIR/source/library/cmtoptical
set path+=$WORK_DIR/source/library/cmtplugin
set path+=$WORK_DIR/source/library/cmtprocess
set path+=$WORK_DIR/source/library/cmtproject
set path+=$WORK_DIR/source/library/cmtscheme
set path+=$WORK_DIR/source/library/cmtsettings
set path+=$WORK_DIR/source/library/cmtsimulationtask
set path+=$WORK_DIR/source/library/cmtsystemconsole
set path+=$WORK_DIR/source/library/cmtthermal
set path+=$WORK_DIR/source/library/cmttranslator
set path+=$WORK_DIR/source/library/cmtutility
set path+=$WORK_DIR/source/library/cmtvgi
set path+=$WORK_DIR/source/library/cmtxml
set path+=$QT_ROOT/include/QtCore
set path+=$QT_ROOT/include/QtGui
set path+=$QT_ROOT/include/QtXml
set path+=$ACIS_ROOT/include
set path+=$ACIS_ROOT/scm/scm/include
set path+=$ACIS_ROOT/scm/scmext/include
if s:MSWIN
   set path+=C:/Program\ Files/Microsoft\ Visual\ Studio\ .NET\ 2003/Vc7/include
else
   set path+=/usr/include/g++-3
   set path+=/usr/X11R6/include
endif
set path+=$EXTERNAL_ROOT/PTC/proeWildfire-2.0/protoolkit/includes
R Sahu
  • 204,454
  • 14
  • 159
  • 270
  • That's a very long `$PATH` you have but the `path` you refer to is *not* `$PATH`. Use `&path` to check the value of the `path` option. – romainl Mar 12 '14 at 16:40
  • References: `:help expr-option` and `:help expr-env`. – benjifisher Mar 12 '14 at 17:27
  • @romainl, `:echo strlen(&path)` prints 2178. That is still larger than the maximum that the documentation says it can be. – R Sahu Mar 12 '14 at 17:52
  • Hmmm, the default value of `path` on Windows is `.,,` so I'm wondering what you did to make it so large. I could understand 10, 20 or even 100 chars but 2178? – romainl Mar 12 '14 at 20:37
  • @romainl, the code used to set the value of path has been added to my original post. – R Sahu Mar 12 '14 at 20:58
  • @RSahu I imagine that this documentation was written a long time ago and those were the expected values when the documentation was written. The it depends on the system is why we can't answer this. It is most likely not a setting within vim. (Or anything that you can control) – FDinoff Jul 25 '14 at 13:37
  • @FDinoff, I'll let the bounty offer run it course. If there are no good answers by then, I'll delete this post. Thanks for contributing to the discussion. – R Sahu Jul 25 '14 at 16:44
  • Upvoted because you have rights to be inquisitive and there is no "stupid questions" if doesn't have an answer . – Nishant Jul 25 '14 at 19:27
  • @FDinoff, That's about the maximum size of %PATH% in the command prompt, quite different from the maximum length of `path` in Vim. – R Sahu Jul 25 '14 at 21:20

4 Answers4

1

Note the maximum length of an expanded option is limited. How much depends on the system, mostly it is something like 256 or 1024 characters.

Kamlesh
  • 654
  • 8
  • 21
1

According to the documentation of the function SetEnvironmentVariable:

The maximum size of a user-defined environment variable is 32,767 characters. For more information, see Environment Variables.

And it seems that for Windows XP and Windows Server 2003 the environment variable is not directly limited, instead, the Process Environment Block(PEB) is:

Windows Server 2003 and Windows XP: The total size of the environment block for a process may not exceed 32,767 characters.

But be aware, most of the programs will truncate the variable environment when reading it. So I recommend you to use one of the methods proposed here for Avoid over populate PATH Environment Variable in Windows.

Community
  • 1
  • 1
Raydel Miranda
  • 13,825
  • 3
  • 38
  • 60
  • I am not talking about windows environment variables. I am talking about a vim setting/variable. – R Sahu Jul 31 '14 at 14:49
0

How much depends on the system, mostly it is something like 256 or 1024 characters.

This seems to indicate that the max length varies based upon your computer.

In reality, the maximum length seems to be much larger than the estimates that the documentation gives, so much so that one doesn't need to worry too much about this limit.

Theoretically, I would conjecture that the maximum length of path depends on the amount of memory available to Vim, which can be edited :

The option 'maxmem' ('mm') is used to set the maximum memory used for one buffer (in kilobytes). 'maxmemtot' is used to set the maximum memory used for all buffers (in kilobytes). The defaults depend on the system used. For the Amiga and MS-DOS, 'maxmemtot' is set depending on the amount of memory available.

Edit: Reread your post and comments, and realized you were asking about the theoretical max.

DinoOcch
  • 430
  • 2
  • 11
0

I have found out the following, on my own, which may be of some help to you/others:

  • Indeed, you can do as many set path+=... as you wish (have only tried up to ~20k chars) and it works! Vim goes about it as you'd expect it to. However:
  • If you store the said set path+=... commands in a manually-edited Session.vim file, you'll likely find it overwritten by the :mks(ession)! command with just one line that contains a set path=... command, and which is only (!) 4k chars long; the only way around it is to keep a backup copy of the said Session.vim file, and to manually merge with it whenever said :mks(hit)! happens.
  • Also, whenever you call it out as :set path from Vim's own prompt, then only the said ~4k chars are being displayed.

HTH

ssz
  • 1