0

Like this for Vim, I'm trying to convert (with no success):

matchadd('ColorColumn', '\%81v\s*\zs\S', 100)

from vimscript to a Lua autocmd:

autocmd({'BufRead'}, {
    pattern = "*",
    callback = function ()
       vim.fn.matchadd('ColorColumn', '\\%81v\\s*\\zs\\S')
    end
})

What am I doing wrong?

2
  • Have you tried the colorcolumn option?
    – D. Ben Knoble
    Commented Mar 11, 2023 at 14:08
  • @D.BenKnoble sure! wo.colorcolumn = "80" but show column always not only on characters >=81. This autocmd should replace the behavior
    – Joannes
    Commented Mar 11, 2023 at 14:29

1 Answer 1

0

Have you tried:

autocmd({'BufRead'}, {
    pattern = "*",
    callback = function ()
       vim.fn.matchadd('ColorColumn', '\\%81v\\s*\\zs\\S', 100)
    end
})

Optional verify that the ColorColumn is defined:

vim.api.nvim_set_hl(0, "CursorColumn", { ctermbg = 0 })
2
  • 1
    Thanks, at the end 100 is missing
    – Joannes
    Commented Mar 12, 2023 at 12:40
  • 1
    Thanks for the feedback :-) Commented Mar 12, 2023 at 15:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.