vim没有突出显示某些c关键字

前端之家收集整理的这篇文章主要介绍了vim没有突出显示某些c关键字前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我使用 vim(安装在cygwin上)编写c程序,但它没有突出显示一些c关键字,如new,delete,public,friend,try,但突出显示其他命令,如namespace,int,const,operator,true,class,include .它也不会改变操作符的颜色.

我从未改变过它的语法文件.它出什么问题了?
非常感谢.

我使用定制的配色方案;当我将其更改为沙漠配色方案时,突出显示没有问题,但我需要使用该配色方案,并且无法将其更改为其他内容.

我希望它显示程序如下图(我在图片中使用了带有记事本的配色方案):

但现在它如下图所示:

colorscheme在这里:

  1. "Tomorrow Night Bright - Full Colour and 256 Colour
  2. " http://chriskempson.com
  3. "
  4. " Hex colour conversion functions borrowed from the theme "Desert256""
  5.  
  6. " Default GUI Colours
  7. let s:foreground = "eaeaea"
  8. let s:background = "000000"
  9. let s:selection = "424242"
  10. let s:line = "2a2a2a"
  11. let s:comment = "969896"
  12. let s:red = "d54e53"
  13. let s:orange = "e78c45"
  14. let s:yellow = "e7c547"
  15. let s:green = "b9ca4a"
  16. let s:aqua = "70c0b1"
  17. let s:blue = "7aa6da"
  18. let s:purple = "c397d8"
  19. let s:window = "4d5057"
  20.  
  21. set background=dark
  22. hi clear
  23. Syntax reset
  24.  
  25. let g:colors_name = "Tomorrow-Night-Bright"
  26.  
  27. if has("gui_running") || &t_Co == 88 || &t_Co == 256
  28. " Returns an approximate grey index for the given grey level
  29. fun <SID>grey_number(x)
  30. if &t_Co == 88
  31. if a:x < 23
  32. return 0
  33. elseif a:x < 69
  34. return 1
  35. elseif a:x < 103
  36. return 2
  37. elseif a:x < 127
  38. return 3
  39. elseif a:x < 150
  40. return 4
  41. elseif a:x < 173
  42. return 5
  43. elseif a:x < 196
  44. return 6
  45. elseif a:x < 219
  46. return 7
  47. elseif a:x < 243
  48. return 8
  49. else
  50. return 9
  51. endif
  52. else
  53. if a:x < 14
  54. return 0
  55. else
  56. let l:n = (a:x - 8) / 10
  57. let l:m = (a:x - 8) % 10
  58. if l:m < 5
  59. return l:n
  60. else
  61. return l:n + 1
  62. endif
  63. endif
  64. endif
  65. endfun
  66.  
  67. " Returns the actual grey level represented by the grey index
  68. fun <SID>grey_level(n)
  69. if &t_Co == 88
  70. if a:n == 0
  71. return 0
  72. elseif a:n == 1
  73. return 46
  74. elseif a:n == 2
  75. return 92
  76. elseif a:n == 3
  77. return 115
  78. elseif a:n == 4
  79. return 139
  80. elseif a:n == 5
  81. return 162
  82. elseif a:n == 6
  83. return 185
  84. elseif a:n == 7
  85. return 208
  86. elseif a:n == 8
  87. return 231
  88. else
  89. return 255
  90. endif
  91. else
  92. if a:n == 0
  93. return 0
  94. else
  95. return 8 + (a:n * 10)
  96. endif
  97. endif
  98. endfun
  99.  
  100. " Returns the palette index for the given grey index
  101. fun <SID>grey_colour(n)
  102. if &t_Co == 88
  103. if a:n == 0
  104. return 16
  105. elseif a:n == 9
  106. return 79
  107. else
  108. return 79 + a:n
  109. endif
  110. else
  111. if a:n == 0
  112. return 16
  113. elseif a:n == 25
  114. return 231
  115. else
  116. return 231 + a:n
  117. endif
  118. endif
  119. endfun
  120.  
  121. " Returns an approximate colour index for the given colour level
  122. fun <SID>rgb_number(x)
  123. if &t_Co == 88
  124. if a:x < 69
  125. return 0
  126. elseif a:x < 172
  127. return 1
  128. elseif a:x < 230
  129. return 2
  130. else
  131. return 3
  132. endif
  133. else
  134. if a:x < 75
  135. return 0
  136. else
  137. let l:n = (a:x - 55) / 40
  138. let l:m = (a:x - 55) % 40
  139. if l:m < 20
  140. return l:n
  141. else
  142. return l:n + 1
  143. endif
  144. endif
  145. endif
  146. endfun
  147.  
  148. " Returns the actual colour level for the given colour index
  149. fun <SID>rgb_level(n)
  150. if &t_Co == 88
  151. if a:n == 0
  152. return 0
  153. elseif a:n == 1
  154. return 139
  155. elseif a:n == 2
  156. return 205
  157. else
  158. return 255
  159. endif
  160. else
  161. if a:n == 0
  162. return 0
  163. else
  164. return 55 + (a:n * 40)
  165. endif
  166. endif
  167. endfun
  168.  
  169. " Returns the palette index for the given R/G/B colour indices
  170. fun <SID>rgb_colour(x,y,z)
  171. if &t_Co == 88
  172. return 16 + (a:x * 16) + (a:y * 4) + a:z
  173. else
  174. return 16 + (a:x * 36) + (a:y * 6) + a:z
  175. endif
  176. endfun
  177.  
  178. " Returns the palette index to approximate the given R/G/B colour levels
  179. fun <SID>colour(r,g,b)
  180. " Get the closest grey
  181. let l:gx = <SID>grey_number(a:r)
  182. let l:gy = <SID>grey_number(a:g)
  183. let l:gz = <SID>grey_number(a:b)
  184.  
  185. " Get the closest colour
  186. let l:x = <SID>rgb_number(a:r)
  187. let l:y = <SID>rgb_number(a:g)
  188. let l:z = <SID>rgb_number(a:b)
  189.  
  190. if l:gx == l:gy && l:gy == l:gz
  191. " There are two possibilities
  192. let l:dgr = <SID>grey_level(l:gx) - a:r
  193. let l:dgg = <SID>grey_level(l:gy) - a:g
  194. let l:dgb = <SID>grey_level(l:gz) - a:b
  195. let l:dgrey = (l:dgr * l:dgr) + (l:dgg * l:dgg) + (l:dgb * l:dgb)
  196. let l:dr = <SID>rgb_level(l:gx) - a:r
  197. let l:dg = <SID>rgb_level(l:gy) - a:g
  198. let l:db = <SID>rgb_level(l:gz) - a:b
  199. let l:drgb = (l:dr * l:dr) + (l:dg * l:dg) + (l:db * l:db)
  200. if l:dgrey < l:drgb
  201. " Use the grey
  202. return <SID>grey_colour(l:gx)
  203. else
  204. " Use the colour
  205. return <SID>rgb_colour(l:x,l:y,l:z)
  206. endif
  207. else
  208. " Only one possibility
  209. return <SID>rgb_colour(l:x,l:z)
  210. endif
  211. endfun
  212.  
  213. " Returns the palette index to approximate the 'rrggbb' hex string
  214. fun <SID>rgb(rgb)
  215. let l:r = ("0x" . strpart(a:rgb,2)) + 0
  216. let l:g = ("0x" . strpart(a:rgb,2,2)) + 0
  217. let l:b = ("0x" . strpart(a:rgb,4,2)) + 0
  218.  
  219. return <SID>colour(l:r,l:g,l:b)
  220. endfun
  221.  
  222. " Sets the highlighting for the given group
  223. fun <SID>X(group,fg,bg,attr)
  224. if a:fg != ""
  225. exec "hi " . a:group . " guifg=#" . a:fg . " ctermfg=" . <SID>rgb(a:fg)
  226. endif
  227. if a:bg != ""
  228. exec "hi " . a:group . " guibg=#" . a:bg . " ctermbg=" . <SID>rgb(a:bg)
  229. endif
  230. if a:attr != ""
  231. exec "hi " . a:group . " gui=" . a:attr . " cterm=" . a:attr
  232. endif
  233. endfun
  234.  
  235. " Vim Highlighting
  236. call <SID>X("Normal",s:foreground,s:background,"")
  237. call <SID>X("LineNr",s:selection,"","")
  238. call <SID>X("NonText","")
  239. call <SID>X("SpecialKey","")
  240. call <SID>X("Search",s:yellow,"")
  241. call <SID>X("TabLine","reverse")
  242. call <SID>X("StatusLine",s:window,"reverse")
  243. call <SID>X("StatusLineNC","reverse")
  244. call <SID>X("VertSplit","none")
  245. call <SID>X("Visual","")
  246. call <SID>X("Directory",s:blue,"")
  247. call <SID>X("ModeMsg",s:green,"")
  248. call <SID>X("MoreMsg","")
  249. call <SID>X("Question","")
  250. call <SID>X("WarningMsg",s:red,"")
  251. call <SID>X("MatchParen","")
  252. call <SID>X("Folded",s:comment,"")
  253. call <SID>X("FoldColumn","")
  254. if version >= 700
  255. call <SID>X("CursorLine",s:line,"none")
  256. call <SID>X("CursorColumn","none")
  257. call <SID>X("PMenu","none")
  258. call <SID>X("PMenuSel","reverse")
  259. end
  260. if version >= 703
  261. call <SID>X("ColorColumn","none")
  262. end
  263.  
  264. " Standard Highlighting
  265. call <SID>X("Comment","")
  266. call <SID>X("Todo","")
  267. call <SID>X("Title","")
  268. call <SID>X("Identifier","none")
  269. call <SID>X("Statement","")
  270. call <SID>X("Conditional","")
  271. call <SID>X("Repeat","")
  272. call <SID>X("Structure",s:purple,"")
  273. call <SID>X("Function","")
  274. call <SID>X("Constant",s:orange,"")
  275. call <SID>X("String","")
  276. call <SID>X("Special","")
  277. call <SID>X("PreProc","")
  278. call <SID>X("Operator",s:aqua,"none")
  279. call <SID>X("Type","none")
  280. call <SID>X("Define","none")
  281. call <SID>X("Include","")
  282. "call <SID>X("Ignore","666666","")
  283.  
  284. " Vim Highlighting
  285. call <SID>X("vimCommand","none")
  286.  
  287. " C Highlighting
  288. call <SID>X("cType","")
  289. call <SID>X("cStorageClass","")
  290. call <SID>X("cConditional","")
  291. call <SID>X("cRepeat","")
  292.  
  293. " PHP Highlighting
  294. call <SID>X("PHPVarSelector","")
  295. call <SID>X("PHPKeyword","")
  296. call <SID>X("PHPRepeat","")
  297. call <SID>X("PHPConditional","")
  298. call <SID>X("PHPStatement","")
  299. call <SID>X("PHPMemberSelector","")
  300.  
  301. " Ruby Highlighting
  302. call <SID>X("rubySymbol","")
  303. call <SID>X("rubyConstant","")
  304. call <SID>X("rubyAttribute","")
  305. call <SID>X("rubyInclude","")
  306. call <SID>X("rubyLocalVariableOrMethod","")
  307. call <SID>X("rubyCurlyBlock","")
  308. call <SID>X("rubyStringDelimiter","")
  309. call <SID>X("rubyInterpolationDelimiter","")
  310. call <SID>X("rubyConditional","")
  311. call <SID>X("rubyRepeat","")
  312.  
  313. " Python Highlighting
  314. call <SID>X("pythonInclude","")
  315. call <SID>X("pythonStatement","")
  316. call <SID>X("pythonConditional","")
  317. call <SID>X("pythonFunction","")
  318.  
  319. " JavaScript Highlighting
  320. call <SID>X("javaScriptBraces","")
  321. call <SID>X("javaScriptFunction","")
  322. call <SID>X("javaScriptConditional","")
  323. call <SID>X("javaScriptRepeat","")
  324. call <SID>X("javaScriptNumber","")
  325. call <SID>X("javaScriptMember","")
  326.  
  327. " HTML Highlighting
  328. call <SID>X("htmlTag","")
  329. call <SID>X("htmlTagName","")
  330. call <SID>X("htmlArg","")
  331. call <SID>X("htmlScriptTag","")
  332.  
  333. " Diff Highlighting
  334. call <SID>X("diffAdded","")
  335. call <SID>X("diffRemoved","")
  336.  
  337. " Delete Functions
  338. delf <SID>X
  339. delf <SID>rgb
  340. delf <SID>colour
  341. delf <SID>rgb_colour
  342. delf <SID>rgb_level
  343. delf <SID>rgb_number
  344. delf <SID>grey_colour
  345. delf <SID>grey_level
  346. delf <SID>grey_number
  347. endif
将其添加到C突出显示段落:
  1. call <SID>X("Statement","")

猜你在找的Bash相关文章