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

Re: winfileexplorer can't open files containing spaces in their filename

Expand Messages
  • Edward L. Fox
    Hi VIMmers, The patch I made to winfileexplorer to support opening selected file with associated external program doesn t work properly under M$ Windoze. Here
    Message 1 of 4 , Sep 28, 2005
    • 0 Attachment
      Hi VIMmers,

      The patch I made to winfileexplorer to support opening selected file with
      associated external program doesn't work properly under M$ Windoze. Here is
      the patch:

      ============= filename: $VIM/vimfiles/plugin/winfileexplorer.vim =============
      4c4
      < " Last Change: 2005-09-28 17:09:38
      ---
      > " Last Change: 2005-09-29 12:11:48
      673c673,677
      < exec "silent !start \'".fn."\'"
      ---
      > if (has("win32"))
      > exec "silent ! start \"\" \"".substitute(fn, "/", "\\", "g")."\""
      > else
      > exec "silent !start \'".fn."\'"
      > endif
      ==================================== end =====================================

      I'm not using Windoze so I didn't recognize such problem yesterday. Sorry for
      my carelessness, and many thanks to my friend who lent me the laptop with
      Windoze for debugging the script.

      The hacking that Mr. Moolenaar made to "!start" under M$ Windoze really
      puzzled me so much when I was debugging the script. See ":help !start" for
      more details.

      To avoid this special treatment, use ":! start".

      -- Bram Moolenaar


      Regards,

      Edward L. Fox


      在 05-9-28,Edward L. Fox<edyfox@...> 写道:
      > ---------- Forwarded message ----------
      > From: Edward L. Fox <edyfox@...>
      > Date: 2005-9-28 下午5:31
      > Subject: winfileexplorer can't open files containing spaces in their filename
      > To: vim@...
      >
      >
      > Hi VIMmers,
      >
      > I'm using winmanager to navigate files in my system. The plugin can be found
      > at this address:
      >
      > http://vim.sourceforge.net/scripts/script.php?script_id=95
      >
      > But winmanager is not able to open the files which contain spaces in their
      > filenames. So I did a little adjustment. Here is the patch:
      >
      > =================== filename: ~/.vim/plugin/winmanager.vim ===================
      > 4c4
      > < " Last Change: Wed Apr 03 05:00 PM 2002 PST
      > ---
      > > " Last Change: 2005-09-28 16:57:01
      > 456c456
      > < exe 'silent! split '.bufcall
      > ---
      > > exe 'silent! split '.escape(bufcall, " ")
      > 458c458
      > < exe 'silent! e '.bufcall
      > ---
      > > exe 'silent! e '.escape(bufcall, " ")
      > ==================================== end =====================================
      >
      > I added a little feature into winfileexplorer.vim: positioning your cursor on
      > a filename or a folder in the file list and press "S" will open the file with
      > the corresponding external program which is currently associated with the file
      > type. So now I can launch an xmms to play a piece of music without leaving my
      > (g)vim.
      >
      > Here is the patch:
      >
      > ================ filename: ~/.vim/plugin/winfileexporer.vim ==================
      > 4c4
      > < " Last Change: Sun Mar 31 11:00 PM 2002 PST
      > ---
      > > " Last Change: 2005-09-28 17:09:38
      > 438a439
      > > nnoremap <buffer> S :call <SID>ShellExecute()<cr>
      > 651a653,675
      > >
      > > "---
      > > " Open file or directory with the corresponding application
      > > " associated by the shell
      > > "
      > > function! s:ShellExecute()
      > > " Are we on a line with a file name?
      > > let l = getline(".")
      > > if l =~ '^"'
      > > return
      > > endif
      > >
      > > " Copy window settings to script settings
      > > let s:sortby=w:sortdirlabel . w:sorttype
      > > let s:longhelp = w:longhelp
      > > let s:longlist = w:longlist
      > >
      > > " Get the file name
      > > let fn=s:GetFullFileName()
      > >
      > > exec "silent !start \'".fn."\'"
      > > endfunction
      > >
      > 912a937
      > > \."\" S : open the file/folder with external program\n"
      > ==================================== end =====================================
      >
      > I'm using the utility "start" to launch the external program, the source code
      > is shown below:
      >
      > =================================== start ====================================
      > #!/bin/sh
      > # For KDE only.
      >
      > if (test $# = 0) then
      > echo Usage: start filename
      > else
      > while (test $# -gt 0)
      > do
      > kfmclient exec "$1"
      > shift
      > done
      > fi
      > ==================================== end =====================================
      >
      > Can anybody provide me an implementation for GNOME? Thanks very much!
      >
      >
      > Regards,
      >
      > Edward L. Fox
      >
    Your message has been successfully submitted and would be delivered to recipients shortly.