Word movements

The extension was created after discussing with @occivink about the controversial mappings and the word movements in general, and I would like to collect your feelings about the following interpretation of word movements.

asciicast

I made a clojure text-object plugin whose element selection works kind of like this, and I mapped w to it. It messes me up when I want to select whitespace at the beginning of a line when the cursor is in the whitespace, though, so I’m not completely happy with it. My current work-around is to use W, which works most of the time. I’m not sure how to resolve this.

The plugin is https://github.com/eraserhd/select-nrepl .

How about mapping e to "_/\s+<ret>?

map global normal e '"_/\s+<ret>'
map global normal E '"_?\s+<ret>'
map global normal <a-e> '"_<a-/>\s+<ret>'
map global normal <a-E> '"_<a-?>\s+<ret>'

It’s kinda weird. I like how it ignores whitespaces and selects words only, and I think it will be handy for prose, but I’m not sure if it will actually be useful in coding, as I don’t often use word movements at all, and search is my only friend. I’ll use it for next several days and report again.

I didn’t knew I needed this until I tried it. It works incredibly good but I still have some bad habits of using e and E to avoid whitespace selection.
I still find a bit weird the double selection feature (pressing back to select before the selection start) instead of going back, but it might just be my muscle memory

@xyuusha I added a command to skip words.

Apart from that, I’m open to experiment new changes.

when pressing w while in the middle of the word, whole word is selected. Doesn’t work with W. Is it intended?

Other than that this is far better than default behavior for word movement.

Yep. word-movement is a superset of Alt + i, w. When the action is satisfied, it moves to the next word. W extends, and honors the selection set.

Select a word with w or Alt + w and use W to extend.

I like this idea and plugin. Though I would suggest to add cursor flip feature to W and B before extending next word. For example when word is selected with w cursor is at right side of the selection, then if I decided to extend its left side, I press B but instead of extending to the next word, in my opinion it’s better to flip the cursor first so it is visually obvious which direction next extension will go. But if cursor is already matching the direction side, for example cursor on the left and B pressed there is no need to flip cursor first. I hope it’s clear what I mean. Also it will be useful in one character extension cases.

I can’t do that because of selection restoration.

I am starting to really enjoy the freedom of movement between words without selection. The b key was my biggest problem due to habit. I am giving a set of new key mappings a go which has broken the b key influence.

word-movement-map previous q
word-movement-map next e
word-movement-map skip w

map global normal W ': word-movement-skip-previous-word<ret>'

Thanks for the plugin @alexherbo2.


Having some trouble with word-skip if I put a scalar value 5w it is not jumping the 5 spaces don’t know if this is me our you but I thought I would share.

A work around from the community, sorry it was a lazy day and did not reference your work.

map global normal 'D' ': jump-word %val{count}<ret>' -docstring "jump words"

define-command -params 1 jump-word %{
    execute-keys -with-hooks "<a-:>%arg{1}whl"
}

Cheers Alex.

Just disabled this plugin, and boy oh boy I can’t use Kakoune now. Without this plugin, selecting words is pain, and movement in general is unpredictive for me! Gonna keep it active :smiley:

Thanks for the feedback. I have to admit I lost my interest to write plugins. I still use it, but not much work has been done since a time.

I have just installed this plugin, I am not very sure, but I think that jumping backward is not working:

word-movement-map previous q

What is your version of Kakoune?

v2019.12.10

I’m using it and I have no problem.

I have mapped it to q, then to , in both cases the cursor still at the same place. Is it possible or common to have a conflict with another plugins?

By the way, Can we move between the word while staying in insert mode ?
This feature can be helpful

@alexherbo2 I think your plugin does not allow the user to map to ctrl-left and ctrl-right for word movement.