Skip to main content
deleted 106 characters in body
Source Link
Rui F Ribeiro
  • 58k
  • 28
  • 156
  • 238

I know this is gonna be a stupid question, but I've tried here, google and the official documentation.

I've got a file with a whole heap of words of the form 'foo' and i want to change them to Literal('foo'). The following :s command :%s/'.*'/Literal('.*')/gci finds the things i want to change but then it replaces them all with Literal('.*') rather than Literal('foo')

Examples:
I get:
'_' -> Literal('.*') 
'dog' -> Literal('.*') 
I want: 
'_' -> Literal('_') 
'dog' -> Literal('dog')

I know this is gonna be a stupid question, but I've tried here, google and the official documentation.

I've got a file with a whole heap of words of the form 'foo' and i want to change them to Literal('foo'). The following :s command :%s/'.*'/Literal('.*')/gci finds the things i want to change but then it replaces them all with Literal('.*') rather than Literal('foo')

Examples:
I get:
'_' -> Literal('.*') 
'dog' -> Literal('.*') 
I want: 
'_' -> Literal('_') 
'dog' -> Literal('dog')

I've got a file with a whole heap of words of the form 'foo' and i want to change them to Literal('foo'). The following :s command :%s/'.*'/Literal('.*')/gci finds the things i want to change but then it replaces them all with Literal('.*') rather than Literal('foo')

Examples:
I get:
'_' -> Literal('.*') 
'dog' -> Literal('.*') 
I want: 
'_' -> Literal('_') 
'dog' -> Literal('dog')
Source Link
vorpal
  • 145
  • 1
  • 5

use search result in replace statement with vim substitute

I know this is gonna be a stupid question, but I've tried here, google and the official documentation.

I've got a file with a whole heap of words of the form 'foo' and i want to change them to Literal('foo'). The following :s command :%s/'.*'/Literal('.*')/gci finds the things i want to change but then it replaces them all with Literal('.*') rather than Literal('foo')

Examples:
I get:
'_' -> Literal('.*') 
'dog' -> Literal('.*') 
I want: 
'_' -> Literal('_') 
'dog' -> Literal('dog')