Difference between revisions of "Configuration model"

From Vifm Wiki
Jump to: navigation, search
(Moving and finding configuration files: Expand todo item)
(Moving and finding configuration files: Minor wording fixes)
Line 47: Line 47:
 
There are two environment variables that can be used in both cases:
 
There are two environment variables that can be used in both cases:
  
* <code>$VIFM</code> points to main configuration (usually <code>~/.vifm/</code>);
+
* <code>$VIFM</code> points to main configuration directory (usually <code>~/.vifm/</code>);
 
* <code>$MYVIFMRC</code> points to main configuration file (usually <code>~/.vifm/vifmrc</code>).
 
* <code>$MYVIFMRC</code> points to main configuration file (usually <code>~/.vifm/vifmrc</code>).
  
 
These environment variables are valid inside Vifm and also can be used to
 
These environment variables are valid inside Vifm and also can be used to
configure Vifm. When <code>$MYVIFMRC</code> isn't set, it's made as
+
configure it by setting some of them before running Vifm.
 +
 
 +
When <code>$MYVIFMRC</code> isn't set, it's made as
 
<code>$VIFM/vifmrc</code> (exception for Windows: vifmrc in the same directory
 
<code>$VIFM/vifmrc</code> (exception for Windows: vifmrc in the same directory
as <code>vifm.exe</code> has higher priority then <code>$VIFM/vifmrc</code>).
+
as <code>vifm.exe</code> has higher priority than <code>$VIFM/vifmrc</code>).
  
 
==== Skipping load of configuration files ====
 
==== Skipping load of configuration files ====

Revision as of 22:30, 15 August 2014

There are several commands that can be used to configure Vifm (e.g. :set, :colorscheme), but, if you restart it, all settings are reset to their previous values. To make changes permanent one needs to put them into configuration file or ask Vifm to store them automatically. Intent of this section is to describe things related to configuration.

Configuration files

Vifm follows the same configuration scheme as Vim and many other Unix applications use:

  • main configuration file should be edited manually as it is only read by the application and is never modified by it;
  • state of the application that is preserved across session is stored in separate file(s) and is not meant to be modified by a user.

For Vifm the first file is called vifmrc (located at ~/.vifm/vifmrc by default) and the second one is vifminfo (located at ~/.vifm/vifminfo).

vifmrc consists of regular commands that can be entered on the command line.

vifminfo is usually written automatically. Which settings are written and applied on startup depends on 'vifminfo' option. Instead of just overwriting all settings, Vifm tries to merge previously stored state with the new one. Such strategy helps a lot in managing multiple instances running at the same time. New settings have higher priority than older ones, still Vifm tries to preserve as much of old state as it can to do not forget history items or other settings that user might want to reuse later.

Writing vifminfo manually

Sometimes (e.g. before running external application that might affect configuration of Vifm) it's useful to write vifminfo file without closing Vifm. :write command is exactly for that.

Omitting writing of vifminfo

By default vifminfo is written on exit, i.e. :q[uit] is equal to :wq, this means that requested changes are saved automatically. Although it's quite convenient, sometimes one might want to drop current runtime state in favor of previously stored one or state of another instance. In such rare cases :quit! command-line command or ZQ normal mode shortcut can be used.

Moving and finding configuration files

There are two environment variables that can be used in both cases:

  • $VIFM points to main configuration directory (usually ~/.vifm/);
  • $MYVIFMRC points to main configuration file (usually ~/.vifm/vifmrc).

These environment variables are valid inside Vifm and also can be used to configure it by setting some of them before running Vifm.

When $MYVIFMRC isn't set, it's made as $VIFM/vifmrc (exception for Windows: vifmrc in the same directory as vifm.exe has higher priority than $VIFM/vifmrc).

Skipping load of configuration files

To ease diagnosing issues caused by configuration and provide a way to start Vifm with sane defaults --no-configs command-line option is supported.

Passing it to Vifm blocks reading of both vifmrc and vifminfo files. They can be read later via :restart command. You probably do not want to save vifminfo file after running Vifm in this mode, so consider reading related section of this page.

Reloading configuration

TODO: describe :restart command.