gpt4 book ai didi

vim - vim中如何一键切换语法开关

转载 作者:行者123 更新时间:2023-12-02 15:17:05 37 4
gpt4 key购买 nike

如何在命令模式和/或插入模式下随时使用一键(例如<F5>)在vim 中打开和关闭语法高亮显示?

最佳答案

来自 help g:syntax_on :

You can toggle the syntax on/off with this command:

   :if exists("g:syntax_on") | syntax off | else | syntax enable | endif

To put this into a mapping, you can use:

   :map <F7> :if exists("g:syntax_on") <Bar>              
\ syntax off <Bar>
\ else <Bar>
\ syntax enable <Bar>
\ endif <CR>

[using the <> notation, type this literally]

要在插入模式下获取它,我认为最简单的方法就是这样做

imap <F7> <C-o>F7

在我的 .vimrc 中我有相同的,但是有 nnoremap<silent> :

nnoremap <silent> <Leader>ts
\ : if exists("syntax_on") <BAR>
\ syntax off <BAR>
\ else <BAR>
\ syntax enable <BAR>
\ endif<CR>

关于vim - vim中如何一键切换语法开关,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39645894/

37 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com