Jose Caballero
unread,Mar 13, 2023, 10:00:27 AM3/13/23Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to vim use
Hello,
I have this function [*].
It is meant to create a line when opening a new file with extension
.pan, where that line is based on the path of the file.
That code works on my personal computer, with VIM 9.0.1023
However, it fails on the computer at work where it has to run, with VIM 7.4.629
I get this error [**].
Is there an easy way to make it work with version 7.4?
Thanks a lot in advance.
Cheers,
Jose
[*]
function! CreatePanFile()
let path = expand('%:p:h')
let file = expand('%:t:r')
let features_idx = match(path, 'features')
if features_idx != -1
let features_path = substitute(path[features_idx:],
'\v(features\/.*)$', '\1', '')
let line = "template '" . features_path . "/" . file . "';"
call setline(1, line)
endif
endfunction
autocmd BufNewFile *.pan call CreatePanFile()
[**]
Error detected while processing function CreatePanFile:
line 5: E121: Undefined variable: features_idx:
E116: Invalid arguments for function substitute(path[features_idx:],
'\v(features\/.*)$', '\1', '')
E15: Invalid expression: substitute(path[features_idx:],
'\v(features\/.*)$', '\1', '')
line 6: E121: Undefined variable: features_path
E15: Invalid expression: "template '" . features_path . "/" . file . "';"
line 7: E121: Undefined variable:
line E116: Invalid arguments for function setline