从vim中的'iskeyword'中删除一个字符 [英] Removing a character from 'iskeyword' in vim

查看:48
本文介绍了从vim中的'iskeyword'中删除一个字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的 vimrc 中,我包含了一个脚本(比如 otherscript.vim,出于工作原因我需要包含它)说:

In my vimrc, I have included a script (say, otherscript.vim, which I need to include for work reasons) that says:

autocmd FileType php setlocal iskeyword+=$

我不想要这种行为.所以,稍后在 vimrc 中,我说:

and I don't want this behaviour. So, sometime later in the vimrc, I say:

autocmd FileType php setlocal iskeyword-=$

(我也尝试使用 set 而不是 setlocal.)但是,当我打开一个 php 文件时,iskeyword 中仍然包含 $ 符号.我正在使用 vim 7.2.':verbose set iskeyword' 的输出是

(I also tried using set instead of setlocal.) But, when I open a php file, iskeyword still contains the $ symbol in it. I am using vim 7.2. The output of ':verbose set iskeyword' is

iskeyword=@,48-57,_,192-255,$
    Last set from /path/to/otherscript.vim

':scriptnames' 的输出是:

The output of ':scriptnames' is:

...
7: /usr/share/vim/vim72/ftplugin.vim
8: /home/yogeshwer/.vimrc
...
74: /path/to/otherscript.vim
... 

有人可以帮助我如何恢复其他脚本对iskeyword"所做的更改?谢谢一堆.

Can somebody help me how I can revert the changes to 'iskeyword' made by the other script? Thanks a bunch.

推荐答案

我喜欢尽可能避免使用 autocmd,并使用 after 目录结构.

I like to avoid autocmds when I can and use the after directory structure.

$ mkdir -p ~/.vim/after/{ftplugin,syntax,indent}
$ echo 'setlocal iskeyword-=$' >> ~/.vim/after/ftplugin/php.vim

这会在用户特定的 vim 配置文件夹中设置一个基本的 after 目录.而 ~/.vim/ftplugin/$FILETYPE.vim 将用于代替 vim 的标准 $FILETYPE.vim 文件,after 目录中的文件在之后执行,允许您可以覆盖或更改 ftplugins、语法定义和缩进命令的行为.

This sets up a basic after directory in your user-specific vim config folder. Whereas ~/.vim/ftplugin/$FILETYPE.vim would be used in lieu of vim's standard $FILETYPE.vim file, files in an after directory get executed after, allowing you to override or change the behavior of your ftplugins, syntax definitions, and indent commands.

作为向您展示这些工作原理的附加示例,我将在此处包含本地 after/syntax/python.vim 文件的一部分.我喜欢我的代码的所有结构性标点符号"在我阅读时脱颖而出,所以我这样做:

As an additional example to show you how these work, I'll include part of my local after/syntax/python.vim file here. I like all the "structural punctuation" of my code to stand out when I read it, so I do this:

syn match pythonParen /[()]/
syn match pythonBrack /[][]/
syn match pythonCurly /[{}]/
hi def link pythonParen Paren
hi def link pythonBrack Brack
hi def link pythonCurly Curly

我还有一个 after/indent/php.vim 文件,它应该可以解决我在切换 <?php ?> 模板文件中的区域,但代码一团糟,一开始就没有真正起作用,所以我不会在这里复制它.我提到它只是为了给你一个例子,说明可以用 after 钩子做什么.

I've also got an after/indent/php.vim file that was supposed to fix some of the annoying indent issues I ran into with the indent behavior when switching in and out of <?php ?> regions in a template file, but the code is a mess and never really worked in the first place, so I won't reproduce it here. I mention it only to give you an example of what can be done with the after hooks.

这篇关于从vim中的'iskeyword'中删除一个字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