Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have installed windows vim and added the following function to my .bashrc:

function winvim() {
    local win_vim_path='/cygdrive/c/Program\ Files\ \(x86\)/Vim/vim73/vim.exe'
    #local win_vim_args=`cygpath -w -a "$*"`
    "$win_vim_path"
}

When I type winvim I am informed that there is 'No such file or directory'. However, if I type the path explicitly in cygwin vim runs as expected.

What is wrong here?

share|improve this question

migrated from stackoverflow.com Jun 5 '13 at 0:13

This question came from our site for professional and enthusiast programmers.

    
the `\` are going to be lost. you need to double-escape –  Marc B Jun 4 '13 at 19:16
2  
@MarcB sure? IMHO he dont't need the ` \ ` because the path is in single quotes... –  jm666 Jun 4 '13 at 19:20
    
but without the escapes the command will be seen as /cygdrive/c/Program with arguments Files and (x86)/Vim/vim73/vim.exe. –  Marc B Jun 4 '13 at 19:21
2  
@MarcB Not if you quote the expansion of win_vim_path. –  chepner Jun 4 '13 at 19:29
add comment

2 Answers 2

up vote 4 down vote accepted

When setting the value of win_vim_path, you need either single quotes or the backslashes to escape the spaces/parantheses, but not both.

local win_vim_path=/cygdrive/c/Program\ Files\ \(x86\)/Vim/vim73/vim.exe

or

local win_vim_path='/cygdrive/c/Program Files (x86)/Vim/vim73/vim.exe'

The quoted version is preferred as easier to read and type.

share|improve this answer
add comment

From memory:

local win_vim_path="$(cygpath -u "$PROGRAMFILES")/Vim/vim73/vim.exe"
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.