11.9 Programming Assistancevim has extensive facilities for both the edit-compile-debug cycle and syntax highlighting. 11.9.1 Edit-Compile SpeedupThe facilities in vim were inspired by the "quick fix" mode of the Manx Aztec C compiler for the Amiga. In fact, the vim documentation refers to this feature as "quick fix" mode. The features are quite flexible, allowing you to tailor them to your programming environment (see Table 11.12 ).
Like elvis , as you move through the errors vim also compensates for changes in the file, so that when you go to the next error, you end up on the correct line.
The vim
options that control the
When you execute :!make -k 2>&1| tee /tmp/vim34215.err ... By using the tee (1) program, the output from make and the compiler is saved in the error file (/tmp/vim34215.err ), and also sent to standard output, in this case your screen. When the make
finishes, vim
reads
the error file, and goes to the location of the first error.
It uses the value of the 11.9.2 Syntax Highlighting
Highlighting in vim
is based primarily on colors.
To enable syntax highlighting, put vim has a very powerful sub-language for defining syntax highlighting. The syntax.txt help file in vim 5.1 that describes it is over 1,500 lines long. Therefore, we won't attempt to give all the details here. Instead, the sample file below should give you some taste for what vim can do. The example consists of portions of the syntax file for Awk: " Vim syntax file " Language: awk, nawk, gawk, mawk " Maintainer: Antonio Colombo <antonio.colombo@jrc.org> " Last change: 1997 November 29 " Remove any old syntax stuff hanging around syn clear " A bunch of useful Awk keywords syn keyword awkStatement break continue delete exit ... syn keyword awkFunction atan2 close cos exp int log rand sin \ sqrt srand ... syn keyword awkConditional if else syn keyword awkRepeat while for do syn keyword awkPatterns BEGIN END syn keyword awkVariables ARGC ARGV FILENAME FNR FS NF NR ... " Octal format character. syn match awkSpecialCharacter contained "\\[0-7]\{1,3\}" " Hex format character. syn match awkSpecialCharacter contained "\\x[0-9A-Fa-f]\+" syn match awkFieldVars "\$[0-9]\+" syn match awkCharClass contained "\[:[^:\]]*:\]" syn match awkRegExp contained "/\^"ms=s+1 syn match awkRegExp contained "\$/"me=e-1 syn match awkRegExp contained "[?.*{}|+]" ... " Numbers, allowing signs (both -, and +) " Integer number. syn match awkNumber "[+-]\=\<[0-9]\+\>" " Floating point number. syn match awkFloat "[+-]\=\<[0-9]\+\.[0-9]+\>" ... syn match awkComment "#.*" contains=awkTodo if !exists("did_awk_syntax_inits") let did_awk_syntax_inits = 1 " The default methods for highlighting. Can be overridden later hi link awkConditional Conditional hi link awkFunction Function hi link awkRepeat Repeat hi link awkStatement Statement ... hi link awkNumber Number hi link awkFloat Float ... hi link awkComment Comment ... endif let b:current_syntax = "awk" The file above uses The syntax.vim file predefines the standard conventions, with a number of lines like these: hi Comment term=bold ctermfg=Cyan guifg=#80a0ff hi Constant term=underline ctermfg=Magenta guifg=#ffa0a0 hi Special term=bold ctermfg=LightRed guifg=Orange hi Identifier term=underline ctermfg=DarkCyan guifg=#40ffff ... The first argument defines the class, and the rest define what kind
of highlighting to do on what kind of terminal. In vim
, the syntax colors are global
attributes. Changing the Since the syntax descriptions use attribute linking, you can
make language-specific changes. For example, to change the comment
color for Awk, you can define attributes for hi awkComment guifg=Green vim comes with a large number of syntax descriptions for different languages. The coloring for Awk is slightly psychedelic (lots of red and pink), although the coloring for context diffs is actually rather pleasant, as is the color scheme for UNIX mailbox files. The HTML mode is also pretty interesting. Overall, it's quite a lot of fun to use. | |||||||||||||||||||||||||||||||||||||||
|