Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

5
  • 1
    Great answer, especially the comprehensive alternatives! Commented Sep 16, 2013 at 12:53
  • OK thanks, yeah, I'd had a look at those docs (in @msw answer also). So, at the end of the day, I've still got to open the file with sudo anyway. Commented Sep 17, 2013 at 10:42
  • You don't need separate shell: if you're using bash, press Ctrl+Z in command mode (i.e. default mode) in vim - you'll put vim in background. After you do your work, you can use fg %n (or just %n) with whatever n vim gets (bash will print the number after you Ctrl+Z) to get vim back in foreground. Commented Sep 17, 2013 at 12:00
  • @Ruslan thanks for you comment. I extended the answer. In most cases, vim should become the current job of the shell, so fg without arguments should work. Commented Sep 17, 2013 at 12:18
  • Yeah, true in cases when you don't e.g. have multiple vim instances running in same shell and need earlier one :) . In this case you can even just use % without fg. Commented Sep 17, 2013 at 12:36