Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding a hook to Vim's default buffer

Tags:

vim

I want to configure Vim such that when the [No Name] buffer is open, the syntax is set to markdown. Is this possible? I couldn't see such kind of hook in Vim's help.

I'm using Vim 7.3, compiled with --with-features=huge.


1 Answers

This is mentioned on the vim tips wiki:

" default filetype
let g:do_filetype = 0
au GUIEnter,BufAdd * if expand('<afile>') == "" | let g:do_filetype = 1 | endif
au BufEnter * if g:do_filetype | setf markdown | let g:do_filetype = 0 | endif

Why the need to use a global variable, and not set the filetype immediately, is to my understanding, because the buffer hasn't been fully created when the autocmd is triggered.

like image 151
Eevee Avatar answered Dec 24 '25 04:12

Eevee



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!