Sunday, June 23, 2024

Re: partial syntax in vim

On 2024-06-17, Andreas Otto <aotto1968zwei@gmail.com> wrote:
> Hi is it possible to change the syntax for a limit part of a file?

Yes. See :help syn-include and :help mysyntaxfile-add.

> example: tcl file with bash syntax used with "pseudo code" vim: push … vim:

I do not recommend using comments with `vim:` because they are
interpreted specially by Vim. Just use (for instance):

if {checkNotIgnore("DIFF")} {
File_Exec_BASH {
# syntax=bash
[...]
# pop syntax
} <@stdin >@stdout 2>@stderr
}

Create ~/.vim/after/syntax/tcl.vim with this content:

unlet b:current_syntax
syn include @Bash syntax/bash.vim
syn region tclBash matchgroup=Comment start=/^\s*# syntax=bash/ end=/^\s*# pop syntax/ contains=@Bash
let b:current_syntax = "tcl"

Hope this helps,
Life.

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/v598nh%2433u%241%40ciao.gmane.io.

No comments:

Post a Comment