Working with Multiple files in Vim
This guide explains how you can work with multiple files in Vim by leveraging the :e command.
Guide Tasks
  • Read Tutorial
  • Watch Guide Video
Video locked
This video is viewable to users with a Bottega Bootcamp license

So we've walked through how to have multiple panes open at the same time for the situations where you want to have multiple files and see them simultaneously. However, what happens if you simply want to replace which file is being seen? So let's say that we have our trusty Gemfile here, and we want to, not actually see the Gemfile along with something else, we actually want to go and open another file.

Well, technically you could close out this file, and then go and open up another file. However, that's a lot of work, so instead, what you'll usually see Vim developers do is pass in an argument, so start a command and you use E. So I'm gonna do colon E and then from here I can actually pick out any file, so I can pick out our Gemfile and then it just swaps it right back. And I could go and do it again, so I could say app controller application controller and there you go, we have that open.

So this is a way where you can switch to different files without actually having to quit out of vim, and you could potentially, if you use this kind of workflow, which is what I do, and then you run various commands like running RSPEC or anything like that, then you could technically not really have to leave Vim as you're doing your development. Which makes for a much more efficient way of using the software, so that's how you can switch between files in Vim. And in the next guide, we're gonna start walking through how to use background jobs