LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 01-24-2011, 03:52 AM   #1
armandino
Member
 
Registered: Oct 2005
Posts: 72

Rep: Reputation: 15
Vim - string replacement from current position to end of file


What is the vim command I have to use when I want to perform a text substitution not on the current line or on the whole document or on lines from number x to number y but just from the current cursor position down to the end (or up to the beginning) of the document?
 
Old 01-24-2011, 04:12 PM   #2
Snark1994
Senior Member
 
Registered: Sep 2010
Location: Wales, UK
Distribution: Arch
Posts: 1,632
Blog Entries: 3

Rep: Reputation: 345Reputation: 345Reputation: 345Reputation: 345
Code:
:.,$s/pattern1/pattern2/g
to end of document.
Code:
:1,.s/pattern1/pattern2/g
from start of document. "." is considered to be the current line number.
Hope this helps

Last edited by Snark1994; 01-24-2011 at 04:15 PM. Reason: Added search from start
 
1 members found this post helpful.
  


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 On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
awk from end of string -3 position comparison dazdaz Linux - Software 4 10-04-2010 11:31 AM
how do i replace a text string in a file with a random string? (with sed etc) steve51184 Linux - Software 16 09-02-2010 12:05 PM
Using sed/awk to replace a string at a given position in anoopvraj Linux - Newbie 6 05-30-2009 08:59 AM
How to find a particular string occurance position in a file? vigneshinbox Programming 5 04-03-2009 12:52 AM
Replacing character position within the string of a file scroy Linux - Newbie 13 11-08-2008 06:45 PM


All times are GMT -5. The time now is 08:20 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration