Welcome to Vifm Q&A, where you can ask questions about Vifm usage. Registration is optional, anonymous posts are moderated. GitHub or Google logins are enabled.
0 votes
in vifm by

I'd like to add a few user commands to my vifmrc that contain a digit in their name. For example:

" Convert reStructuredText to HTML
command rst2html rst2html %c /tmp/rst2html-temp.html
" External script for converting mp3 files
command mp3 ~/scripts/ffmpeg-mp3.sh %f
" Compress files using the 7z format with atools
command 7z apack "%a".7z %f

However, when I try any of these in vifm v0.11, I get the following error in a popup:

Error in /home/me/.config/vifm/vifmrc at line 143:

Incorrect command name

Press Return to continue or Ctrl-C to skip its future error messages

I could change their name by replacing the number, as in command mpthree, but I find that too much to type in comparison.

So, I wonder, is it even possible to use numbers in command names?

(I'm not sure if it can be considered a bug or cases like this one are already documented somewhere, so I'm asking here.)

1 Answer

0 votes
by

Numbers aren't allowed in command names. The restriction is in place to allow to skip space after command name if first argument doesn't start with a letter.

Vim doesn't have the same restriction probably because all user-defined :commands start with upper-case letter there.

Lifting this will create ambiguity and it's not clear if it's worth it.

by

The restriction is in place to allow to skip space after command name if first argument doesn't start with a letter.

Could you give me one or two examples? I don't use any commands like that in vifm (or even in the terminal in general), so I'm wondering where this could be practical.

I personally would be very happy to be able to have numbers in commands in some way, but if you're against it, I'm going to respect your decision.

by

See examples with special symbols here. Numbers aren't there, but they are treated the same way. You can do something like :cd10 if you have a directory named 10.

In general I'm not against it, people asked about such commands before, I just worry about problems on entering commands.

7z can't be allowed for sure, because then range in front of the command can't be parsed (Vim doesn't allow this either).

The issue with something like mp3 is that if :mp will be a valid command prefix, then we need a way to decide which command gets called.

A possible solution might be to reject adding a command if it potentially conflicts in this specific way with any other command that's already there (especially with builtin ones). This might work.

by

Next release (after v0.11) will allow numbers in commands (see) unless there will be some issues with this. 7z is still an invalid name.

...