2

This is my issue with Vim: you have it open for a couple of days. You're ready to close vim. You don't necessarily want to save all files... you want to skip any files which don't have modified changes, and you want to be left (or be asked) what you want to do with the remaining buffers with unmodified changes…

For anyone that has used Photoshop, this is very familiar… you use it for a week, and when you close Photoshop, it is really trying to close the application, and skips all files which haven't been touched, let's you chose what you want to do with the remaining files, and then closes itself.

It seems like every time I close Vim, I have to go through this circus of doing :qa, then running into a file, doing :bd!, then doing :qa again, run into a file I want, :w, and it's just a huge pain. There has to be a better way of doing this.

If it isn't already obvious… I have :set hidden in my .vimrc.

epsilonhalbe
  • 15,637
  • 5
  • 46
  • 74
Rey
  • 3,639
  • 5
  • 33
  • 40

3 Answers3

1

How about

:confirm qa

It asks you for each modified file whether to save or abandon it (or all remaining). This is the same behavior that GVIM exhibits when you close it via the X in the window title.

Ingo Karkat
  • 167,457
  • 16
  • 250
  • 324
  • Only one problem with that: whereas Photoshop would bring the file in question to the forefront, this command does not, i.e. if I'm on a file that hasn't been modified, I do the command you're suggesting, it asks me if I want to save UNTITLED but doesn't give any sort of clue as to what Untitled is....also if this has to be the fix I understand but I'd rather stay away from the gui prompts... – Rey Nov 27 '12 at 11:00
  • If you want anything more than that, you'll have to write your own complex command. Bringing to the front would potentially run autocmds, something that may run arbitrary actions... not a good idea when you want to quit (quickly). – Ingo Karkat Nov 27 '12 at 11:19
  • I'm not asking for something specific.... I'm describing what I want, and am asking people to come close. For instance.... consider :bufdo bdelete, which closes all non-modified buffers, which gets that out of the way... and then :qa, then from there I can have mappings to either save or quit the file, which will automatically go to the next buffer and once I'm done with the last buffer, MacVim will close. That's all very possible, but I'm asking for either better solutions than that, or an implementation of that. Telling me I'll need to write my own complex command is sort of redundant. – Rey Nov 27 '12 at 12:50
0

does :xa! solve your problem ?

:xa[ll]!    Write all changed buffers, even the ones that are readonly,
        and exit Vim.  If there are buffers without a file name or
        which cannot be written for another reason, Vim will not quit.
Kent
  • 189,393
  • 32
  • 233
  • 301
  • No, because Vim (:xa!) pretty much tells me what I already know... that there are unnamed buffers, but it doesn't for instance close all non-modified buffers and focus on the buffers it says need attention. – Rey Nov 26 '12 at 22:14
0

I was able to find the plugin BufOnly, and then with the help of someone else on StackOverflow, I got an answer that satisfies me:

https://stackoverflow.com/a/14690570/240287

Community
  • 1
  • 1
Rey
  • 3,639
  • 5
  • 33
  • 40