First I will describe what I am trying to achieve:
In general I use
set iskeyword+=- as I see this more usable (one should always put spaces around operators when needed). This is quite helpful, but has one significant disadvantage - it also causes
i_^w to behave not as expected. So I am trying to write function that would reset
'iskeyword' to default value, modify it a little and then fire the same functionality as
i_^w, however I cannot find how to handle "deletion" part.
func! smart#delete_word() abort let l:iskeyword = &iskeyword try set iskeyword&vim set iskeyword-=_ if col('.') == col('$') - 1 normal! dvb else normal! db end finally let &iskeyword = l:iskeyword endtry endfunc
dvb trick isn't always working as expected and sometimes there are some leftovers at the end of the line or some additional characters are deleted.
So question is, how to achieve the same behaviour as
i_^w in function (worth mentioning that
i_^w itself will be remapped to this function, so it wouldn't be a solution to just