1

I've read the help section for term, terminal, termopen, buftype, and I've read several stack questions, but I haven't been able to find a solution for settings options in terminal mode. I know about tnoremap, what I want to do is set options, not remap keys.

I tried:

" Terminal Buffer
function! TerminalSettings()
    set nonumber
    set mouse=
    set list
endfunction
augroup terminal
    autocmd!
    autocmd TermOpen call TerminalSettings()
augroup END

But this had no effect (as far as I could tell). Is this the correct approach incorrectly implemented, or do I need to do something else?

Update

I tried opening Vim with the config, and it gave me an error:

E216: No such group or event: TermOpen call TerminalSettings()

Which leads me to believe that NeoVim at least has this event, since it opens without any errors.

I also tried using setlocal instead of set, but no change.

Setting the option manually works :setlocal nonumber.

1
  • 1
    You may need setlocal. FWIW in regular vim even with set number, when I run :terminal there are never line numbers.
    – D. Ben Knoble
    Jan 20 at 14:52

1 Answer 1

0

Found the problem. The approach was correct, it was just a syntax issue: autocmd TermOpen * call TerminalSettings(). I was missing the asterisk.

My current config is now:

" Terminal Buffer
function! TerminalSettings()
    setlocal nonumber
    normal a
endfunction
augroup terminal
    autocmd!
    autocmd TermOpen * call TerminalSettings()
augroup END

FYI what helped me find it was the Vim documentation 40.3 example :autocmd FileWritePre * call DateInsert() and explanation :autocmd [group] {events} {file_pattern} [nested] {command}. I was confused by the :help autocmd section which said {pat} instead of {file_pattern}.

1
  • 1
    {pat} instead of {file_pattern} All events are different. Most of them pass {file_pattern} (actually, a buffer name), but there are several exceptions.
    – Matt
    Jan 21 at 11:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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