I would like to know how to use vim modelines in a Markdown document. Is it possible, or does modelines only recognise certain comment markers?
I have tried using this as the first line of my file:
<!-- vim: set ft=markdown -->
I also tried all these suggestions here with no luck.
Add the following statement to ~/.vimrc to set filetype=markdown for all .md files. This statement says that when starting to edit a new file that doesn't exist or when starting to edit a new buffer, after reading the file into the buffer, if the file matches the pattern *.md then set filetype=markdown.
With " set ", the modeline ends at the first colon not following a backslash. Without " set ", no text can follow the options, so for example, the following is invalid: With the following in your vimrc and the default leader key, you could type \ml to add a modeline based on your current settings: " Append modeline after last line in buffer.
With 'set', the modeline ends at the first colon not following a backslash. And without 'set', no text can follow the options. For example, /* vim: noai:ts=4:sw=4 */ is an invalid modeline. Sadly, Vim's Modeline feature can be used to compromise security.
To enable the feature, open the .vimrc file (located in your home directory), and then add the following line to it: Now, whenever you enter a tab and save the file (where the expandtab modeline command was entered), the tab will automatically convert into white spaces. Let's consider another use-case.
Your modeline syntax is off. Add a colon at the end, and it will work:
<!-- vim: set ft=markdown: -->
Modeline doesn't care about comment markers. There are two different modeline formats:
[text]{white}{vi:|vim:|ex:}[white]{options}
This form does not use the keyword set
, does not require a final colon, and most importantly, does not allow random text after options (such as -->
). This means, any paired comment markers must necessarily use the second form:
[text]{white}{vi:|vim:|Vim:|ex:}[white]se[t] {options}:[text]
This form requires the use of set
keyword, requires terminating options with a colon (:
), and allows the terminating colon to be followed by random text.
I apply some markdown related settings according to the autocmd + filetype.
In my vimrc
I have:
if has("autocmd")
autocmd FileType markdown vmap <Leader><Bslash> :EasyAlign*<Bar><Enter>
endif
Not sure that it's the most traditional way.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With