Stephen Chu
Stephen Chu

Reputation: 373

Configure vim word boundary highlight for Bash function names

In vim, when I have a Bash function that ends with a Bash keyword, my vim highlighting starts highlighting it and assumes a new scope (if applicable):

values-for() {
  ...
}

       ^yellow "for" highlight
^syntax error highlight

But when I rename the "for" word to "for1" then those undesired highlights disappear.

How do I tell vim to ignore keywords like "for" when it is used as part of a function name?

Upvotes: 1

Views: 75

Answers (2)

Ingo Karkat
Ingo Karkat

Reputation: 172510

  • I cannot reproduce this with the $VIMRUNTIME/syntax/sh.vim script (that ships with Vim 8.0.1358), version 172 from Oct 02, 2017 (assuming a proper #!/bin/bash shebang, so that the syntax detects the Bash dialect).
  • On the maintainer's web site, there's an even newer update (version 174).
  • If you can still reproduce the problem with that version, please contact DrChip via email and report this bug.
  • Just to be clear, this is something that you cannot fix "in Vim"; it's a bug in the syntax definition itself, so that must be changed.

Upvotes: 1

phd
phd

Reputation: 94397

Word boundaries are \< and \>. So use \<for\>.

Upvotes: 0

Related Questions