cF change backw. how can I include start character?


I have noticed that when one wants to make a change c with backwards search with F, then
vim does not include the char one starts on. Eg. if my cursor is on the last char of a word and I want
to change text by searching for the first letter of the word, then all but the last char of the word will be changed, i.e. the char I started on/ was on before initiating the change.

() = cursor start
abcd(e)e if I do cFa.

Is there an easy way to create a custom F command that actually includes the char I am starting on if I want to make a backwards change?

EDIT: I read the docs on motion and it turns out you can change exclusive/inclusive of the command by typing v before F, eg. cvFa would change from char a to b including a.

nnoremap cF lcF " i don’t recommend this :slight_smile:
nnoremap cF cvF

or create a new operator and map it to F.

thanks for the link and suggestions man!
i’m definitely gonna checkout the link and try this. feels like a great exercise for getting
a bit deeper with vim.

allright so I just wanted to get back with my progress. I haven’t solved this yet.
Atm I am learning more about creating custom operators and vimscript which takes a while.
BUT I wanted to just inform anyone reading that

" this is not working
nnoremap cF cvF
nnoremap dF dvF

I am using the latest nightly version and it didn’t work before either fyi.

also I am realizing that you cannot use a {count} between c and F if the mappings above would have worked.

I learnt from this discussion that you should do omap instead!!! :smiley:

then it works perfectly!!

omap T vT
omap F vF
1 Like

actually omap freezesmy nvim now do usenore` instead.