Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

what i want to do

  1. editing one file
  2. run '!svn diff %' (or any other command that takes the current file name)
  3. put the output on a new buffer (or tab)

bonus: not using a script, as i work often on hosts i do not manage to my liking.

My first try was: :tabnew | r !svn diff % which obvious does not work because % will be empty as it is parsed after the tabnew command.

share|improve this question
up vote 7 down vote accepted

This should work:

:tabnew | r !svn diff #

# references the previous buffer, i.e. the buffer you had open before the :tabnew was executed.

Even better is

:tabnew | set buftype=nowrite | r !svn diff #

because then vim won't complain when you close the tab, but this is already too much to type everytime.

share|improve this answer
    
This is a really powerful pattern! I wish I knew about that pipe command before. – AlexMA May 16 '14 at 17:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .