This chapter discusses some of the options you can use when starting Vim from the command line. A Unix/Linux distribution is assumed for the examples shown in this chapter. Syntax and features might vary for other platforms like Windows.
Documentation links:
DefaultRecall that you need to add
-
prefix for built-in help on CLI options, :h -y for example.
gvim
opens a new unnamed buffer when a filename is not specifiedgvim script.py
opens script.py
script.py
doesn't exist, file will be created only after you explicitly issue write commandsgvim report.log power.log area.log
opens the specified files
report.log
here) will be the current buffergvim -- *.txt
if filenames can start with -
, use --
to prevent such files from being treated as an optiongvim -h
brief description of the options
gvim -p *.log
opens the specified files as separate tab pages
10
pages, use the tabpagemax
setting if you want to change this numbergvim -o *.log
opens the specified files as horizontal splitsgvim -O *.log
opens the specified files as vertical splitsEasy modeYou can append a number to each of these options to specify how many tabs or splits you want. For example,
gvim -p3 *.py
opens three tabs irrespective of the number of input files. Empty buffers will be used if there aren't enough input files to satisfy the given number.
gvim -y
opens in Insert mode and behaves like a click-and-type editor
alias vim='vim -y'
Readonly and Restricted modesSee also novim-mode plugin, which aims to make Vim behave more like a normal editor.
gvim -R
Readonly mode
gvim -M
stricter Readonly mode
gvim -Z
Restricted mode
gvim + script.py
opens script.py
and the cursor is placed on the last linegvim +25 script.py
opens script.py
and the cursor is placed on the 25th line
gvim +/while script.py
opens script.py
and the cursor is placed on the first line containing the given pattern
gvim +1 +/pattern
to force the search to start from the first line, otherwise cursor position stored in viminfo
will be used (if applicable)gvim -c
allows you to execute the Command-line mode command passed as an argumentgvim -c '%s/search/replace/g' script.py
opens script.py
and performs the given substitute operationgvim -c 'normal =G' script.py
opens script.py
and auto indents the entire file contentAs per :h -c, "You can use up to 10
+
or-c
arguments in a Vim command. They are executed in the order given. A-S
argument counts as a-c
argument as well"
Quickfix
--cmd
option is similar to the-c
option, but executes the command before loading anyvimrc
files.
gvim -q <(grep -Hn 'search' *.py)
interactively edit the matching lines from grep
output
-H
and -n
options provide filename and line number prefix for the matching linesgvim -q file
if you had saved the grep
output to that filegvim -q error.log
edit source code based on compiler output containing filenames and line numbers for the error locations
error.log
is assumed to be the filename used to save the error messagesSee Vim and the quickfix list and stackoverflow: How do you use Vim's quickfix feature? to learn more about this feature.
Vimrc and PluginsSee :h quickfix for documentation.
gvim -u file
uses the given file for initialization instead of vimrc
files
vimrc
based on which project you are working on, etcgvim -u NONE
all initializations are skippedgvim -u DEFAULTS
similar to NONE
, but defaults.vim
is loadedgvim -u NORC
similar to NONE
, but plugins are loadedgvim --noplugin
only plugins are not loadedHere's a neat table from :h --noplugin:
argument vimrc plugins defaults.vim (nothing) yes yes yes-u NONE
no no no -u DEFAULTS
no no yes -u NORC
no yes no --noplugin
yes no yes Session and Viminfo
gvim -S proj.vim
restore a session using the previously saved session file
gvim -i proj.viminfo
restore Viminfo from the given file
viminfo
file to save informationRetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4