LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 12-15-2010, 06:06 PM   #1
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 3,225

Rep: Reputation: 49
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.
 
Old 12-15-2010, 06:16 PM   #2
mlangdn
Senior Member
 
Registered: Mar 2005
Location: Kentucky
Distribution: Slackware64-current
Posts: 1,380

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

http://www.worldtimzone.com/res/vi.html
 
1 members found this post helpful.
Old 12-15-2010, 06:19 PM   #3
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 3,225

Original Poster
Rep: Reputation: 49
Thanks a lot, mlangdn.
 
Old 12-15-2010, 06:32 PM   #4
markush
Senior Member
 
Registered: Apr 2007
Location: Germany
Distribution: Slackware
Posts: 3,974

Rep: Reputation: 849Reputation: 849Reputation: 849Reputation: 849Reputation: 849Reputation: 849Reputation: 849
Hi,
Code:
vim foo1.txt
then within vim
Code:
:e foo2.txt
and back again
Code:
:e #
Markus
 
1 members found this post helpful.
Old 12-15-2010, 06:37 PM   #5
barriehie
Member
 
Registered: Nov 2010
Distribution: Debian Lenny
Posts: 136
Blog Entries: 1

Rep: Reputation: 23
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
 
Old 12-15-2010, 06:39 PM   #6
mlangdn
Senior Member
 
Registered: Mar 2005
Location: Kentucky
Distribution: Slackware64-current
Posts: 1,380

Rep: Reputation: 180Reputation: 180
Quote:
Originally Posted by stf92 View Post
Thanks a lot, mlangdn.
You're welcome! I've been meaning to learn about vi/vim, and I had that one bookmarked.
 
Old 12-15-2010, 06:46 PM   #7
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 3,225

Original Poster
Rep: Reputation: 49
Quote:
Originally Posted by markush View Post
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?
 
Old 12-15-2010, 06:53 PM   #8
markush
Senior Member
 
Registered: Apr 2007
Location: Germany
Distribution: Slackware
Posts: 3,974

Rep: Reputation: 849Reputation: 849Reputation: 849Reputation: 849Reputation: 849Reputation: 849Reputation: 849
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
 
1 members found this post helpful.
Old 12-15-2010, 06:57 PM   #9
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 3,225

Original Poster
Rep: Reputation: 49
Vim's powerful.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Editor comparison: vim VS vim-lite, Cleaning vim Ruler2112 *BSD 4 04-13-2009 05:26 PM
Cant use vim nor vi help files amk229 Linux - Software 5 09-19-2007 06:01 PM
vim copy between files tekmann33 Linux - Newbie 2 09-14-2007 02:02 PM
VIM question: can I stop <Esc> moving the cursor back? xlq Linux - Software 9 06-03-2007 11:46 AM
multiple files in VIM james.farrow Linux - Newbie 3 07-09-2004 06:46 AM


All times are GMT -5. The time now is 12:51 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration