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..
%R – Displays the read-only flag. %b – Shows the ASCII/Unicode character under cursor. 0x%B – Shows the hexadecimal character under cursor. %l – Display the row number. %c – Display the column number. %p%% – Show the cursor percentage from the top of the file. Type help: statusline for more information. This is the complete .vimrc file.
Vim complains about "trailing characters" because you give it erroneous commands like: that contain too much junk and thus can't be parsed correctly. Vim uses " for comments. If you didn't already, do $ vimtutor as many times as needed to get the basics right.
Every line in your virmc is an Ex command. :# is an Ex command that prints lines so it can't be used for comments. Vim complains about "trailing characters" because you give it erroneous commands like: that contain too much junk and thus can't be parsed correctly. Vim uses " for comments.
%c – Display the column number. %p%% – Show the cursor percentage from the top of the file. Type help: statusline for more information. This is the complete .vimrc file.
Instead of
exec 'normal :%s/(, /(/g'
You should just do
:%s/(, /(/g
Along with fixing the ^M
and ^[
issues that should solve your problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With