LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > General
User Name
Password
General This forum is for non-technical general discussion which can include both Linux and non-Linux topics. Have fun!

Notices

Reply
 
Search this Thread
Old 08-21-2008, 09:36 AM   #1
Berticus
Member
 
Registered: Jul 2005
Distribution: Arch
Posts: 159

Rep: Reputation: 31
[SOLVED] vim search pattern


I have vim on Windows, and need to use it to edit a file containing a list of files. An example would be something like "C:\Documents and Settings\Berticus\foo\bar." I would like to replace "C:\Documents and Settings\Berticus" with something like "D:\Backup\Berticus Files"

If I do something like
Code:
:%s/C:\Documents and Settings\Berticus/D:\Backup\Berticus Files
It says:
Code:
E486: Pattern not found: C:\Documents and Settings\Berticus
But pretty much every line starts with that.

I also tried:
Code:
:%s/*Berticus/D:\Backup\Berticus Files
and that didn't work either.

I don't have a lot of experience with patterns, and the semicolon always throughs everything off. I've always found a way to work around it, but this time I can't seem to figure a way around it.

---Edit---
Solved:
Code:
:%s/.*Berticus/D:\Backup\Berticus Files

Last edited by Berticus; 08-21-2008 at 10:10 AM. Reason: Fixed
 
Old 08-21-2008, 10:26 AM   #2
oneandoneis2
Senior Member
 
Registered: Nov 2003
Location: London, England
Distribution: Ubuntu
Posts: 1,460

Rep: Reputation: 46
You need TWO backslashes: C:\\Documents etc.

Backslash is a special character, it's so you can do things like :%s/Indent/\tIndent and it'll insert a tab in front of the word Indent..
 
Old 08-21-2008, 11:39 AM   #3
Berticus
Member
 
Registered: Jul 2005
Distribution: Arch
Posts: 159

Original Poster
Rep: Reputation: 31
Quote:
Originally Posted by oneandoneis2 View Post
You need TWO backslashes: C:\\Documents etc.

Backslash is a special character, it's so you can do things like :%s/Indent/\tIndent and it'll insert a tab in front of the word Indent..
Didn't think it was a special character issue since I was having a similar problem with a different program (in Linux). I used a double backslash to get a backslash character, but I still had the problem.
 
Old 08-21-2008, 12:13 PM   #4
oneandoneis2
Senior Member
 
Registered: Nov 2003
Location: London, England
Distribution: Ubuntu
Posts: 1,460

Rep: Reputation: 46
Not sure why you still had the issue:

:%s/C:\\Documents and Settings\\Berticus/D:\\Backup\\Berticus Files

works for me. But it's good to know you solved it, whatever way
 
  


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
Vim - Pattern to match email address taylor_venable Linux - Software 2 01-31-2007 04:56 PM
Question on aptitude search pattern Akhran Linux - Newbie 4 02-10-2006 12:39 PM
vim: search pattern / replace with file naflan Programming 5 01-07-2006 03:16 PM
Quick VIM question (unhighlighting search terms after search) lrt2003 Linux - Newbie 5 05-08-2004 05:21 PM
Pattern search in a line jitz Linux - General 2 12-06-2003 04:50 AM


All times are GMT -5. The time now is 11:30 PM.

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