Hi Ven!

On Mi, 09 Mär 2011, Ven Tadipatri wrote:

> I've had a bit of frustration opening file paths when running VIM
> through Cygwin because of the forward vs. backslash issue. Finally I
> decided to add a mapping to my vimrc. It's rather clunky, but allows
> me to copy a path that I have, say in a windows folder, and open it
> easily in vim:
> 
> "Map the insert key to paste what's on the clipboard
> nmap <Insert> iz<Esc>mz:execute "normal a".system("cat /dev/clipboard")<CR>`zx
> "Map Control-n to paste what's on the clipboard, then change the
> slashes, add cygdrive to it, and open the path in a new tab
> map <C-n> 
> A<CR><Esc><Insert>A<CR><Esc>k:s#\\\\#/#g<CR>I/cygdrive/<Esc>llx^v$h"yy:new
> <C-r>y<CR>
> 
> It's not the prettiest Vim macro in the world, but I can finally just
> copy a path that's in the Windows format and not pull my hair out
> trying to figure out how to open it in vim.

Hm, I remember some years back, that I was using the cygpath utility to 
convert the path between both systems. See here:
http://www.cygwin.com/cygwin-ug-net/using-utils.html

>   I tried just doing :new followed by the path to the file in quotes,
> but I think the problem is that the slashes are interpreted as escape
> characters. Why did Microsoft have to be different? Why couldn't they
> just use slashes the same way as Unix systems did? It would have saved
> countless hours of programming and development over the years.

Something like this?
:new "/foobar/baz/file.txt" ?

That won't work, because " acts as a comment sign and so you would 
actually perform a :new
Simply don't use the quotes, but you need to escape spaces and other 
special filenames. The fnameescape() function is helpful to escape all 
special letters.


regards,
Christian

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

Reply via email to