简体   繁体   English

¬ 在 vi​​m 中每一行的末尾

[英]¬ at the end of each line in vim

this might be a silly question, but I couldn't find an answer to it.这可能是一个愚蠢的问题,但我找不到答案。 So, how can I add a ¬ to the end of each line of my vim files?那么,如何在 vim 文件的每一行末尾添加一个 ¬ 呢? It's more about styling, avoid trailing spaces, etc, like this colorscheme:http://ethanschoonover.com/solarized/img/solarized-dualmode.png更多的是关于样式,避免尾随空格等,就像这个颜色方案:http ://ethanschoonover.com/solarized/img/solarized-dualmode.png

Thanks in advance.提前致谢。

set list
set listchars+=eol:¬

See :help 'list' and :help 'listchars' .请参阅:help 'list':help 'listchars'

If you type in:如果您输入:

:set list

then vi should show you the end of each line with a $ character.然后 vi 应该用$字符显示每行的结尾。 Assuming all you want is to capture trailing space, that will do the trick.假设您想要的只是捕获尾随空间,那就可以了。 You can then turn it off with:然后你可以关闭它:

:set nolist

It actually gives you other things like making tabs visible as well, very handy when trying to track down Python problems with indentation, or things that print differently due to different tab width settings.它实际上为您提供了其他功能,例如使选项卡可见,在尝试跟踪 Python 缩进问题或由于选项卡宽度设置不同而打印不同的内容时非常方便。

Of course, if you're looking to remove white space at line end, you can use regular expressions in your substitute commands:当然,如果您想删除行尾的空格,您可以在替换命令中使用正则表达式:

:g/  *$/s///g
:set list listchars+=eol:¬

或者,如果您只是对查看尾随空格感兴趣,可以使用:

:set list listchars+=trail:∙

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM