invoking 

Send to Kindle
home » snippets » vim » invoking



Load without any scripts

vim -Nu NONE

# Verbose messages.
# -V[N]     Verbose.  Sets the 'verbose' option to [N] (default: 10).
#         Messages will be given for each file that is ":source"d and
#         for reading or writing a viminfo file.  Can be used to find
#         out what is happening upon startup and exit.  {not in Vi}
#         Example:
#             vim -V
#             vim -V8 foobar

# -V[N]{filename}
#         Like -V and set 'verbosefile' to {filename}.  The result is
#         that messages are not displayed but written to the file
#         {filename}.  {filename} must not start with a digit.
#         Example:
#             vim -V20vimlog foobar

Command line options

Option Description
+ Position cursor on the last line.
+num Position the cursor on line num.
+command Same as -c command.
-c command Execute command after the first file has been loaded (after it's read, autocommands and modelines for it have been processed).
--cmd command Execute command before processing any vimrc file. Otherwise it acts like -c command.
-t TAG Look up TAG, make the current file the file associated with the tag, and run the associated command.
-q [errorfile] QuickFix mode.  Read errorfile and display the first error.  If errorfile is absent, uses the errorfile option instead.
-S vimscript_file Equivalent to -c "source vimscript_file". Handy for loading session files.
-s vimscript_file Equivalent to -c "source! vimscript_file".  Since it uses source!, the characters in the file are interpreted as if you had typed them.  After EOF, reads further characters from the keyboard.
g Start in GUI mode.
-e -s Batch mode as Ex.  Silences most prompts, messages (including echo), warnings and errors.  Prints the results of the following commands to stdout— :print, :list, :number, :set.  If verbose is non-zero, prints messages to stderr.  term and $TERM are ignored.  Initializations, except those from -u are skipped.
-b Binary mode.
-l Lisp mode.
-d Diff mode (like vimdiff)
-V[N] Verbose mode.  N defaults to 10.  e.g. -V or -V4.
-V[N]fname e.g. -V20vimlog.  Like setting -V[N] and the 'verbosefile' option.  Obviously, fname can't begin with a digit.
-D Debugging mode.  Enter debug-mode when running the first command from a script.
-Z Restricted mode.
-o[N] Open files in N horizontally split windows.  If N is absent, it defaults to the number of files specified on the command line.
-O[N] Open files in N vertically split windows.  If N is absent, it defaults to the number of files specified on the command line.
-p[N] Open files in N tab pages.  If N is absent, it defaults to the number of files specified on the command line.
--nofork Don't fork in GUI mode.
--noplugin Don't load plugins.  Resets the 'loadplugins' option.  See also -u.
-u vimrc Use vimrc for initialization. Most other initializations are skipped; see initializationvimrc supports some special valuesNONE skips all initializations from files include gvimrc and also does not load any plugins.  NORC is like NONE but loads plugins.
-U vimrc Use gvimrc for GUI initialization instead of other GUI initialization files. If set to NONE, skips GUI initialization from files.
-w {scriptout} Record (append) all the characters you type into the file scriptout.  You can later use that file with :source.
-W {scriptout} Like -w but overwrite the file rather than append.
-i viminfo Use viminfo as the viminfo-file.  If set to NONE, then neither reads or writes viminfo regardless of the 'viminfo' option.
Triggers the SourcePre

When you want to reduce accesses to the disk (e.g., for a laptop), don't use "-n", but set 'updatetime' and 'updatecount' to very big numbers, and type ":preserve" when you want to save your work. This way you keep the possibility for crash recovery.

Start an alternate version for testing

vim_profile() {(
  export VIM_PROFILE_DIR=$1
  if [[ ! -e $VIM_PROFILE_DIR ]]; then
    if [[ -e $VIMWS/profiles/$VIM_PROFILE_DIR ]]; then
      VIM_PROFILE_DIR=$VIMWS/profiles/$VIM_PROFILE_DIR
    elif [[ -e ~/z/play/vim/$VIM_PROFILE_DIR ]]; then
      VIM_PROFILE_DIR=~/z/play/vim/$VIM_PROFILE_DIR
    else
      echo Unknown vim profile: $VIM_PROFILE_DIR
      exit 1
    fi
  fi

  # start with profile
  # -u: specify the .vimrc startup script file
  # -U: specify the .gvimrc startup script file
  # -i: specify the viminfo file
  # --cmd: execute specified command before loading any vimrc file.
  command vim \
      --cmd 'set nocompatible' \
      --cmd "set runtimepath=$VIM_PROFILE_DIR,\$VIM/vimfiles,\$VIMRUNTIME,\$VIM/vimfiles/after,$VIM_PROFILE_DIR/after" \
      -u $VIM_PROFILE_DIR/_vimrc -U $VIM_PROFILE_DIR/_gvimrc -i $VIM_PROFILE_DIR/_viminfo --startuptime $VIM_PROFILE_DIR/startup.log
)}

vim_profile test1