The preparation of the instruments


  • Vim8.2.539 (163).
  • MacOS Catalina 10.15.7

Pay attention to


Don’t do this if you’re installing Vim using Brew, the Mac’s package manager. The version of Vim installed on BREW is not up to date!

Therefore, the best direct Baidu search link to install.

preface


(Usual) As a thrashing emperor I began a new round of thrashing vim

Let’s start with the results:

The interface is quite beautiful, I don’t know what you think, please type your own opinion in the comment area below ↓ ↓ ↓

The body of the

Toss a – Vim beginner’s tutorial

First, talk about the use of VIm

Basically, VI/VIM is divided into three modes, respectively

  • Command Mode
  • Insert mode
  • Last Line Mode

Command mode

The user enters the command mode just after starting vi/vim.

Keystrokes in this state are recognized by Vim as commands rather than input characters. For example, when we press I, instead of typing a character, I is treated as a command.

Here are some common commands:

# I switches to input mode to enter characters.
# x Removes the character at the current cursor position.
# : Switch to baseline command mode to enter commands on the bottom line.
Copy the code

The input mode

Press I in command mode to enter input mode.

In input mode, the following keys can be used:

# character key and Shift combination, input characters
# ENTER, ENTER, line feed
# BACK SPACE, the backspace key, deletes the character before the cursor
# DEL deletes a character after the cursor
# Arrow keys to move the cursor in text
# HOME/END, move the cursor to the beginning /END of the line
# Page Up/Page Down
# Insert, switch the cursor to input/replace mode, the cursor will change to vertical/underline
# ESC, exit input mode and switch to command mode
Copy the code

Baseline command mode

Press (colon) in command mode to enter baseline command mode.

The bottom-line command mode allows you to enter single or multiple character commands, and there are many available commands.

In baseline command mode, the basic commands are (colon omitted) :

# q Exit the program
# w Save the file
Copy the code

Press ESC to exit baseline command mode at any time.

Open file, save file, close file (in command mode)

#:w // Save file
#:w vpser.net // Save to vpser.net file
#:q // Exit the editor, use the following command if the file has been modified
#:q! // Exit the editor without saving
#:wq // Exit the editor and save the file
Copy the code

Move cursor (in command mode)

1, use up, down, left and right arrow keys

2. In command mode: H goes left, J goes down, K goes up, l goes right. Space to the right, Backspace to the left, Enter to the beginning of the next line, and – to the beginning of the previous line.

Toss ii – Vim plug-in installation

After going through vim’s various modes and functions, we finally came to plug-in configuration

To be honest, Vim can work without plug-ins. But the experience with viM without the plugin was still a bit worse than with viM with the plugin

Here’s a list of my plugins:

Note that not every plug-in has to be installed.

The plugin,

  • Vundle

This is the famous Vim plug-in manager, which must be installed in order to install plug-ins

Website tutorial

git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim Clone the vundle package first
Vimrc adds the following content to the header
setNocompatible "required FileType off" required"Set the runtime path to include Vundle and initialize set RTP +=~/.vim/bundle/ vundle.vim call Vundle #begin()" to make Vuldle manage its Plugin 'VundleVim/Vundle.vim' .... "All your plug-ins must be formatted as plugins before this line'GitHub path for plugin'
call vundle#end() " required
filetype plugin indent on    " required
Copy the code

Note that it can take a long time to install the plugin (especially YouCompleteMe), so download a few animations locally in advance to get you through the long, boring period…

  • Other plug-ins
Plugin 'Valloric/YouCompleteMe'    "Auto complete"
Plugin 'nathanaelkane/vim-indent-guides'    "Indent display"
Plugin 'fholgado/minibufexpl.vim'    "Operate multiple files"
Plugin 'Yggdroot/indentLine'    "Indent indicator line"
Plugin 'scrooloose/nerdtree'    "Tree Directory Configuration"
Plugin 'ctrlpvim/ctrlp.vim'
Plugin 'majutsushi/tagbar'    "Show file classes, functions, variables"
Plugin 'dyng/ctrlsf.vim'
Plugin 'vim-airline/vim-airline'
Plugin 'vim-airline/vim-airline-themes'
Plugin 'MattesGroeger/vim-bookmarks'
Plugin 'vim-syntastic/syntastic'    "Grammar check"
Plugin 'dense-analysis/ale'    "Grammar check"
Copy the code

Here is the nerdTree configuration (use F2 shortcut key to open the tree directory, you can customize it)

NERDTree map < F2 > :NERDTreeToggle
      The window positionlet g:NERDTreeWinPos='left'
"Let g:NERDTreeSize=30Copy the code

My vimrc


""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Vundle set nocompatible " be iMproved, required
filetype off                  " required " set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')

