Does anyone know a quick shortcut I can use to replace a word in a series of words connected with underscores?
Given:
Create_in_one_of_these_words
I want to make, where |
is cursor:
Create_in_|_of_thse_words
Vi and Vim Stack Exchange is a question and answer site for people using the vi and Vim families of text editors. It only takes a minute to sign up.
Sign up to join this communityDoes anyone know a quick shortcut I can use to replace a word in a series of words connected with underscores?
Given:
Create_in_one_of_these_words
I want to make, where |
is cursor:
Create_in_|_of_thse_words
If you are anywhere on that line, you can try this:
/one
- to jump to the word one
(in this particular case even fo would be enough - see :help f
)t
- so in this case everything till _
- and since we used c it will leave you in insert mode - see :help t
set iskeyword-=_
has side effects (see for example How do I change until the next underscore in Vim?. There are more plugins to help you out camelcasemotion and vim-wordmotion. However, I recommend to use the general way given here.
– Hotschke
Aug 17 '18 at 10:25
Another alternative is to use vim-textobj-variable-segment which along with vim-textobj-user, will allow you to edit segments in snakecase and camelcase words. It provides iv
and av
text objects. This would allow you to do fociv
to change you one
in your example.