0

Suppose that i am editing a line such as below(just a bash command),my cursor is locating at the monitor's m:

1.How can quickly move cursor at the alsa's a?

ffmpeg -f pulse -i  alsa_output.pci-0000_09_00.6.analog-stereo.monitor  music.mp3

2.How can quickly copy the string alsa_output.pci-0000_09_00.6.analog-stereo.monitor?
A word is a string which begins with a space and end with a space.How can?
If i can define such string alsa_output.pci-0000_09_00.6.analog-stereo.monitor as a word, press b and yiw can do the trick.

1 Answer 1

1

The iskeyword setting controls which charters are part of a "word"; you can add the . and - to it (isk being the abbreviated form):

:setl isk+=- isk+=.

And then b will go back to the "word" as you want.

This affects many things though, including things like expand('<cword>') that may be used by plugin, syntax highlighting for some filetypes, commands like *, and many more. Personally I found setting iskeyword more trouble than it's worth in almost all cases, also because having commands behave different in different filetypes is confusing.


Instead, I would use F<Space> or T<Space> in your example, F ("find") will find a character backwards, moving to it, and T ("'till") will do the same, but puts the cursor one character before it. f and t do the same, but search forward. T is clearly the better choice here.

To copy that entire string, you can use T<Space>yt<Space>.

2
  • 1
    This is also a WORD, so B or yiW should do
    – D. Ben Knoble
    Oct 16, 2022 at 20:07
  • I had completely forgotten about those commands @D.BenKnoble! That's indeed much better. I should use those commands more. Oct 17, 2022 at 4:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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