I'm trying to run a function that is in my vimrc to insert dependencies in a php class.
The script must enter a parameter type hinting in the construct of my class and assign the result of this parameter to an attribute of the local class.
I'm using Linux and I found in some posts that these types of characters that are in the function are not used to Linux. But for Mac.
The function:
function! AddDependency()
let dependency = input('Var Name: ')
let namespace = input('Class Path: ')
let segments = split(namespace, '\')
let typehint = segments[-1]
exec 'normal gg/construct^M:H^Mf)i, ' . typehint . ' $' . dependency . '^[/}^>O$this->^[a' . dependency . ' = $' . dependency . ';^[?{^MkOprotected $' . dependency . ';^M^[?{^MOuse ' . namespace . ';^M^['
" Remove opening comma if there is only one dependency
exec 'normal :%s/(, /(/g'
endfunction
And when I try to run this function I get:
Error detected while processing function AddDependency:
line 10:
E115: Missing quote: 'normal :%s/(, /(/g
E15: Invalid expression: 'normal :%s/(, /(/g
Press ENTER or type command to continue
What is exactly this special chars?
How can I fixed this and is there some reference to learn about this chars?
Thanks advance..
Instead of
exec 'normal :%s/(, /(/g'
You should just do
:%s/(, /(/g
Along with fixing the ^M
and ^[
issues that should solve your problem.
let segments = split(namespace, '\')
在我看来,这好像在反斜杠后缺少某些字符。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.