The configuration file is/ETC/VIMRC, and the following modifications can be added directly below the configuration file.
Automatically add comments, vim write. sh and. py files when you press F4 in command mode, you can add annotations automatically
Map <f4> ms:call addauthor () <cr> ' Sfunction addauthor () let n=1 while n < 11 let line = getline (n) if line=~ ' [#]*\ s*\*\s*\s*last\s*modified\s*:\s*\s*.*$ ' call updatetitle () return endif let n = n + 1 endwhile if & filetype == ' sh ' call addtitleforshell () elseif &filetype == ' python ' call addtitleforpython () else call addtitleforc() endifendfunction "" add comment for *function addtitleforc () call append (0, "# **********************************************************" ) call append (1, "") call append (2, "# * create time : ". Strftime ("%y-%m-%d %h:%m ")) call Append (3, "# * filename : ". Expand ("%:t")) call append (4, "") call append (5, "# ******************************* ") endfunction" " add comment for Pythonfunction Addtitleforpython () call append (0, "#!/usr/bin/env python") call append (1, "#coding: Utf-8") call append (2, "") call append (3, "# *") call append (4," # * author : pengyongshi ") call append (5, "# * email : [email Protected] call append (6, "# * create time : ". Strftime ("%y-%m-%d %h:%m ")) call append (7," # * last modified : ". Strftime ("%y-%m-%d %h:%m ")) call append (8," # * Filename : ". Expand ("%:t ") call Append (9, "# * description : ") call append (10, "# ********************************************************** ") echohl warningmsg | echo "SuCcessful in adding the copyright. " | echohl noneendfunction "" add conment for shellfunction Addtitleforshell () call append (0, "#!/bin/bash") call Append (1, "# **********************************************************") call append (2, "# * author : pengyongshi") call append (3, "# * email : [email protected] call append (4, "# * create time : ". Strftime ("%y-%m-%d %h:%m ")) call append (5," # * Last modified : ". Strftime ("%y-%m-%d %h:%m ")) call append (6, "# * filename : ". Expand ("%:t")) &Nbsp; call append (7, "# * description : ") call append (8, "# **********************************************************") endfunction
3. Set Tab key to 4 grid
Set tabstop=4
4. Auto Indent
Set Autoindentset cindent
5. Unified Indentation 4, default is 8 grid
Set Softtabstop=4set shiftwidth=4
This article is from the "Stranded," blog, please be sure to keep this source http://yasar.blog.51cto.com/9120455/1875112
Vim Personalization Settings