viw / how to select a one char word ?

35 views
Skip to first unread message

M Kelly

unread,
Feb 3, 2020, 6:16:57 AM2/3/20
to vim_use
Hi,

Is there a way to select a one char word ?
lbve or viw or ?  All my attempts seem to continue on to the beginning (or end) of the next word.
Is it that a 'word' cannot be a single char ?

thx for everything vim,
-m

Tony Mechelynck

unread,
Feb 3, 2020, 6:33:16 AM2/3/20
to vim_use
When I do viw with the cursor on a one-letter word, that one-letter
word becomes visually selected. What is 'selection' set to? (":verbose
set sel?" will tell you the value and — if other than by default or
from the keyboard — where it was set.)

My vimrc includes the following, BTW:
" :behave tonymec
if exists('+selectmode')
set slm=mouse,key
endif
if exists('+mousemodel')
set mousemodel=popup
endif
if exists('+keymodel')
set keymodel=startsel
endif
if exists('+selection')
set selection=inclusive
endif

Best regards,
Tony.

M Kelly

unread,
Feb 3, 2020, 6:45:06 AM2/3/20
to vim_use
Tony, hi

I have 

selection=inclusive.

For me, if there is a sentence -

 a few words

and my cursor is on the 'a' and I am in normal mode and I press 'viw'
I get 'a f' visually highlighted/selected.  

It must be some plugin / mapping then, sorry.  I just tried again with -

vim -u NONE

and now 'viw' will only include the 'a' - although the cursor does not change color indicating the selection.

I am very curious where/how this is altered and will have to dig through my .vimrc and plugins.

thx again for your help,
mark

Boyko Bantchev

unread,
Feb 3, 2020, 6:55:32 AM2/3/20
to vim...@googlegroups.com
On Mon, 3 Feb 2020 at 13:16, M Kelly <mckel...@gmail.com> wrote:
>
> Hi,
>
> Is there a way to select a one char word ?
> lbve or viw or ? All my attempts seem to continue on to the beginning (or end) of the next word.
> Is it that a 'word' cannot be a single char ?

If you are in a normal mode, typing ‘v’ (visually) selects the
character under the cursor.
Then, typing ‘y’ will yank that character (and take you back to the
normal mode).
Or instead, type ‘yl’ to the same end.
Either way you will have the character stored in the unnamed register.
Is this what you need?

M Kelly

unread,
Feb 3, 2020, 7:03:18 AM2/3/20
to vim_use
Hi,

Yes, thanks.
I was looking for a consistent way to select the whole word the cursor is on, no matter how many chars it is.
This could then become a new mapping or mouse double-click etc.

It seems viw, vaw, lbve are all good and work most of the time, but I cannot seem to find one set of cmds that always works.
It is also weird the difference between my vim and with -u NONE about the viw.

thx,
-m

M Kelly

unread,
Feb 3, 2020, 8:33:45 AM2/3/20
to vim_use
Hi,

ok I found my error and fixed it. It was in a bad vmap I had for iw
Thank you all, as always, for the info.
Now I think 'viw' works well for me in all cases :-)
I wish the one char word, when selected, changed colour but not a problem.

take care,
-m

Tony Mechelynck

unread,
Feb 3, 2020, 8:45:14 AM2/3/20
to vim_use
On Mon, Feb 3, 2020 at 2:33 PM M Kelly <mckel...@gmail.com> wrote:
>
> Hi,
>
> ok I found my error and fixed it. It was in a bad vmap I had for iw
> Thank you all, as always, for the info.
> Now I think 'viw' works well for me in all cases :-)
> I wish the one char word, when selected, changed colour but not a problem.

In my gvim the one-character visually selected word's Visual highlight
is visible during the "off" phase of the blinking cursor; and with
'showcmd' on the number of characters (and bytes, if different) in the
selection is displayed near bottom right of the Vim screen.

Best regards,
Tony.

BPJ

unread,
Feb 4, 2020, 7:31:30 AM2/4/20
to vim_use
I simply use v. Doesn't that work for you? I have to wait a little moment before I hit the next key because I have 'timeoutlen' set to a rather high value to compensate for my motor disability (I have cerebral palsy and move slower than normal), but with the normal 'timeoutlen' of 100 ms that should not be a problem for physically normal people.


M Kelly

unread,
Feb 5, 2020, 7:40:30 PM2/5/20
to vim_use
Hi,

Yes, I'll wager this has something to do with my terminal and its terminfo capabilities.

thx,
-m
Reply all
Reply to author
Forward
0 new messages