I have partially fixed my problem using the quickfix window by playing with the setting
set efm=\%f%\\s:%l: The magic comes from the first backslash \. With it, the output in quickfix will contain the full path. I searched the help document, but I still do not understand this efm format. Thanks Frank On Apr 6, 2:03 pm, Gary Johnson <[email protected]> wrote: > On 2010-04-06, [email protected] wrote: > > On Apr 6, 12:05 pm, Ben Fritz <[email protected]> wrote: > > > On Apr 6, 1:56 pm, "[email protected]" <[email protected]> > > > wrote: > > > > Hi, > > > > > I am using the findstr /f:file.txt /n pattern in my script to search > > > > the pattern. After the system the search results > > > > have the full path of the file name. However, after dump the result to > > > > quickfix window, some of the files are only displayed as relative > > > > path. Does anyone know how to fix this? > > > > > Here is the command that I am using: > > > > let files = 'c:\cscope.files' > > > > let scmd = 'findstr /f:'.files . ' /n ' . a:pattern > > > > let search_result = system(scmd) > > > > > exe "redir! > " . tmpfile > > > > silent echon search_result > > > > redir END > > > > exe "silent! cgetfile " . tmpfile > > > > I'm wondering if you considered using the :grep command within Vim, > > > which on Windows is already set up to do a findstr search by default. > > > It may save you some scripting headaches. > > > > > When I debug the code and echo the search_result, it contains the full > > > > path of the results. However, in the quickfix, some files are only > > > > displayed without the complete path. > > > > I think the quickfix list tries to make every path relative to the > > > current working directory. If you don't have autochdir set, and > > > you :cd to some directory containing none of your files (or the root > > > directory of whatever drive you are on will probably work), then the > > > quickfix list should show full paths. > > > > I'm not sure if there are other ways to accomplish this or not. > > This is annoying. There will be more coding to avoid this problem. > > Hopefully, there will be an option letting user making decision in > > future. > > I don't understand the problem. I think you may be trying to code a > solution that Vim already provides. > > > On the window, vim uses findstr even though you type grep command. > > Right. That's because Vim on Windows assumes that the only > grep-like command available is findstr. You can easily change > 'grepprg' to any command you like. You just need make sure the > output that your command produces and the input that 'grepformat' > expects agree with each other. > > For example, I think you could > > let &grepprg = 'findstr /f:'.files.' /n' > > and then > > :grep pattern > > to get the results you seem to be looking for. > > I don't how Vim decides whether to use the full or relative path > names in the quickfix list. It always "just works" for me, but I > usually navigate the quickfix list with mappings to :cn and :cp > rather than using the quickfix window. > > Please don't top-post on this list. > > Regards, > Gary- Hide quoted text - > > - Show quoted text - -- 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 To unsubscribe, reply using "remove me" as the subject.
