1

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
3

If you are anywhere on that line, you can try this:

  • 0 - to go to the beginign of line
  • /one - to jump to the word one (in this particular case even fo would be enough - see :help f)
  • ct_ - this will delete everything between cursor and character pressed after t - so in this case everything till _ - and since we used c it will leave you in insert mode - see :help t
2

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.