Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a file that contains a SQL statement that looks like this that I paste in from some code. Can someone tell me the search/replace command for changing the + " values to blank or null?

I've tried various combinations of this but nothing seems to work

:%s\x ",,

  " select"
+ " col1 "
+ " col1 "
+ " col1 "
+ " col1 "
+ " from table"
share|improve this question

3 Answers 3

:%s/+\|"//g

Explanation:

%s - Search the whole file

/ - Separator character

+\|" Search for the string + or the string "

/ - Separator character

- Replace with nothing

/ - Separator character

g - "Global" replace (without this it would only do one substitution per line)

Substitutions are in the form range to look at/what to look for/what to replace with/options

The separator character can be anything, / is just the most common. Personally, I like ; because it makes it easier to read when you have a bunch of backslashes.

share|improve this answer
3  
An alternative: :%s/[+"]//g (a little easier to read) –  jahroy May 31 '13 at 6:22

I think this is the simplest way:

:%s/["+]//g

This assumes that you want to remove all " and + characters.

share|improve this answer

Try:

:%s/+ "//

Assuming you want to remove all '+ "' strings

share|improve this answer
    
I believe the OP also wants to remove the " characters at the end of each line. –  jahroy May 31 '13 at 6:39

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.