[vim/vim] /etc/vim/anyscript does not load the same as from .vimrc (Issue #11475)

18 views
Skip to first unread message

Mattis DALLEAU

unread,
Oct 31, 2022, 8:35:04 AM10/31/22
to vim/vim, Subscribed

Steps to reproduce

  1. Add source /etc/vim/myscript.vim in /etc/vim/vimrc
  2. Put my script at /etc/vim/myscript.vim
  3. Tells me that the dictionary has invalid syntax (See Expected Behaviour)
  4. Remove the line in source /etc/vim/myscript.vim in /etc/vim/vimrc
  5. Remove myscript.vim from /etc/vim
  6. Create a ~/.vimrc and add the line source ~/.vim/myscript.vim
  7. Put my script in it
  8. Works like a charm

Expected behaviour

Here is the code

let s:comMapNoShebang = {
            \ 'c': {'b': '/*', 'm': '**', 'e': '*/'},
            \ 'cpp': {'b': '//', 'm': '//', 'e': '//'},
            \ 'make': {'b': '##', 'm': '##', 'e': '##'},
            \ 'java': {'b': '//', 'm': '//', 'e': '//'},
            \ 'latex': {'b': '%%', 'm': '%%', 'e': '%%'},
            \ 'html': {'b': '<!--', 'm': '  --', 'e': '-->'},
            \ 'lisp': {'b': ';;', 'm': ';;', 'e': ';;'},
            \ 'css': {'b': '/*', 'm': '**', 'e': '*/'},
            \ 'pov': {'b': '//', 'm': '//', 'e': '//'},
            \ 'pascal': {'b': '{ ', 'm': '   ', 'e': '}'},
            \ 'haskell': {'b': '{-', 'm': '-- ', 'e': '-}'},
            \ 'vim': {'b': '""', 'm': '"" ', 'e': '""'},
            \}

I do not understand why if the script is loaded by /etc/vim/vimrc it tells me:

Error detected while processing /etc/vim/epitech.vim:
line   35:
E15: Invalid expression: {
line   36:
E10: \ should be followed by /, ? or &
line   37:
E10: \ should be followed by /, ? or &
line   38:
E10: \ should be followed by /, ? or &
line   39:
E10: \ should be followed by /, ? or &
line   40:
E10: \ should be followed by /, ? or &
line   41:
E10: \ should be followed by /, ? or &
line   42:
E10: \ should be followed by /, ? or &
line   43:
E10: \ should be followed by /, ? or &
line   44:
E10: \ should be followed by /, ? or &
line   45:
E10: \ should be followed by /, ? or &
line   46:
E10: \ should be followed by /, ? or &
line   47:
E10: \ should be followed by /, ? or &
line   48:
E10: \ should be followed by /, ? or &
line   50:
E15: Invalid expression: {
line   51:
E10: \ should be followed by /, ? or &
line   52:
E10: \ should be followed by /, ? or &
line   53:
E10: \ should be followed by /, ? or &
line   54:
E10: \ should be followed by /, ? or &
line   55:
E10: \ should be followed by /, ? or &
line   56:
E10: \ should be followed by /, ? or &
line   57:
E10: \ should be followed by /, ? or &
line   58:
E10: \ should be followed by /, ? or &
line   59:
E10: \ should be followed by /, ? or &
Press ENTER or type command to continue

But works like a charm in .vimrc

I actually need this script for system wide installation

Version of Vim

VIM - Vi IMproved 8.1 (2018 May 18, compiled Apr 15 2020 06:40:31) Included patches: 1-2269 Modified by team...@tracker.debian.org Compiled by team...@tracker.debian.org

Environment

Operating System: Ubuntu20.04 LTS
Terminal: Default Gnome Terminal

Logs and stack traces

No response


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/11475@github.com>

Yegappan Lakshmanan

unread,
Oct 31, 2022, 11:09:38 AM10/31/22
to vim...@googlegroups.com, reply+ACY5DGEKYFJTF3AJC2...@reply.github.com, vim/vim, Subscribed
Hi,

On Mon, Oct 31, 2022 at 5:35 AM Mattis DALLEAU <vim-dev...@256bit.org> wrote:

Steps to reproduce

  1. Add source /etc/vim/myscript.vim in /etc/vim/vimrc
  2. Put my script at /etc/vim/myscript.vim
  3. Tells me that the dictionary has invalid syntax (See Expected Behaviour)

This is caused by running Vim in Vi-compatible mode.  This is described under:

:help cpo-C
:help line-continuation

When the /etc/vim/myscript.vim file is sourced, Vim is still running in compatible mode.

  1. Remove the line in source /etc/vim/myscript.vim in /etc/vim/vimrc
  2. Remove myscript.vim from /etc/vim
  3. Create a ~/.vimrc and add the line source ~/.vim/myscript.vim

When the .vimrc file is present, Vim starts in non-compatible mode.  So sourcing
your script from the .vimrc file doesn't cause any problems.

- Yegappan

vim-dev ML

unread,
Oct 31, 2022, 11:09:55 AM10/31/22
to vim/vim, vim-dev ML, Your activity

Hi,

On Mon, Oct 31, 2022 at 5:35 AM Mattis DALLEAU ***@***.***>
wrote:

> Steps to reproduce
>
> 1. Add source /etc/vim/myscript.vim in /etc/vim/vimrc
> 2. Put my script at /etc/vim/myscript.vim
> 3. Tells me that the dictionary has invalid syntax (See Expected
> Behaviour)
>
>

This is caused by running Vim in Vi-compatible mode. This is described
under:

:help cpo-C
:help line-continuation

When the /etc/vim/myscript.vim file is sourced, Vim is still running in
compatible mode.


> 1. Remove the line in source /etc/vim/myscript.vim in /etc/vim/vimrc
> 2. Remove myscript.vim from /etc/vim
> 3. Create a ~/.vimrc and add the line source ~/.vim/myscript.vim

>
>
When the .vimrc file is present, Vim starts in non-compatible mode. So
sourcing
your script from the .vimrc file doesn't cause any problems.

- Yegappan


>
> 1. Put my script in it
> 2. Works like a charm
> Included patches: 1-2269 Modified by ***@***.*** Compiled
> by ***@***.***

> Environment
>
> Operating System: Ubuntu20.04 LTS
> Terminal: Default Gnome Terminal
> Logs and stack traces
>
> *No response*
>
>
>


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/11475/1297235027@github.com>

Christian Brabandt

unread,
Nov 2, 2022, 2:01:24 PM11/2/22
to vim/vim, vim-dev ML, Comment

Closed #11475 as completed.


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/issue/11475/issue_event/7725974391@github.com>

Christian Brabandt

unread,
Nov 2, 2022, 2:01:25 PM11/2/22
to vim/vim, vim-dev ML, Comment

closing then.


Reply to this email directly, view it on GitHub.

You are receiving this because you commented.Message ID: <vim/vim/issues/11475/1301023117@github.com>

Reply all
Reply to author
Forward
0 new messages