Vim is set to automatically add spaces to the left and right sides of the operation symbols such as =+-. The original VIM does not have this function, write code such as Z=x+y, not beautiful, many compilers (such as VS) can automatically add space on both sides of the symbol, such as Z = x + y, looks more beautiful.
Just add the following code to the. VIMRC:
"set = +-* Auto space before and after"set, automatically add spaces afterifExists"g:equ"): Inoremap= <c-r>=equalsign ('=') <CR>: Inoremap+ <c-r>=equalsign ('+') <CR>: Inoremap-<c-r>=equalsign ('-') <CR>: Inoremap* <c-r>=equalsign ('*') <CR>: Inoremap/<c-r>=equalsign ('/') <CR>: Inoremap> <c-r>=equalsign ('>') <CR>: Inoremap< <c-r>=equalsign ('<') <CR>: Inoremap,,<space>endiffunction! Equalsign (Char)ifA:Char=~'='&& Getline ('.') =~".*("return A:Charendif let Ex1= Getline ('.') [Col ('.') -3]let ex2= Getline ('.') [Col ('.') -2]ifEx1 =~"[-=+><>\/\*]"ifEX2!~"\s"return"\<esc>i"AChar."\<space>"Elsereturn"\<esc>xa"AChar."\<space>"endifElseifEX2!~"\s"return"\<space>"AChar."\<space>\<esc>a"Elsereturn A:Char."\<space>\<esc>a"endif endifendif
You can do it. In addition, you can add the following code to increase the convenience of vim:
"prevention of hand-mistaken kill strokesnnoremap:: Cnoremap Q! Q!command Wq wqcommand Q qcommand Wq wqset nu"code Displays line numberSyntax on"keyword highlightingSet Cindent"C Syntax Auto indentSet Autoindent"New Line Auto indentSet shiftwidth=4 "Indent width 4Set tabstop=4 "Tab Width 4Set softtabstop=4 "Tab Width 4
Set vim in Linux to automatically add spaces on both sides of the operation symbol