Skip to content

E121: Undefined variable: b:undo_ftplugin #579

Closed
@willxy

Description

@willxy

After e6a4f2f, where it does:

let b:undo_ftplugin .= ' | setlocal iskeyword< suffixesadd<'

I'm getting:

Error detected while processing /home/will/.vim/plugged/vim-javascript/after/
ftplugin/javascript.vim:
line   11:
E121: Undefined variable: b:undo_ftplugin
E121: Undefined variable: b:undo_ftplugin
E121: Undefined variable: b:undo_ftplugin

Searching around, it looks some solutions (jalvesaq/Nvim-R#9) can be:

if exists("b:undo_ftplugin")
        let b:undo_ftplugin .= ' | setlocal iskeyword< suffixesadd<'
else
        let b:undo_ftplugin = 'setlocal iskeyword< suffixesadd<'
endif

Or to avoid code duplication, maybe just initializing before appending to it:

if !exists("b:undo_ftplugin") | let b:undo_ftplugin = '#!' | endif
let b:undo_ftplugin .= ' | setlocal iskeyword< suffixesadd<'

The '#!' was the best I could find as a no-op (second best was 'silent echo'). It looked like an empty string ('') doesn't work as a noop; that produces error E749: empty buffer.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions