VimThere are ready-made Plug-ins on the official website to add the vim syntax color, which has been difficult to solve. The principle is relatively simple. Use the ctags tool to generate the tags file, then generate the vim source file from the tags file, and then run the vim source command to execute it.
1. Download a Vim that supports Lua, learn Lua's hand itch, and have little understanding of Vim's script. The function is written by Lua;
2. Download a ctags. cygwin may conflict with each other. Make sure the version is correct.
Exuberant ctags 5.8, copyright (c) 1996-2009 Darren Hiebert
Compiled: Jul 9 2009 17:05:35
Addresses: <dhiebert@users.sourceforge.net>, http://ctags.sourceforge.net
Optional compiled features: + Win32, + RegEx, + internal-sort
3. Write a Lua file named stag. Lua. You can modify it by yourself and add more personal settings, such as known tags and change colors;
local tags_vim=io.open("tags.vim", "w");local hl={};hl.f="Function";hl.m="Member";hl.d="Define";hl.s="Struct";hl.v="Variable";hl.t="Typedef";--ctags -R -V -f ./tagsio.input("tags")for line in io.lines() dolocal id, idtype=string.match(line, "^(.-)\t.-;\"\t(.)");if (id) thenlocal hltype=hl[idtype];hltype=hltype or "Type";tags_vim:write("syn keyword " .. hltype .. " " .. id .. "\n");endendtags_vim:write([[syn keyword Typedef stringsyn keyword Typedef stdsyn keyword Typedef auto_ptrhighlight Function gui=none guifg=navy guibg=bg ctermfg=Greenhighlight Member gui=none guifg=#808080 guibg=bg ctermfg=DarkMagentahighlight Define gui=none guifg=#a055df guibg=bg ctermfg=Whitehighlight Struct gui=none guifg=#7f0055 guibg=bg ctermfg=LightGreenhighlight Variable gui=none guifg=blue guibg=bg ctermfg=LightGreenhighlight Typedef gui=none guifg=blue guibg=bg ctermfg=Yellow]]);tags_vim:close();
4. Bind two keys to gvimrc;
map <F11> :call Myhl() <CR><F12>map <F12> :so tags.vim<CR>function! Myhl()lua << EOFdofile("stag.lua");EOFendfunction
5.Run ctags.exe in the directory of the source code to generate the tags file. Press F11 in VIM to see your favorite color settings.