9

When I write a German text containing something like abücd for instance and to a dw in front, it will only delete the ab since it does not interpret ü as a word character.

When I edit reStructuredText, I have

iskeyword=38,42,43,45,47-58,60-62,64-90,97-122,_

That explains why the umlauts are not marked, but I do not understand where this comes from. When I just open gVim this is set to

iskeyword=@,48-57,_,192-255

Where could this be coming from?

Martin Ueding
  • 305
  • 1
  • 7
  • 3
    Put set encoding=utf-8 in your .vimrc. – cuonglm Nov 06 '15 at 18:08
  • That is already in my .vim/vimrc and :set enc? gives me utf-8. Same with fenc. Still it does not work. – Martin Ueding Nov 06 '15 at 21:06
  • After :set iskeyword& is ü still not recognized as a part of a word? – ryuichiro Nov 07 '15 at 01:04
  • Show as your iskeyword (set iskeyword). It should be something like "@,48-57,_,128-167,224-235"or "@,48-57,_,192-255". Are you using Vim or Vi ? (the default value in Vi ("@,48-57,_") does not recognize ü; the default value in Vim is fine) – JJoao Nov 07 '15 at 13:37
  • 1
    I use gVim and have iskeyword=@,48-57,_,192-255. It magically works in a fresh Vim instance now. That is strange, I have to observe that more carefully. – Martin Ueding Nov 07 '15 at 15:40
  • When editing certain documents this happens. I updated the question. – Martin Ueding Nov 08 '15 at 08:26
  • When you type :verb set isk, does it tell you from where the option was set ? – saginaw Nov 08 '15 at 08:56

2 Answers2

5

The @ character in iskeyword includes all characters for which isalpha() (C function) is TRUE; in modern (last 20 years) libc implementations this also looks for unicode characters.

Your second iskeyword uses 97-122 (a-z) and 64-90 (A-Z), which doesn't include all the variants with the various diacritics (such as the umlaut/diaeresis/trema).

So the solution is to replace 97-122 and 64-90 with @.

This funky iskeyword comes from the LISP syntax file; the rst syntax file includes a bunch of other syntax files for highlighting the code blocks.

Luckily you can set which languages to include with the g:rst_syntax_code_list variable. The default is:

let g:rst_syntax_code_list = ['vim', 'java', 'cpp', 'lisp', 'php', 'python', 'perl']

Since it's unlikely that you need LISP syntax highlighting in your reStructuredText file, you can probably just remove it. Just add it anywhere in your vimrc file, if it's defined, the syntax file will use that value instead of defining its own.

In my opinion, you probably want to use:

let g:rst_syntax_code_list = []

Because who knows what funky side-effects the other syntax files cause...

Martin Tournoij
  • 62,054
  • 25
  • 192
  • 271
1

If one inlines grammars from other languages in for example markdown files, then the settings of those languages seem to override the settings for markdown syntax. One can check if that is the case using:

:verbose set iskeyword?

In order to fix this, one can define an auto command to be run each time one enters a markdown file (and probably other languages as well):

autocmd BufEnter,BufNewFile *.md set iskeyword=38,42,43,45,47-58,60-62,_,@

Putting this in my .vimrc fixed the issue for me. I was using vim-pandoc syntax and inlined languages including racket, python, sh and some. I think it is not necessary to define an auto command for leaving markdown files, because when you enter files of other languages, their syntax files should set their keywords, if I understand correctly.