Skip to main content
deleted 47 characters in body
Source Link
muru
  • 25.1k
  • 8
  • 83
  • 144

I have a vim script, which uses Unix type path separator as:

  "Prg: Expand snippets {{{!
    let s:plugin_dir=filter(split(&rtp, ','), 'v:val =~ "/vimf90"')[0]
    let s:templatedir=s:plugin_dir . '/templates/'
    function! Prog(arg)
      execute 'r ' . s:templatedir . a:arg . '.txt'
      %substitute#\[:EVAL:\]\(.\{-\}\)\[:END:\]#\=eval(submatch(1))#ge
    endfunction
    "}}}
    "

I have never used Windows, so I was not aware that it may break in windowsWindows. One of my userusers reported thethis issue:

The script works very well on Linux system, but when I try it on Windows, it does not work with the following error:

================================================= 
Error detected while processing
C:\User\Ki-Tae\vimfiles\plugged\vimf90\ftplugin\fortran_comp.vim: line
102: E684: list index out of range: 0 E15: Invalid expression:
filter(split(&rtp, ','), 'v:val =~ "/vimf90"')[0] line 103: E121:
Undefined variable: s:plugin_dir E15: Invalid expression: s:plugin_dir
. '/templates/'
=================================================
> ================================================= 
Error detected while processing
> C:\User\Ki-Tae\vimfiles\plugged\vimf90\ftplugin\fortran_comp.vim: line
> 102: E684: list index out of range: 0 E15: Invalid expression:
> filter(split(&rtp, ','), 'v:val =~ "/vimf90"')[0] line 103: E121:
> Undefined variable: s:plugin_dir E15: Invalid expression: s:plugin_dir
> . '/templates/'
> =================================================

Also, he was kind enough to send me back the solution as:

In Windows, forward slash should be backward slash, so the code should be

filter(split(&rtp, ','), 'v:val =~ "\vimf90"')[0]
filter(split(&rtp, ','), 'v:val =~ "\vimf90"')[0]

and

s:plugin_dir . '\templates\'
s:plugin_dir . '\templates\'

Which he claims to work for him.

As far as I know, vim should alter the path separators inherently. But, clearly, this is not the case here.

The complete code in question is available here.

I will be grateful if someone kindly check this. I can't do that since I don't have any access to windowsWindows.

Thanks and Regards,

I have a vim script, which uses Unix type path separator as:

  "Prg: Expand snippets {{{!
    let s:plugin_dir=filter(split(&rtp, ','), 'v:val =~ "/vimf90"')[0]
    let s:templatedir=s:plugin_dir . '/templates/'
    function! Prog(arg)
      execute 'r ' . s:templatedir . a:arg . '.txt'
      %substitute#\[:EVAL:\]\(.\{-\}\)\[:END:\]#\=eval(submatch(1))#ge
    endfunction
    "}}}
    "

I have never used Windows, so I was not aware that it may break in windows. One of my user reported the issue:

The script works very well on Linux system, but when I try it on Windows, it does not work with the following error:

> ================================================= 
Error detected while processing
> C:\User\Ki-Tae\vimfiles\plugged\vimf90\ftplugin\fortran_comp.vim: line
> 102: E684: list index out of range: 0 E15: Invalid expression:
> filter(split(&rtp, ','), 'v:val =~ "/vimf90"')[0] line 103: E121:
> Undefined variable: s:plugin_dir E15: Invalid expression: s:plugin_dir
> . '/templates/'
> =================================================

Also, he was kind enough to send me back the solution as:

In Windows, forward slash should be backward slash, so the code should be

filter(split(&rtp, ','), 'v:val =~ "\vimf90"')[0]

and

s:plugin_dir . '\templates\'

Which he claims to work for him.

As far as I know, vim should alter the path separators inherently. But, clearly, this is not the case here.

The complete code in question is available here.

I will be grateful if someone kindly check this. I can't do that since I don't have any access to windows.

Thanks and Regards,

I have a vim script, which uses Unix type path separator as:

"Prg: Expand snippets {{{!
let s:plugin_dir=filter(split(&rtp, ','), 'v:val =~ "/vimf90"')[0]
let s:templatedir=s:plugin_dir . '/templates/'
function! Prog(arg)
  execute 'r ' . s:templatedir . a:arg . '.txt'
  %substitute#\[:EVAL:\]\(.\{-\}\)\[:END:\]#\=eval(submatch(1))#ge
endfunction
"}}}
"

I have never used Windows, so I was not aware that it may break in Windows. One of my users reported this issue:

The script works very well on Linux system, but when I try it on Windows, it does not work with the following error:

================================================= 
Error detected while processing
C:\User\Ki-Tae\vimfiles\plugged\vimf90\ftplugin\fortran_comp.vim: line
102: E684: list index out of range: 0 E15: Invalid expression:
filter(split(&rtp, ','), 'v:val =~ "/vimf90"')[0] line 103: E121:
Undefined variable: s:plugin_dir E15: Invalid expression: s:plugin_dir
. '/templates/'
=================================================

Also, he was kind enough to send me back the solution as:

In Windows, forward slash should be backward slash, so the code should be

filter(split(&rtp, ','), 'v:val =~ "\vimf90"')[0]

and

s:plugin_dir . '\templates\'

Which he claims to work for him.

As far as I know, vim should alter the path separators inherently. But, clearly, this is not the case here.

The complete code in question is available here.

I will be grateful if someone kindly check this. I can't do that since I don't have any access to Windows.

Source Link
BaRud
  • 491
  • 3
  • 10

path seperator in vim

I have a vim script, which uses Unix type path separator as:

  "Prg: Expand snippets {{{!
    let s:plugin_dir=filter(split(&rtp, ','), 'v:val =~ "/vimf90"')[0]
    let s:templatedir=s:plugin_dir . '/templates/'
    function! Prog(arg)
      execute 'r ' . s:templatedir . a:arg . '.txt'
      %substitute#\[:EVAL:\]\(.\{-\}\)\[:END:\]#\=eval(submatch(1))#ge
    endfunction
    "}}}
    "

I have never used Windows, so I was not aware that it may break in windows. One of my user reported the issue:

The script works very well on Linux system, but when I try it on Windows, it does not work with the following error:

> ================================================= 
Error detected while processing
> C:\User\Ki-Tae\vimfiles\plugged\vimf90\ftplugin\fortran_comp.vim: line
> 102: E684: list index out of range: 0 E15: Invalid expression:
> filter(split(&rtp, ','), 'v:val =~ "/vimf90"')[0] line 103: E121:
> Undefined variable: s:plugin_dir E15: Invalid expression: s:plugin_dir
> . '/templates/'
> =================================================

Also, he was kind enough to send me back the solution as:

In Windows, forward slash should be backward slash, so the code should be

filter(split(&rtp, ','), 'v:val =~ "\vimf90"')[0]

and

s:plugin_dir . '\templates\'

Which he claims to work for him.

As far as I know, vim should alter the path separators inherently. But, clearly, this is not the case here.

The complete code in question is available here.

I will be grateful if someone kindly check this. I can't do that since I don't have any access to windows.

Thanks and Regards,