vim-syntax-highlighting

Vim variable syntax highlighting

邮差的信 提交于 2019-11-30 18:11:25
I'd like to change my vim config file to allow highlighting of only my declared variables, not keywords. This article shows and explains what I mean: Alternate syntax highlighting I'm a beginner to vim (I've never changed the default config file). Could anyone point me in the right direction? As proof of concept, I tried let vars = ['init', 'editable', 'init_ui'] let colors = ['ff0000', '00ff00', '0000ff'] for var in vars execute 'syn keyword var_' . var var execute 'hi default var_' . var 'guifg=#' . remove(colors, 0) endfor and it worked as expected. This created syntax items for each

vim syntax: match only when between other matches

♀尐吖头ヾ 提交于 2019-11-30 17:09:57
问题 I am trying to create a syntax file for my logfiles. They take the format: [time] LEVEL filepath:line - message My syntax file looks like this: :syn region logTime start=+^\[+ end=+\] +me=e-1 :syn keyword logCritical CRITICAL skipwhite nextgroup=logFile :syn keyword logError ERROR skipwhite nextgroup=logFile :syn keyword logWarn WARN skipwhite nextgroup=logFile :syn keyword logInfo INFO skipwhite nextgroup=logFile :syn keyword logDebug DEBUG skipwhite nextgroup=logFile :syn match logFile " \S

Vim inconsistently syntax highlighting bash files

六眼飞鱼酱① 提交于 2019-11-30 05:48:10
When I open some bash script files with vim it sometimes identifies them as conf files, that's okay, I can just correct that by setting the filetype to sh with :setf sh . That great, except I've noticed that this doesn't fix things entirely: Notice that shopt is properly highlighted on the left, but not on the right, where I manually set the filetype to sh . This means that when a file is identified as bash or sh by vim, it sets the filetype to sh but then does some extra steps that I'm not doing when I set the filetype manually. Any one know what that might be, and how I could fix it? vim

VIM syntax highlighting of html nested in yaml

梦想与她 提交于 2019-11-30 02:35:03
问题 Given a yaml file that contains html , like this: template : |+ <div>Hello, world</div> Is it possible in Vim (version 7.3.087) to highlight the html portion with html syntax highlighting? I found the post Different syntax highlighting within regions of a file, which seems to have exactly the concept I was looking for, but I cannot get it to work as expected with yaml . I'd expect to be able to do the following (as suggested in the link): " .vimrc " include the code from the above link call

Customizing Syntax Highlighting in Vim

这一生的挚爱 提交于 2019-11-29 23:03:23
问题 How I can keep all the current formatting for a file type but add functionality . I would like to highlight colors in .vim files so that each color is highlighted how the terminal will resolve it. I created a vim.vim file containing: syn keyword yellow yellow containedin=All highlight yellow ctermfg=yellow syn keyword red red containedin=all highlight red ctermfg=red and put it into ~/.vim/after/syntax/vim.vim As suggested here. This has no effect. Update In fact I was mistaken when I said my

Add GoLang syntax highlighting for VIM

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-29 20:25:45
I'm trying to add Go language syntax highlighting to VIM on ubuntu with resources and direction supplied here http://go-lang.cat-v.org/text-editors/vim/ . Go comes with a go.vim file that contains syntax settings for VIM and the above page offers the following instructions Place $GOROOT/misc/vim/syntax/go.vim in ~/.vim/syntax/ and put the following in ~/.vim/ftdetect/go.vim: au BufRead,BufNewFile *.go set filetype=go This is more or less the same vein of procedure for customizing vim syntax I've seen elsewhere ( Vim 7.3 on Ubuntu 12.10 doesn't have 'ftplugin' directory anywhere and https:/

Vim inconsistently syntax highlighting bash files

♀尐吖头ヾ 提交于 2019-11-29 06:12:05
问题 When I open some bash script files with vim it sometimes identifies them as conf files, that's okay, I can just correct that by setting the filetype to sh with :setf sh . That great, except I've noticed that this doesn't fix things entirely: Notice that shopt is properly highlighted on the left, but not on the right, where I manually set the filetype to sh . This means that when a file is identified as bash or sh by vim, it sets the filetype to sh but then does some extra steps that I'm not

Highlight python docstrings as comments (vim syntax highlighting)

流过昼夜 提交于 2019-11-28 23:21:04
Is it possible to modify python.vim (and the corresponding colorscheme file) such that triple-quoted strings right under class and def statements (a.k.a. docstrings) will be highlighted as comments during python syntax highlighting under vim? class URLopener: """Class to open URLs. This is a class rather than just a subroutine because we may need more than one set of global protocol-specific options. Note -- this is a base class for those who don't want the automatic handling of errors type 302 (relocated) and 401 (authorization needed).""" def addheader(self, *args): """Add a header to be

How to override default syntax highlight in vim?

本小妞迷上赌 提交于 2019-11-28 21:34:13
In VIM, I need to perform a simple task - highlight "(" and ")". I can do this easily by issuing two commands: :syn match really_unique_name display "[()]" :hi really_unique_name guifg=#FF0000 But if I add same commands (without ':' of course) to empty .vimrc and restart VIM - "(" and ")" are not highlighted anymore in .cpp files. It seems that if i create/load .cpp file, VIM loads syntax file for it that overrides my custom highlights. How can i configure highlights in my .vimrc file so it will take place after standard syntax definitions or will not be affected by standard syntax definition?

HTML syntax highlighting in javascript strings in vim

感情迁移 提交于 2019-11-28 10:26:23
I don't know if this is possible/sensible, but I was curious to know if I can have my strings in javascript files have html highlighting. I discovered that strings in php could have SQL syntax highlighting, so I believe it is possible. But, I don't know vim-scripting, so any help on this appreciated. I am using the Better Javascript syntax . PS: If there could be an option to turn it on and off while editing a js file, that would be wonderful Thanks Yes, it's possible if you don't mind some syntax file hacking. First you need to include the HTML syntax file from within the Javascript syntax