David I McCooey wrote:
Hi all,

When editing a file that has #!/bin/bash on the first line,
indicating a bash shell script, vim appears to recognize
a different set of word-delimiter characters for the purposes
of operations like 'cw' (change word) or '*' (search for word).

For example, the period (.) is not recognized as a delimiter:
If the cursor is on the 'x' character in a sequence like
"xyz.cpp", and you type 'cw', then all 7 letters will be changed
instead of just the "xyz" part.

This is probably intentional behavior, but is there any way
to disable it, so that vim has a consistent set of word delimiter
rules regardless of the file type that is being edited?

-Dave


It is intentional, because what is "a word" varies from one programming language to another. In bash (IIUC) the dot is just any filename character. In Vim script it is a string operator. In C it is (IIUC) a structure operator. In COBOL it is a punctuation mark (end-of-sentence or end-of-declaration). And so on.

You can use cW to use WORDS delimited by spaces, tabs or linebreaks (and nothing else), but I guess that isn't what you want.

You can also write an after-plugin (see ":help after-directory") to be sourced "after" the concerned ftplugin, for instance:

--- start ~/.vim/after/ftplugin/sh.vim (for Unix)
setlocal iskeyword-=.
--- end ~/.vim/after/ftplugin/sh.vim

Whatever you write into ~/.vim/after/ftplugin/sh.vim will be sourced after $VIMRUNTIME/ftplugin/sh.vim, and on the same files, at the FileType event.


Best regards,
Tony.

Reply via email to