Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VIM Autocomplete - Use $ as the word separator

Let's say I have following typed in my source file.

var myFunction = function() { };

var anotherFunction = function() { };

var test-m

I can now press Ctrl + P and it will show 'myFunction' in the autocomplete list. It's great and very helpful.

But what I want to do is make VIM treat '$' in the same way it treats '-'.

So when I type

var myFunction = function Module$m  

and press Ctrl+P and it will show myFunction in autocomplete.

I have looked at this question and tried setting $ as keyword using iskeyword command but it didn't help.

And I know it's possible to do this as I used to have it working before and then I messed up my VIMRC and I am not able to get it work anymore. :(

Your help is appreciated, thanks!

like image 267
SolutionYogi Avatar asked Dec 17 '22 04:12

SolutionYogi


1 Answers

To make vim use a dollar-sign as a word separator, do:

:set iskeyword-=\$

If wanting the opposite: (to autocomplete words containing a dollar sign, add a literal dollar sign to the current autocomplete match pattern, by doing the opposite:

:set iskeyword+=\$

To find your current iskeyword setting, do:

:set iskeyword?

This will show you a list of ASCII ranges vim considers a single word. Mine looks like:

iskeyword=@,48-57,_,192-255
like image 144
zen Avatar answered Dec 27 '22 05:12

zen