Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Linux .vimrc humanized configuration parameters (can be copied)

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

The following content is from "shell programming practice" published by the old boy

Set nocompatibleset history=100filetype onfiletype plugin onfiletype indent onset autoreadset mouse=asyntax enableset cursorlinehi cursorline guibg=#00ff00hi CursorColumn guibg=#00ff00set nofenset fdl=0set expandtabset tabstop=4set shiftwidth=4set softtabstop=4set smarttabset aiset siset wrapset sw=4set wildmenuset rulerset cmdheight=1set lzset backspace=eol,start,indentset whichwrap+=,h,lset magicset noerrorbellsset novisualbellset showmatchset mat=2set hlsearchset ignorecaseset encoding=utf-8set fileencodings=utf-8set termencoding=utf-8set smartindentset cinset showmatchset guioptions-=Tset guioptions-=mset vb t_vb=set laststatus=2set pastetoggle=set background=darkhighlight Search ctermbg=black ctermfg=white guifg=white guibg=blackautocmd BufNewFile * .py,*.cc,*.sh * .java exec ": call SetTitle ()" func SetTitle () if expand ("%: e") = 'sh' call setline (1, "#! / bin/bash") call setline (2, "# Author:Ray") call setline (3, "# Blog: https://blog.51cto.com/14154700") call setline (4," # Time: ".strftime ("% F% T ")) call setline (5 "# Name:" .clients ("%") call setline (6, "# Version:V1.0") call setline (7, "# Description:This is a test script.") Endifendfunc

Upload the above vim configuration file .vimrc to the "~" directory of the Linux system (effective only for this user), or add it to the / etc/vimrc file (global file, effective for all users), then log out of the SSH client and log in again, and the corresponding settings in .vimrc can be applied.

The vim features configured above are as follows:

As long as it is a file with a .sh extension, copyright information will be automatically added. Code folding, in command mode, you can position the cursor to the beginning of the line that needs to be folded, and then perform zf3j (of which 3 specifies how many lines you want to fold), you can fold the current line and the following three lines of code. If you place the cursor over the corresponding folded line, press the Spacebar to expand the folded line. Sometimes copy part of the shell code from the outside to the current script and find that the indentation is messy, you can adjust the vim editor to command mode (press the ESC key), then position the cursor to the beginning of the line you want to adjust, then press the "v" key, and then use the keyboard up and down keys to select multiple lines of code to adjust, and then press the "=" key to adjust the code to a regular format.

The above configuration is explained as follows:

"turn off compatibility mode set nocompatible" set history steps set history=100 "turn on related plug-in filetype onfiletype plugin onfiletype indent on" when the file is modified externally Automatically update the file set autoread "activate mouse use set mouse=a" = > fonts and colors "" turn on syntax syntax enable "set font" set guifont=dejaVu\ Sans\ MONO\ 10 "set color match" colorscheme desert "highlight the current line set cursorlinehi cursorline guibg=#00ff00hi CursorColumn guibg=#00ff00" "= > Code folding function by oldboy" activate folding function set foldenable setting to fold syntactically (set fdm=XX can be abbreviated) "there are six folding methods:" manual manually defined folding "indent more indentation indicates a higher level of folding" expr defines folding with expressions Fold "syntax uses syntax highlighting to define folding" diff collapses unchanged text "marker folds the flag in the text set foldmethod=manual" sets the width of the folding area if it is not 0 A folding identification column "-" and "+" is displayed on the left side of the screen to indicate open and closed folds, respectively. Set foldcolumn=0 "set the number of folding layers to 3setlocal foldlevel=3" set to automatically close folding set foldclose=all "use the space bar instead of zo and zc shortcut keys to achieve switch folding" zo O-pen a fold "zc C-lose a fold" zf F-old creation (create fold) nnoremap @ = (foldclosed (line ('.'))

< 0) 'zc' : 'zo')"""""""""""""""""""""" =>

Word processing by oldboy "replace Tabset expandtab with spaces" set all Tab and indentation to 4 spaces set tabstop=4 "set the width of the command to 4set shiftwidth=4" so that when pressing the backspace key, you can delete four spaces at a time set softtabstop=4set smarttab "indentation, automatic indentation (inherits the previous line of indentation)" set autoindent command turns off automatic indentation, which is the abbreviation configured below. " You can use the abbreviation of the autoindent command, that is, ": set ai" and ": set noai". " You can also use ": set ai sw=4" to turn on indentation in a command and set the indentation level. Set ai "Smart indent set si" automatic line wrapping set wrap "set soft width set sw=4" > Vim interface by oldboy "" Turn on WiLd menuset wildmenu "display ruler set ruler" set command line height set cmdheight=1 "display lines" set nu "Do not redraw, when running macros.. Lazyredrawset lz "set backspace set backspace=eol,start,indent" Bbackspace and cursor keys wrap toset whichwrap+=,h L "Set magic on (setting Magic) set magic" turns off the sound prompt in the event of an error "turn off the error message ring set noerrorbells" turn off use the visual ring instead of calling set novisualbell "display matching parentheses ([{and}]) set showmatch" How many tenths of a second to blinkset mat=2 "highlight the searched content set hlsearch" search is not case-sensitive "you can also use the abbreviation (": set ic ") And ": set noic") set ignorecase "= > Encoding Settings"set Encoding set encoding=utf-8" Settings File Encoding set fileencodings=utf-8 "set Terminal Encoding set termencoding=utf-8" = > other Settings by oldboy 2010 " "use intelligent auto-indent set smartindentset cinset showmatch when opening new lines" hide toolbar set guioptions-=T "hide menu bar set guioptions-=m" terminal code set vb tones vb = "display status bar (default is 1) Indicates that the status bar cannot be displayed) set laststatus=2 "solution to the problem of pasting without wrapping" set pastetoggle= "set background color set background=dark" set highlight related highlight Search ctermbg=black ctermfg=white guifg=white guibg=black

-this is the end of this article. Thank you for reading-

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report