tags:

views:

96

answers:

2

I want to run command like this:

vim -c "%g/blablabla/norm /str<ESC>cwSTR" file

How I write escape character in the command?

+1  A: 

As you type the command, use control-v then escape to enter the escape.

However, I have to question whether vim is the right tool for this job. Normally, you would be better off with something like sed. That said, I'm not quite clear what the vim command is up to, so maybe you do need it.

Jonathan Leffler
Actually what I want to do is to replace last argument of some function. So I use vim facilities to navigate in code. The actual command is: -c "%g/fun_name//func_name<ESC>w%bcwREPLACE_TEXT". This search fuunction invocation, goes to the closing ), steps backward 1 word and replace the last argument.
dimba
Ok it works. I wasn't aware it works in bash too, I thought it works only in vim.
dimba
@idimba: I see why you're using vim for the job - it probably makes more sense than most other tools given what you are doing.
Jonathan Leffler
A: 

This is what I would do:

vim -s -c ':exec "normal %g/blablabla/norm /str\<Esc>cwSTR"' file

Notice that I am using :exec to expand the "\" to the real . The advantage? it is more script friendly. However, I am not sure what this command is doing, are you using some of your custom maps here?

haridsv