Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there anyway to have vim not count special characters as words?

Tags:

vim

macros

I'm using VIM do alot of work for me using the macros.

There's alot of text in columns and I want the macro to move between columns effortlessly by pressing the w key to "move to the beginning of the next word"

For example:

DataSourceName            string                       ""   
DetailFields              []string                          
DynamicControlBorder      boolean                 empty  may be void 
EscapeProcessing          boolean                    True   
FetchDirection            long                       1000   
FetchSize                 long                         12   
Filter                    string                       ""   
GroupBy                   string                       ""   
HavingClause              string                       ""

However when I do this, VIM only does this for letters; whenever it encounters a "[" or a " it interprets this as another word, messing up the macro because it now appears that there is an additional column.

Is there any setting I can change to make vim ignore the special characters and treat them just like the letters by skipping over them?

[Update]

I found an even better answer to this question over at superuser.com:

https://superuser.com/questions/12679/is-there-anyway-to-have-vim-not-count-special-characters-as-words/12828#12828

like image 517
leeand00 Avatar asked Jul 25 '09 12:07

leeand00


Video Answer


2 Answers

You could make the special characters a part of word, see the iskeyword option. In your case you could simply try the following commands:

:set iskeyword+=[
:set iskeyword+=]
like image 108
zoul Avatar answered Sep 28 '22 15:09

zoul


The W command (Shift+W) moves to the next word delimited only by spaces, not whatever Vim is configured to consider a "word" (as unshifted w does).

like image 29
Greg Hewgill Avatar answered Sep 28 '22 16:09

Greg Hewgill