4

I just found out that we can use :e . to enter the browsing mode and then can choose file what we like.

vim

But I don't know how to get back to already opened file without choosing it again.

I tried <Esc> and :q but the first one doesn't work and second closes the file I have opened already (.vimrc in my case).

7

You can use any of Vim's many buffer-switching commands to return to the file you were previously working on.

Here's a few possibilities:

  • Use the :buffer command to jump to the alternate buffer: :b #
  • Use the normal mode command to jump to the alternate buffer: <C-^>
  • Just step back through the jump list till you get there: <C-O>

As Peter Rincker points out in a comment below, you can also use the dedicated :Rexplore command provided by the file explorer plugin (netrw) itself to do this: :Rex will return you to the file you were editing previously if run from explorer view (and will conversely return you back to the explorer view if you subsequently run it from a normal buffer).

  • 1
    You can use :Rex to resume exploring right where you left off – Peter Rincker Nov 22 '17 at 20:19
  • Those who try to :Rex when you were previously in a [No Name] buffer may think isn't working, and that's correct. If it's by design, it seems bad because someone may have stuff typed in that buffer. You can use :b # in that case, though. Note: only if that [No Name] buffer wasn't empty. – shmup Jan 11 '18 at 1:35
0

as Rich has mentioned, we can use :b<buffer_number> to jump to a buffer,
we can see buffer_number using command :list

In my case I just wanted to go to previous buffer/file, so we can use

:bp

this will get us to the previously edited buffer,

Thanks, icc97, Rich and everyone....

#Happy coding

  • Note that this command won't always have the effect of returning to the file you were in before entering netrw: it steps back through the buffer list, which is ordered according to when the buffers were created, not when they were most recently visited. – Rich Nov 29 '17 at 9:38
  • So, which command can help me with that specific problem, I do not want to dive deep into any of tool, as I am very new to VIM, and do not want to get overwhelmed. – Ashish Patel Nov 30 '17 at 18:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.