[vim/vim] make c syntax indedpendent of `iskeyword` (Issue #21173)

14 views
Skip to first unread message

Maxim Kim

unread,
Aug 27, 2026, 7:46:35 PM (2 days ago) Aug 27
to vim/vim, Subscribed
habamax created an issue (vim/vim#21173)

I would like to change iskeyword in my configuration to exclude _, so that it would be possible to navigate/change words in long_functions_or_variables_separated_like_this. However this breaks c syntax highlighting.

Use syn iskeyword instead of relying on iskeyword option, e.g.:

diff --git a/runtime/ftplugin/c.vim b/runtime/ftplugin/c.vim
index 97111121c..06142bb58 100644
--- a/runtime/ftplugin/c.vim
+++ b/runtime/ftplugin/c.vim
@@ -1,7 +1,7 @@
 " Vim filetype plugin file
 " Language:	C
 " Maintainer:	The Vim Project <https://github.com/vim/vim>
-" Last Change:	2026 Feb 3
+" Last Change:	2026 Aug 28
 " Former Maintainer:	Bram Moolenaar <Br...@vim.org>
 
 " Only do this when not done yet for this buffer
@@ -35,11 +35,6 @@ endif
 " Also include ///, used for Doxygen.
 setlocal comments=sO:*\ -,mO:*\ \ ,exO:*/,s1:/*,mb:*,ex:*/,:///,://
 
-" In VMS C keywords contain '$' characters.
-if has("vms")
-  setlocal iskeyword+=$
-endif
-
 " Use terminal window for gui
 if has('gui_running') && exists(':terminal') == 2 && executable("man")
   setlocal keywordprg=:CKeywordPrg
diff --git a/runtime/syntax/c.vim b/runtime/syntax/c.vim
index 9b18c2b8a..23f8f1b17 100644
--- a/runtime/syntax/c.vim
+++ b/runtime/syntax/c.vim
@@ -1,7 +1,7 @@
 " Vim syntax file
 " Language:		C
 " Maintainer:		The Vim Project <https://github.com/vim/vim>
-" Last Change:		2026 Jul 25
+" Last Change:		2026 Aug 28
 " Former Maintainer:	Bram Moolenaar <Br...@vim.org>
 
 " Quit when a (custom) syntax file was already loaded
@@ -25,6 +25,13 @@ if exists("c_autodoc")
   unlet b:current_syntax
 endif
 
+" In VMS C keywords contain '$' characters.
+if has("vms")
+    syn iskeyword @,48-57,_,192-255,$
+else
+    syn iskeyword @,48-57,_,192-255
+endif
+
 " A bunch of useful C keywords
 syn keyword	cStatement	goto break return continue asm
 syn keyword	cLabel		case default


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/21173@github.com>

h_east

unread,
Aug 28, 2026, 12:28:02 AM (yesterday) Aug 28
to vim/vim, Subscribed
h-east left a comment (vim/vim#21173)

I don't think modifying 'iskeyword' for that purpose makes sense.
Please use f_, t_, ;, etc. instead.


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/21173/5448435579@github.com>

Maxim Kim

unread,
Aug 28, 2026, 12:32:05 AM (yesterday) Aug 28
to vim/vim, Subscribed
habamax left a comment (vim/vim#21173)

I don't think modifying 'iskeyword' for that purpose makes sense. Please use f_, t_, ;, etc. instead.

I use it, but still find using ciw for a_long_cursorishere_variable is way easier for me personally. The syn-iskeyword is exactly to make sure syntax is independent on what user may change within iskeyword option.


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/21173/5448459412@github.com>

h_east

unread,
Aug 28, 2026, 12:43:52 AM (yesterday) Aug 28
to vim/vim, Subscribed
h-east left a comment (vim/vim#21173)

What? I just provided those commands because you explicitly mentioned


"so that it would be possible to navigate/change words in long_functions_or_variables_separated_like_this."


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/21173/5448532023@github.com>

h_east

unread,
Aug 28, 2026, 1:14:05 AM (yesterday) Aug 28
to vim/vim, Subscribed
h-east left a comment (vim/vim#21173)

It doesn't make sense to exclude characters that the language recognizes as keywords from 'iskeyword'. I imagine that would lead to various undesirable side effects.
How about using a plugin?
A quick search turned up the following options that seem relevant (though I haven't actually tested them myself).

CamelCaseMotion
https://github.com/bkad/CamelCaseMotion
camelcasemotion
https://github.com/inkarkat/vim-camelcasemotion
vim-textobj-underscore
https://github.com/lucapette/vim-textobj-underscore
vim-textobj-variable-segment
https://github.com/Julian/vim-textobj-variable-segment
vim-wordmotion
https://github.com/chaoren/vim-wordmotion


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/21173/5448719216@github.com>

Maxim Kim

unread,
Aug 28, 2026, 2:59:36 AM (yesterday) Aug 28
to vim/vim, Subscribed
habamax left a comment (vim/vim#21173)

Let's ignore the fact I want to use iskeyword for my own usecases, isn't the usage of syn-keyword exactly to guard against accidental or not so accidental change of the iskeyword option? And it would probably good to have it in the syntax file?

If not, that is ok, I can workaround it.


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/21173/5449456993@github.com>

Maxim Kim

unread,
Aug 28, 2026, 3:02:24 AM (yesterday) Aug 28
to vim/vim, Subscribed
habamax left a comment (vim/vim#21173)

What? I just provided those commands because you explicitly mentioned "so that it would be possible to navigate/change words in long_functions_or_variables_separated_like_this."

I want the change and navigation to be smoother than T_ct_, for me ciw is way more convenient. And I do turn it on with iskeyword when I know there would be a lot of changes in a codebase with snake_case stuff.


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/21173/5449481296@github.com>

h_east

unread,
Aug 28, 2026, 3:08:19 AM (yesterday) Aug 28
to vim/vim, Subscribed
h-east left a comment (vim/vim#21173)

Please configure that yourself.
I do not think this is something that should be handled on the Vim side.


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/21173/5449531357@github.com>

Maxim Kim

unread,
Aug 28, 2026, 3:13:35 AM (yesterday) Aug 28
to vim/vim, Subscribed
habamax left a comment (vim/vim#21173)

ok, fair enough. I can override the c syntax locally.

However, if the change of the iskeyword so dangerous (plugins might not work as expected etc), shouldn't it be somehow explicitly discouraged to be set? Or even remove it as an option exposed to the user at all?


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/21173/5449574893@github.com>

dkearns

unread,
Aug 28, 2026, 7:32:07 AM (yesterday) Aug 28
to vim/vim, Subscribed
dkearns left a comment (vim/vim#21173)

I suspect you are talking past each other, so let me muddy the waters.

@habamax, if you were assuming that the 'iskeyword' modification for VMS in the ftplugin was primarily for use by the syntax file it seems that you'd be wrong in this instance (see section 8.13 in :help os_vms.txt).

While a lot of the syntax 'iskeyword' definitions were moved to their respective ftplugins under the somewhat lazy assumption that the syntax file users would always be running with :filetype plugin on that doesn't appear to be the case here.


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/21173/5451991682@github.com>

Maxim Kim

unread,
Aug 28, 2026, 7:42:28 AM (yesterday) Aug 28
to vim/vim, Subscribed
habamax left a comment (vim/vim#21173)

That is fine, Vms iskeyword needs to also stay in ftplugin to keep word movements. But anyway I have updated my overrides to include sun iskeyword locally.


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/21173/5452080814@github.com>

h_east

unread,
Aug 28, 2026, 9:03:05 AM (yesterday) Aug 28
to vim/vim, Subscribed
h-east left a comment (vim/vim#21173)

In other words, the content of the PR is correct, isn't it?


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/21173/5452824802@github.com>

dkearns

unread,
Aug 28, 2026, 9:40:45 AM (24 hours ago) Aug 28
to vim/vim, Subscribed
dkearns left a comment (vim/vim#21173)

Yes, I think your PR is correct. Thanks.


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/21173/5453221609@github.com>

Reply all
Reply to author
Forward
0 new messages