Opening all modified files in an SVN repo with Vim

svn st | grep ^M | awk ‘{print($2)}’ | xargs vim -p

svn st – this is svn status, lists modified files with a M for modified

grep ^M only shows lines that start with a capital M.  If you have capital M in your filename and that file was displayed in “svn st” for some other reason then they would be kept in this list.  The ^ is regex for beginning of the line to prevent that.

awk is awesome.  This awk commmand just prints the 2nd column of data, which is the file path and name.

xargs is also awesome.  In this case we are using it to allow vim to open the list of file names without compaining about it.  Vim will still throw a warning, but no error.

vim is your editor, right?  -p opens them in separate tabs.  gt and gT move left and right through your tabs.

Instead of remembering this “one liner” you can set an alias in your .bashrc file.  mine looks like this:
alias vimAll=’svn st | grep ^M | awk “{print($2)}” | xargs vim -p’

So now in any svn checkout, I type vimAll to open all the modified files in and under the current directory.



Leave a Reply

Your email address will not be published. Required fields are marked *