Welcome to Vifm Q&A, where you can ask questions about using Vifm. Registration is optional, anonymous posts are moderated. E-mail and GitHub logins are enabled.
0 votes
ago in vifm by
edited ago by

for vifm's rename command "cw", is there any way to put the cursor at the exact position before the extention name?

like the file name is "aaaa.epub", when i press "cw", the cursor is at the dot character.

I tried using the <left> for several times, but it cannot adapt for different length of extention names.

1 Answer

0 votes
ago by
 
Best answer

I think I know how to do that, but maybe all you need is cW key? Or do you need this to edit the extension?

ago by

Nope, the 'cW' key is not what i need which is without extention name.

i need the full name but positioning the cursor just before the extention name, more exactly it's at the dot position.

i tried editing the code but didn't find where to change it, maybe you can give me some hint, thank you.

ago by

"cW" is not what I want, but thanks anyway. I have found the way to change this behavior (refer to the code of cmdline mode function cmd_left)

ago by

Here is how to achieve it without code changes:

nnoremap <silent> cw cw=<c-u><c-r>=expand('%c:s/^[^.]*$//:s/^([^.]*(\.))*/\2/')<cr><c-a><c-r>=expand('%c:s/(.*)\.[^.]*$/\1/')<cr>

It inserts the extension, moves the cursor to the start of the line, and then inserts everything before the extension. Although, modifying the code may actually be simpler :)

ago by

Wow! also works perfectly, thanks a lot!

...