Non-Binary | High School | OI | Code | Photography | etc. 独立开发者、摄影/文学/电影爱好者 English/中文,日本語を勉強しています INFP | they

vimrc Configuration Guide


Vim, short for Vi Improved, is an extremely powerful editor with the following advantages:

  • No need for a mouse, purely keyboard-based
  • Pre-installed on Linux systems
  • Very efficient once you have memorized the keyboard commands

However, it has numerous configurations that can be difficult to remember. I happen to be configuring it on a new computer, so I am writing this article.

Why not use someone else's?#

  1. My own configuration is more convenient and familiar to me.
  2. Understanding Vim Script allows me to create my own plugins.
  3. etc.

What if I don't know Vim?#

Ah, well... 🤣

You can try entering vimtutor in the command line.

Location of vimrc#

This article uses a newly installed vim as an example. Vim's configuration file is called vimrc. On systems like Mac and Linux, it is located at ~/.vimrc. On Windows systems, it is called _vimrc, but it is still located in the Home directory.

The global configuration is located at /etc/vimrc on systems like Mac and Linux. On Windows systems, it is stored in the Vim installation directory and is also called vimrc.


A Vim with no configuration may look like this when opened:


You can add your own desired configurations below. All configurations can be entered in command mode to enable or disable them temporarily.


set nocompatible " Do not use Vi compatibility mode
filetype plugin on  " Detect file type and load plugins
syntax on " Enable syntax highlighting
set showmode " Show current mode
set showcmd " Show command at the bottom
set mouse=a " Enable mouse (not recommended)
set encoding=utf-8  
set t_Co=256
filetype indent on " Indentation based on file type


set autoindent " Auto-indent
set tabstop=4 " Tab takes up 4 spaces
set shiftwidth=4 " Number of spaces for each level of indentation when pressing >> (increase one level of indentation), << (decrease one level of indentation), or == (remove all indentation) on text.
set expandtab " Convert tab to spaces automatically
set softtabstop=2 " Number of spaces a tab is converted to


set number " Show line numbers
set relativenumber " Show current line number for the cursor line, and relative line numbers for other lines
set cursorline " Highlight the current line
colorscheme default " Set color scheme to default. Color schemes are stored in the .vim/colors folder in the Home directory, and in the vimfiles/colors folder on Windows.
set wrap " Automatically wrap text that exceeds the line width, use set nowrap to disable
set linebreak " Only break lines at certain characters
set laststatus=2 " Whether to show the status line. 0 for no display, 1 for display only in multiple windows, 2 for display.
set ruler " Show cursor position in the status line
set showmatch " Highlight matching brackets
set hlsearch " Highlight search results
set incsearch " Jump to matches as you type
set ignorecase " Ignore case when searching


Vim configurations go beyond these, I have only introduced some commonly used ones. Learning Vim Script is worthwhile, and you can even develop your own plugins after mastering it.

Off-topic - Plugins#

For plugin management, although Vim now has its own built-in plugin manager, I still highly recommend Vim-Plug

Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.