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

Re: VisVim and pathnames with embedded spaces

Expand Messages
  • Bram Moolenaar
    ... If you are able to build VisVim, try the patch below. It inserts a backslash in front of every space in the filename. I didn t verify this actually
    Message 1 of 2 , Jul 30, 2003
    • 0 Attachment
      Rob Retter wrote:

      > I have recently installed vim 6's VisVim add-on to the MSVC IDE, hoping to
      > use vim as the editor within Microsoft's C/C++ IDE (version 6) for Windows
      > (version 2000Pro).
      >
      > It works, except in the *very* common case where a source file sits in a
      > folder for which the fully-qualified pathname contains spaces. The obvious
      > example of such a folder would be any which reside under the "My Documents"
      > folder, a common location for the storage of files in Windows.
      >
      > When the pathname contains spaces, vim is invoked on several "files", where
      > each "file" name is a portion of space-separated text. For instance, let's
      > say that the file to be edited is:
      > C:\Documents and Settings\username\My Documents\subfolder\filename
      >
      > When vim is invoked, it thinks it was invoked on 4 files:
      > C:\Documents
      > and
      > Settings\username\My
      > Documents\subfolder\filename
      >
      > The typical method for dealing with such whitespace-related issues in most
      > command interpreters (UNIX shells, MS-DOS, etc) is to enclose the entire
      > fully-qualified name within quotes.
      >
      > Because I'm not actually forming the command by which vim gets invoked
      > (something underneath does that when I click on the Vim button that VisVim
      > added to my MSVC toolbar), I don't know how to get around this problem and
      > make the thing understand that the (apparent) arguments are all pieces of
      > one long name.

      If you are able to build VisVim, try the patch below. It inserts a
      backslash in front of every space in the filename. I didn't verify this
      actually works...

      *** ../vim-6.2.057/src/VisVim/Commands.cpp Sat Sep 7 17:03:06 2002
      --- src/VisVim/Commands.cpp Wed Jul 30 21:32:02 2003
      ***************
      *** 515,520 ****
      --- 515,521 ----
      char VimCmd[MAX_OLE_STR];
      char* VimCmdStart;
      char* s;
      + char* p;

      // Prepend CTRL-\ CTRL-N to exit insert mode
      VimCmd[0] = 0x1c;
      ***************
      *** 533,543 ****
      VimChangeDir (VimOle, DispatchId, FileName);

      // Make Vim open the file
      ! sprintf (VimCmd, ":drop %S\n", (char*) FileName);
      ! // Convert all \ to /
      ! for (s = VimCmd; *s; ++s)
      ! if (*s == '\\')
      ! *s = '/';
      if (! VimOle.Method (DispatchId, "s", TO_OLE_STR_BUF (VimCmd, Buf)))
      goto OleError;

      --- 534,552 ----
      VimChangeDir (VimOle, DispatchId, FileName);

      // Make Vim open the file
      ! // In the filename convert all \ to /, put a \ before a space.
      ! sprintf (VimCmd, ":drop ");
      ! s = VimCmd + 6;
      ! for (p = (char *)FileName; *p != '\0'; ++p)
      ! if (*p == '\\')
      ! *s++ = '/';
      ! else
      ! {
      ! if (*p == ' ')
      ! *s++ = '\\';
      ! *s++ = *p;
      ! }
      ! *s = '\n';
      if (! VimOle.Method (DispatchId, "s", TO_OLE_STR_BUF (VimCmd, Buf)))
      goto OleError;



      --
      Shift happens.
      -- Doppler

      /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
      /// Creator of Vim - Vi IMproved -- http://www.Vim.org \\\
      \\\ Project leader for A-A-P -- http://www.A-A-P.org ///
      \\\ Help AIDS victims, buy here: http://ICCF-Holland.org/click1.html ///
    Your message has been successfully submitted and would be delivered to recipients shortly.