In pcmanfm you can use your ~/Templates
folder, to create new files using them. it's so easy then to make a template file and use it many times, now VIFM as a great file manager, how it can do this?
The best thing about vifm is the sheer amount of things which can be achieved using configuration language. So while there seems to be no built-in means to handle user templates, it's possible to program the behavior you describe with two lines in vifmrc
configuration:
" add command named 'newt' ('new from template') - or any other command name
command newt !ls ~/Templates %m
" map 'C' key in menu mode to paste selected menu entry as command input
mnoremap C c"<c-a><c-f>cp -- ~/Templates/"<c-e> .
Execution of newly added :newt
command will open the list of templates available in your ~/Templates
directory as custom menu. Template entry can be selected using regular navigation (j
, k
, g
, /
etc.), and pressing C on selected entry will open interactive input allowing to enter the name of new file (default is .
which will use original template name, placing it in current directory).
command newt !ls ~/Templates %m
First option is pretty straightforward — it adds the newt
command which calls ls
command in ~/Templates
directory with %m flag - the output of the command will be piped to create the custom interactive menu.
mnoremap C c"<c-a><c-f>cp -- ~/Templates/"<c-e> .
Second option (mnoremap
) is a bit more tricky: it adds a keymap to C key (any different key can be assigned here) which expands into the following sequence:
c
: paste selected menu entry into the command line, as described here.
"
: wrap in double quote on right side ("
) in case if template name contains spaces.
<c-a><c-f>cp -- ~/Templates/"
: move prompt cursor to the left side and insert cp -- ~/Templates/"
command (which wraps template name with "
on the left side).
<c-e> .
: moves cursor back to the end of line and inserts .
as second argument for cp
.
The keymap (C) leaves interactive input with cp
command open, so instead of .
is's possible to enter a different name for a file created from the selected template.