Command-line and alike modes
Command-line editing
Assuming that most of users know at least some of Emacs-like shortcuts usually available on command-line prompt. And also considering them to be quite convenient (and familiar due to the first statement) for single line editing. As well as listening to common sense claims that Vim-like editing of the command-line of Vim-like file manager would be overkill caused adding of shell shortcuts to Vifm's command-line mode.
They are basically can be divided into two categories:
- navigation;
- editing;
- recalling parts of previous commands (see section on history below);
- pasting various information into current cursor position (see section that covers Ctrl-X shortcuts).
TODO: add table for navigation commands.
TODO: add table for editing commands.
TODO: add short table for history commands.
TODO: add short table for Ctrl-X commands.
TODO: refer to "Recalling previous commands" for detailed description of Alt-..
Completion
Available completion kinds
TODO: describe what can be completed on the command line.
Activating, controlling and finishing completion
Starting completion just takes one press of the Tab (or Ctrl-I, which is the same in terminal) or Shift-Tab key. The first one starts completion in forward direction (e.g. in ascending order) while the second one is basically the same but in backward direction.
If nothing happens on hitting one of completion start keys, it might be because:
- there is no matches for the input;
- there is only one match and it's identical to the input.
Same keys are used to go through the list of matches in both directions. One more key is Ctrl-_ (entered as Ctrl-Shift--), which stops completion and restores original input.
Once any other key is pressed match is considered to be picked and completion is finished.
Key | Starts completion | Stops completion | Description |
---|---|---|---|
Tab Ctrl-I |
Yes | No | Complete in forward direction. |
Shift-Tab | Yes | No | Complete in backward direction. |
Ctrl-_ | No | Yes | Restore initial input. |
Any other key | No | Yes | Accept current match. |
One of good developments of completion is displaying of matches so that user
doesn't need to remember the most recent ones and could see what's comming next
at the same time. It's also useful to see that you're actually completting
something rather then just editing command line. Vifm supports one of possible
ways of such matches preview called "wild menu" (same can be found in Vim).
It's disabled by default and is controlled by 'wildmenu'
boolean
option. So it can be enabled like this:
:set wildmenu
There is also related highlight group that can be customized in color schemes
called WildMenu
.
And here is an example of how it looks like:
Treating /
(forward slash) specially
Sometimes matches on completing directory names end with a
slash (/
). At this point one often wants to:
- pick current match and end completion;
- or pick current match and continue by typing file name after already filled in directory name.
To allow doing both of this conveniently and without leaving strange looking
double slash Vifm skips slash character in completion mode if there is
already a slash at cursor position and stops completion at the same time. So
it actually doesn't matter how file name is written as name
or
/name
because both will yield same results.
Comparison of input and completion candidates
Generally to perform completion Vifm matches candidates with pattern (part of input before cursor position when completion starts) like this:
- at the start of the candidate string (like
ab
pattern inabc
candidate); - case sensitive (
ab
doesn't matchAb
,aB
orAB
).
That said, sometimes completion is done differently. Namely, in the following cases:
- when command-line argument being completed is case insensitive (e.g. first argument of the
:highlight
command, which is case insensitive name of highlight group); - when completing paths on Windows, where paths are not case sensitive (well, theoretically they can be, but it's hard to find Windows systems configured in that way);
- completion of
:help
command argument when'vimhelp'
option is set, where pattern is matched anywhere in the string and always in case insensitive way (likecd
pattern inabcDe
candidate).
Recalling previous commands
TODO: History (Ctrl-N/Ctrl-P/Down/Up).
TODO: Alt-. command.
Pasting runtime context into command-line
TODO: describe Ctrl-X mappings.
Editing command-line externally
TODO: describe q:/q//q=/Ctrl-G shortcuts.
Useful Vim-plugin additions
TODO: describe cursor column positioning. TODO: describe automatic insertion mode. TODO: describe handling of Enter.