Question: For some reason I get, what I call an "uneven" output from Ack/Ag in the quickfix list window. 

My project directory structure is the following:

```
/home/user/projects/myproject
 |
 ---- llvm-or1k
 |
 ---- clang-or1k

```

I did a search with Ag using the following command:

```
:ag --nogroup --nocolor --column -S -U BuildSchedGraph /home/user/projects/myproject

```

And got the following output (snippet)

```
...

/home/user/projects/myproject/llvm-or1k/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.h|176 col 63| /// BuildSchedUnits, AddSchedEdges - Helper functions for BuildSchedGraph.

llvm-or1k/lib/CodeGen/SelectionDAG/ScheduleDAGVLIW.cpp|100 col 3| BuildSchedGraph(AA);

/home/user/projects/myproject/llvm-or1k/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp|336 col 3| BuildSchedGraph(NULL);

...

```

I can't understand why the first and the last "finds" have `/home/user/projects/myproject` prepended to the path while the second one doesn't.

This is becoming quite annoying.

Any help is appreciated.

Answer: 
Yes, it is annoying.

When Vim creates a quickfix list from the output of a program such as Ack, it creates a buffer for each file in the quickfix list using the name provided by the other program. This is often a full path name. Vim simplifies or resolves those names to relative path names upon certain events. The problem is that those names are not resolved when the quickfix list is displayed, so you see a mixture of full path names and relative path names.

There is no good solution available to users.

I have a workaround that is very much a hack, but it works for me because of the way I use Vim. That is, when I'm working on a project for which I use quickfix lists generated from programs such as cscope, I always start Vim in the top-level directory of the project and never use `:cd` or `:lcd`. It turns out that executing `:cd` is one of the events that causes Vim to resolve its buffer names, so I have the following in my `~/.vimrc`:

```
au BufAdd * exe "cd" fnameescape(getcwd())

```

As Vim creates the quickfix list, it adds a buffer for each file. That autocommand executes `:cd` to the current working directory for each file added and causes the file names to be resolved. Executing `:cd` like that is a no-op in my case. Again, this is a hack and it has side effects depending on what you're doing, but it works for me in my situation and makes my quickfix lists more appealing. It may work for you, too.
As garyjohn pointed out:

> 
> It turns out that executing :cd is one of the events that causes Vim to resolve its buffer names.
> 
> 
> 

So you can use that in a simple command:

```
command! Copen cd / | copen

```

You may want to cd to a more useful directory.

You could make this automatic with QuickFixCmdPost. See `:h QuickFixCmdPost-example`:

```
au QuickfixCmdPost make cd /home/user/projects/myproject | copen

```

or with garyjohn's no-op method:

```
au QuickfixCmdPost make exe "cd" fnameescape(getcwd())

```

But using cwd means some paths will be relative and some absolute. Using the project root makes them all relative.