简体   繁体   English

vimrc函数中的错误字符

[英]Error characters in vimrc function

I'm trying to run a function that is in my vimrc to insert dependencies in a php class. 我正在尝试运行vimrc中的函数以在php类中插入依赖项。
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. 我正在使用Linux,并且在一些帖子中发现该函数中的这些类型的字符不适用于Linux。 But for Mac. 但对于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. 除了解决应解决您的问题的^M^[问题。

let segments = split(namespace, '\')

在我看来,这好像在反斜杠后缺少某些字符。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM