LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 05-16-2008, 06:24 AM   #1
jason.rohde
Member
 
Registered: Aug 2005
Location: Chicago
Distribution: RHEL5,CENTOS
Posts: 62

Rep: Reputation: 15
Question VIM Question


I haven't used VIM in any great capacity in quite a while and I need a quick refresher. I know that there is the option to open 2 documents in a single session of VIM, a split screen deal. I can't recall how this is done and I have not found it in the MAN page(I know it is there but I can't find it)nor can I find the instructions in the vimtutor (I didn't expect to find anything there but thought I would check anyway. Would some VIM guru tell me how to 1)open the vertical split screen option and 2) open the same file in both windows, one to edit and one to reference.

Thanks
 
Old 05-16-2008, 07:22 AM   #2
clvic
Member
 
Registered: Feb 2008
Location: Rome, Italy
Distribution: OpenSuSE 11.x, vectorlinux, slax, Sabayon
Posts: 206
Blog Entries: 2

Rep: Reputation: 45
To open the same file in two separate views, simply open your file with vim and then type :split.
To open two files in two views, open the first file, then type ":split <2ndfilename>" and you'll have the second file open.
Typing crtl+w and then arrow down switches to the lower split, with arrow up you'll go to the upper one.
 
Old 05-16-2008, 08:30 PM   #3
jason.rohde
Member
 
Registered: Aug 2005
Location: Chicago
Distribution: RHEL5,CENTOS
Posts: 62

Original Poster
Rep: Reputation: 15
You rock, thanks
 
Old 05-16-2008, 09:55 PM   #4
jason.rohde
Member
 
Registered: Aug 2005
Location: Chicago
Distribution: RHEL5,CENTOS
Posts: 62

Original Poster
Rep: Reputation: 15
one more question and I should be set. I know that there is a search and replace feature in VIM, can I use this to remove any instance of unwanted text from a file. As you can probably guess I have a large file that is very cluttered and for ease of administration I need to clean it out. Problem being that this file is constantly being added too, but no one before me has had the clarity of thought to remove the information that is no longer necessary. In order to get this cleaned up I need to be able to muscle through it in a single shift and to go through line by line could take a very long time.

Example;

:%s/[unwanted text]/[delete]/cgi
 
Old 05-17-2008, 06:13 AM   #5
clvic
Member
 
Registered: Feb 2008
Location: Rome, Italy
Distribution: OpenSuSE 11.x, vectorlinux, slax, Sabayon
Posts: 206
Blog Entries: 2

Rep: Reputation: 45
In this case, from within vim type ":help substitution" and you'll have the complete reference about this topic.
I don't know how to tell vim to substitute in the whole file, but you can type "100 ." to repeat the last command 100 times. Obviously, you can type the number you like...
but if you frequently need such an automated task, you should definitely opt for something like "sed" (very simple and efficient for string substitutions)
 
Old 05-17-2008, 06:20 AM   #6
jason.rohde
Member
 
Registered: Aug 2005
Location: Chicago
Distribution: RHEL5,CENTOS
Posts: 62

Original Poster
Rep: Reputation: 15
clvic, you are the man! thanks for the help
 
  


Reply



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
A vim question rangalo Debian 0 06-15-2007 05:51 AM
vim question xtremeclones Linux - General 2 07-07-2006 01:58 PM
A little vim question EAD Linux - Newbie 1 03-29-2006 10:54 AM
vim question blackzone Linux - Newbie 2 09-10-2004 10:04 AM
vi/vim question kiley_rodgers Slackware 1 06-18-2003 09:15 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

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

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration