LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Vim: getting back and forth between two files. (https://www.linuxquestions.org/questions/linux-newbie-8/vim-getting-back-and-forth-between-two-files-850509/)

stf92 12-15-2010 05:06 PM

Vim: getting back and forth between two files.
 
Hi:
I do 'vim foo1.txt foo2.txt'. How do I switch from one file to the other? Any hint will be welcome.

mlangdn 12-15-2010 05:16 PM

Here's a vi/vim cheat sheet. I think what you want is towards the bottom:

http://www.worldtimzone.com/res/vi.html

stf92 12-15-2010 05:19 PM

Thanks a lot, mlangdn.

markush 12-15-2010 05:32 PM

Hi,
Code:

vim foo1.txt
then within vim
Code:

:e foo2.txt
and back again
Code:

:e #
Markus

barriehie 12-15-2010 05:37 PM

Previous buffer
Code:

:bp
Next buffer
Code:

:bn
Or failing all of that you can install 'buftabs'. http://www.vim.org/scripts/script.php?script_id=1664

mlangdn 12-15-2010 05:39 PM

Quote:

Originally Posted by stf92 (Post 4192879)
Thanks a lot, mlangdn.

You're welcome! I've been meaning to learn about vi/vim, and I had that one bookmarked.

stf92 12-15-2010 05:46 PM

Quote:

Originally Posted by markush (Post 4192890)
and back again
Code:

:e #
Markus

Marvelous! But what does vim (or the shell) do with the second argument (vim foo1.txt foo2.txt) if I invoke that way? Does he take notice?

markush 12-15-2010 05:53 PM

Well, this works if you edit one file after another, when editing two buffers simultanously, you may use the code of barriehie in post #5
But if you edit both files simultanously with "vim foo1.txt foo2.txt" you'll have to use ":bp" or ":bn" once and may use ":e #" afterwards to switch between the two files.

Markus

stf92 12-15-2010 05:57 PM

Vim's powerful.


All times are GMT -5. The time now is 06:31 AM.