" let Vundle manage Vundle, required Plugin 'VundleVim/Vundle.vim' " The following are examples of different formats supported.
" Keep Plugin commands between vundle#begin/end.
" plugin on GitHub repo
"Plugin 'tpope/vim-fugitive'
" plugin from http://vim-scripts.org/vim/scripts.html
"Plugin 'L9'
" Git plugin not hosted on GitHub
Plugin 'git://git.wincent.com/command-t.git'
" git repos on your local machine (i.e. when working on your own plugin)
Plugin 'file:///home/gmarik/path/to/plugin'
" The sparkup vim script is in a subdirectory of this repo called vim.
" Pass the path to set the runtimepath properly.
Plugin 'rstacruz/sparkup', {'rtp': 'vim/'}
" Avoid a name conflict with L9
"Plugin 'user/L9', {'name': 'newL9'}
" All of your Plugins must be added before the following line
call vundle#end() " required
"NerdTree plugin configuration information"NERDTree map < F2 > :NERDTreeToggle<cr>"Let g:NERDTreeWinPos='left'"The window sizelet g:NERDTreeSize=30
filetype plugin on    " required
" To ignore plugin indent changes, instead use:
"filetype plugin on
"
" Brief help
" :PluginList       - lists configured plugins
" :PluginInstall - installs plugins; append `! ` to update or just :PluginUpdate " :PluginSearch foo - searches forfoo; append `! ` to refreshlocal cache
" :PluginClean - confirms removal of unused plugins; append `! ` to auto-approve removal "
" see :h vundle for more details or wiki for FAQ
" Put your non-Plugin stuff after this line

set nocompatible              " be iMproved, required filetype off " required

" set the runtime path to include Vundle and initialize set rtp+=~/.vim/bundle/Vundle.vim call vundle#begin() Plugin 'VundleVim/Vundle.vim' "Vundle plug-in" Plugin 'Valloric/YouCompleteMe' "Automatic completion" Plugin 'nathanaelkane/vim-indent-guides' "The indentation shows" Plugin 'fholgado/minibufexpl.vim' "Working with multiple files" Plugin 'Yggdroot/indentLine' "Indent indicator line" Plugin 'scrooloose/nerdtree' "Tree directory configuration" Plugin 'ctrlpvim/ctrlp.vim' Plugin 'majutsushi/tagbar' "Display file classes, functions, and variables" Plugin 'dyng/ctrlsf.vim' Plugin 'vim-airline/vim-airline' Plugin 'vim-airline/vim-airline-themes' Plugin 'MattesGroeger/vim-bookmarks' Plugin 'vim-syntastic/syntastic' "Syntax checking" Plugin 'dense-analysis/ale' "Syntax checking" call vundle#end() filetype plugin indent on """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Configuration file for vim set modelines=0 " CVE-2007-2438

" Normally we use vim-extensions. If you want true vi-compatibility
" remove change the following statements
set nocompatible	" Use Vim defaults instead of 100% vi compatibility set backspace=2 " more powerful backspacing

" Don't write backup file if vim is being called by "crontab -e"
au BufWrite /private/tmp/crontab.* set nowritebackup nobackup
" Don't write backup file if vim is being called by "chpass" au BufWrite /private/etc/pw.* set nowritebackup nobackup let Skip_defaults_vim =1 colorscheme evening "setting color theme syntax on" syntax highlighting filetype on "checking filetype set number" display line number set cursorline "Autocmd InsertLeave * se nocul "autocmd InsertEnter * se cul set ruler" Set lastStatus =2 "displays the status bar (default is 1, Unable to display the status bar) set statusline < = \ % % F [% 1 * * % % M % n % R % H] = y \ \ % % % 0 (% {& fileformat} \ % {& encoding} \ % c: % l/l % %) \ "set in the status line shows the information set Tabstop =4 "Tab key width set softtabStop =4 set Shiftwidth =4" uniform indentation to 4 set autoindent "vim use automatic alignment, Set cindent "set smartindent" Smartindent For similar C programming, it is useful to set scrolloff=3 "when the cursor moves to the top and bottom of the buffer, keep 3 lines apart. Set incSearch" Search results will be displayed when the search content is entered. Set hlSearch "Highlight the text set that is found Foldmethod =indent "Set indent fold set foldLevel =99" Set mouse=a set linespace=6 set MatchTime =1 nnoremap 
      
        @=((foldclosed(line('
      .')) < 0)? 'zc':'zoIf has("autocmd") au BufReadPost * if line("')\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
endif
Copy the code

Afterword.


There is a kite plugin, but you need to download kite from PC6 on your Mac and click the Install button for VIm. Please type your kite plugin installation in the comments section below ~ ↓ ↓ ↓

Finally, the Vim keymap is only for the old guys to work on, if you are a novice (in plain English, novice) then the keyboard map is suitable for installing X, it doesn’t matter.

Welcome to forward the author’s home page attention and collection! 🙂