===========================
A better echo
command! Pp [args...]
Where args is a comma-separated list of vim expressions that will be eveluated.
You can also use it as nnoremap i|replacement for call
command, it will show a pretty
return value.
" An example:
:Pp [1, 2, '3', {'a': 4}], function('search'), "special\nchar"
pp.vim defines the global dict g:pp
, which contains the functions for printing/parsing.
:Pp g:pp
You can define your theme by:
- defining a global func
PPtheme
- calling
pp#theme(dict)
- setting
g:pp['theme']
" pp.theme =>
let theme = {}
let theme['Name'] = 'Normal'
let theme['String'] = 'String'
let theme['Number'] = 'Number'
let theme['Float'] = 'Number'
let theme['Function'] = 'Function'
let theme['FuncIdentifier'] = 'Identifier'
let theme['List'] = 'Enum'
let theme['Dict'] = 'Structure'
let theme['SpecialChar'] = 'SpecialChar'
let theme['Separator'] = 'Comment'
let theme['Delimiter'] = 'Delimiter'
let theme['StringDelimiter'] = 'StringDelimiter'
You can also get the pretty theme by calling pp#prettyTheme()
.
-
pp#()
: returnspp
dict -
pp#print(...)
: the function called byPp
command -
pp#dump(obj[, depth=2])
: printsobj
-
pp#theme()
: returns current theme -
pp#theme(t)
: setspp['theme']
tot
Calling pp
object functions:
let obj = {'some': {'object': {'very': {'deeply': 'recursive'}}}}
let depth = 4
call pp.dump(obj, depth)
" (Pp command default is depth=2)
" Don't tell anyone, but if ever you need to print a message
" with highlight:
call pp._('Keyword', 'text to print')