A little background. Not long ago, I decided to join the project
w3af (Web Application Attack and Audit Framework) . In this application it is possible to automate repetitive actions using command scripts (such an analog batch file and shell scripts).
# This is a test for the 404 fingerprinting of the core
plugins
output console,textFile
output
output config textFile
set fileName output-w3af.txt
set verbose True
back
output config console
set verbose False
back
discovery pykto,serverHeader
discovery config pykto
#set mutateTests True
back
back
target
set target localhost/w3af
back
start
Constantly working with them, I thought, why did it all fade? And the idea was born to make a simple syntax highlighting for w3af scripts.
Of course you need to start with reading mans (: h syntax). In general, even in this moment, the vim tuning depth is pronounced. You can make your syntax highlighting file. You can override an existing one and so on. To begin with, we will be interested in the section MAKING YOUR OWN SYNTAX FILES.
')
1. If you do not already have, then create the directory ~ / .vim / syntax
2. Here I liked the approach in mana most of all:
Write the Vim syntax file. Or download one from the internet. Then write it in your syntax directory.
Well, that is to say, I’m kind of useful to learn how to write such files, but here it is :) Well, I took the Python syntax-highlighting file as a basis. After we remove everything unnecessary from there, save: w ~ / .vim / syntax / w3af.vim
3. Hooray, now you can use your own backlight scheme:: set syntax = mine
Let us dwell a little more on paragraph 2 :)
" Vim syntax file
" Language: w3af file
" Maintainer: Pento <naplanetu@gmail.com>
" Last change: 2008 Oct 12
if version < 600
syntax clear
elseif exists("b:current_syntax")
finish
endif
syntax sync fromstart
syn keyword w3afStatement set back start assert plugins exploit profiles exit help
syn match w3afComment "#.*$"
if version >= 508 || !exists("did_w3af_syn_inits")
if version <= 508
let did_w3af_syn_inits = 1
command -nargs=+ HiLink hi link <args>
else
command -nargs=+ HiLink hi def link <args>
endif
" The default methods for highlighting. Can be overridden later
HiLink w3afStatement Statement
HiLink w3afComment Comment
delcommand HiLink
endif
let b:current_syntax = 'w3af'
Statement is a common to all programming language tokens (if I use this term correctly here) like Function, Comment, etc. That is, in the end, you will operate with these general groups when coloring your file (see: h syntax section NAMING CONVENTIONS) The keyword is a syntactic entity. Vim understands 3 such entities:
1.
keyword - ordinary keywords. No more and no less :) (: h syn-keyword)
2.
match - match a regular expression (: h syn-match). It is convenient to use it for example to define comments.
3.
region - the region between two “tags” (also reg. Expressions) (: h syn-region). In the python file, this is used to define strings.
There is nesting of these entities. You can also combine them into groups. After that, we have already highlighted a set of keywords:

Now it remains to set a new file type. To do this, add ~ / .vimrc (or use modeline ...: h modeline):
"Filetypes
au BufRead, BufNewFile * .w3af set filetype = w3af
Then, by analogy with the Python file, I added other rules for highlighting. In fact, the number of different settings and techniques described in: h syntax is amazing, but what could you expect from an editor like Vim? =)
Crosspost with
All About Vim