gpt4 book ai didi

vim - 为什么这个 vimrc 命令对我不起作用?我正在尝试突出显示超过 80 个字符的长行

转载 作者:行者123 更新时间:2023-12-04 05:27:14 27 4
gpt4 key购买 nike

所以我在 StackOverflow 上找到了这个解决方案:Vim 80 column layout concerns

如果我在文件中输入长行,我希望突出显示超过 80 个字符限制的字符。很多人似乎认为这个解决方案工作正常,但我在我的 vimrc 文件中有它,它的行为好像没有任何改变。我的长线没有突出显示。

highlight OverLength ctermbg=red ctermfg=white guibg=#592929
match OverLength /\%81v.\+/

供引用,这是我的整个 .vimrc ,这不是那么长:
" You'll need to add the following to your ~/.vimrc so that pathogen will be loaded
" properly. Filetype detection must be off when you run the commands so its best to
" You'll need to add the following to your ~/.vimrc so that pathogen will be loaded
" execute them first:
"filetype off
call pathogen#runtime_append_all_bundles()
call pathogen#helptags()
"filetype on

syntax on

let mapleader = ","
let g:CommandTMaxHeight=25
imap ii <Esc>

map <S-Enter> O<Esc>
map <CR> o<Esc>

set guioptions-=T
set guioptions-=r

set hlsearch
highlight OverLength ctermbg=red ctermfg=white guibg=#592929
match OverLength /\%79v.\+/
set nocompatible
set ruler
set number
set shellcmdflag=-ic
set list
set expandtab
set tabstop=4
set softtabstop=4
nmap <C-k> ddkP
nmap <C-j> ddp
vmap <C-k> xkP`[V`]
vmap <C-j> xp`[V`]

au! BufWritePost vimrc source %
colorscheme vividchalk

最佳答案

发件人:https://stackoverflow.com/a/10993757/1701170

augroup vimrc_autocmds
autocmd BufEnter * highlight OverLength ctermbg=darkgrey guibg=#111111
autocmd BufEnter * match OverLength /\%75v.*/
augroup END

这对我有用,而我以前的解决方案则不然。我不确定为什么,但页面上的另一位评论者在评论时提供了一个提示,关于无需打开和关闭的解决方案 augroup行,“这仅适用于您在任何给定缓冲区中打开的第一个文件”。

现在,如果有人能解释为什么额外的开始和结束行可以解决任何给定缓冲区中的第一个文件问题,以及为什么首先存在该问题,那么我会感到开明。

关于vim - 为什么这个 vimrc 命令对我不起作用?我正在尝试突出显示超过 80 个字符的长行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13058548/

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