Code Monkey home page Code Monkey logo

rainbow's Introduction

Rainbow Parentheses Improved

help you read complex code by showing diff level of parentheses in diff color !!

As everyone knows, the most complex codes were composed of a mass of different kinds of parentheses(typically: lisp). This plugin will help you read these codes by showing different levels of parentheses in different colors. you can also find this plugin in www.vim.org.

lisp

lisp

html

html

What is improved ?

  • no limit of parentheses levels.
  • separately edit guifgs and ctermfgs (the colors used for highlighting)
  • now you can design your own parentheses such as 'begin' and 'end'.
  • you can also configure anything seprately for different type of files.
  • now you can even decide to let some operators (like + - * / , ==) hilighted with the parentheses together.
  • json style configuration used, more understandable and readable, easier for advanced configuration.
  • the code is shorter and easier to be read now.
  • smoother and faster.
  • the chinese document is added.

Referenced:

Install:

via Vundle:

Plugin 'luochen1990/rainbow'
let g:rainbow_active = 1 "0 if you want to enable it later via :RainbowToggle

Manually:

  • first, put rainbow.vim(this file) to dir ~/.vim/plugin or vimfiles/plugin

  • second, add the follow sentences to your .vimrc or _vimrc :

     let g:rainbow_active = 1 "0 if you want to enable it later via :RainbowToggle
  • third, restart your vim and enjoy coding.

Configure:

There is an example for advanced configuration(which i'm using), add it to your vimrc and edit it as you wish(just keep the format).

	let g:rainbow_conf = {
	\	'guifgs': ['royalblue3', 'darkorange3', 'seagreen3', 'firebrick'],
	\	'ctermfgs': ['lightblue', 'lightyellow', 'lightcyan', 'lightmagenta'],
	\	'operators': '_,_',
	\	'parentheses': ['start=/(/ end=/)/ fold', 'start=/\[/ end=/\]/ fold', 'start=/{/ end=/}/ fold'],
	\	'separately': {
	\		'*': {},
	\		'tex': {
	\			'parentheses': ['start=/(/ end=/)/', 'start=/\[/ end=/\]/'],
	\		},
	\		'lisp': {
	\			'guifgs': ['royalblue3', 'darkorange3', 'seagreen3', 'firebrick', 'darkorchid3'],
	\		},
	\		'vim': {
	\			'parentheses': ['start=/(/ end=/)/', 'start=/\[/ end=/\]/', 'start=/{/ end=/}/ fold', 'start=/(/ end=/)/ containedin=vimFuncBody', 'start=/\[/ end=/\]/ containedin=vimFuncBody', 'start=/{/ end=/}/ fold containedin=vimFuncBody'],
	\		},
	\		'html': {
	\			'parentheses': ['start=/\v\<((area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)[ >])@!\z([-_:a-zA-Z0-9]+)(\s+[-_:a-zA-Z0-9]+(\=("[^"]*"|'."'".'[^'."'".']*'."'".'|[^ '."'".'"><=`]*))?)*\>/ end=#</\z1># fold'],
	\		},
	\		'css': 0,
	\	}
	\}
  • 'guifgs': colors for gui interface, will be used in order.
  • 'ctermfgs': colors for terms
  • 'operators': describe the operators you want to highlight(read the vim help :syn-pattern)
  • 'parentheses': describe what will be processed as parentheses, a pair of parentheses was described by two re pattern
  • 'separately': configure for specific filetypes(decided by &ft), key * for filetypes without separate configuration, value 0 means disable rainbow only for this type of files
  • keep a field empty to use the default setting.

User Command:

  • :RainbowToggle --you can use it to toggle this plugin.

Rate this script if you like it, and i'll appreciate it and improve this plugin for you because of your support ! just goto this page and choose Life Changing and click rate

rainbow's People

Contributors

luochen1990 avatar hoosieree avatar

Watchers

James Cloos avatar Zhiqiang Zhao avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.