vimtex:force}和{不要跳过空行

问题描述 投票:1回答:2

当我使用}{时,vimtex + vim在文档中稍微随机跳转,跳过几个空行。见下文。

如何恢复默认的vim行为不要跳过空行?

enter image description here

vim latex keyboard-shortcuts vim-plugin
2个回答
1
投票

简短的回答

跳过非常随机的事实表明空行不是真的空。它们包含空格或其他特殊字符。

将光标移动到这些“空”行,然后按$查看它们是否真的是空的。


如何避免这样的问题:

(是的,其他人也有你的问题。)

让vim显示空白字符 Vim有办法展示这些角色。使用set list并定义listchars。从list for vim的帮助:

    Strings to use in 'list' mode and for the :list command.  It is a
    comma separated list of string settings. 
    [...]
                                                    lcs-space
      space:c       Character to show for a space.  When omitted, spaces
                    are left blank.
                                                    lcs-trail
      trail:c       Character to show for trailing spaces.  When omitted,
                    trailing spaces are blank.  Overrides the "space"
                    setting for trailing spaces.

有关更多信息,请参阅:help :list:help listchars


突出显示尾随空格 我发现总是为任何空间显示一个角色非常烦人,我的眼睛太糟糕了,看不到一条线的末端有一个小点(对于尾随空格)。因此,我使用突出显示组来显示所有尾随空白字符:

" Show trailing whitespace
    highlight ExtraWhitespace ctermbg=red       " define highlight group                      
    match ExtraWhitespace /\s\+$/               " define pattern
    autocmd BufWinEnter * match ExtraWhitespace /\s\+$/         " apply match to all buffers
    autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/  " don't match while in insert 
    autocmd InsertLeave * match ExtraWhitespace /\s\+$/
    autocmd BufWinLeave * call clearmatches()                   " It's good for the RAM

自动删除尾随空格 还有一种方法可以在编写缓冲区时自动删除这些字符 - 但是有一些注意事项(想想markdown用于换行符的双尾部空格)。

Vim wiki有一个很好的解释。

最简单(但可能不是最好的)解决方案是添加

 autocmd BufWritePre * %s/\s\+$//e

到你的.vimrc或相应的ftplugin文件。我个人在我的vimrc中有一个功能,并禁用它的文件类型,我不想要/不需要它。


您可能也对Make { and } ignore lines containing only whitespace感兴趣


放弃 可能存在不是空格的字符,但默认情况下也不会被vim显示。我从来没有遇到过这个问题,但我在“简答”中所说的内容仍然适用。


2
投票

查找是否有使用}的映射

:map }

现在,您可以取消映射您找到的任何映射

:unmap }

如果你想把它放在你的.vimrc中,我建议你在该插件的after目录下进行。

~/.vim/after/plugin

© www.soinside.com 2019 - 2024. All rights reserved.