Tweak vims syntax highlighting

here is a little tutorial for making your own s-h theme for vim,
if you're using gvim you can skip the part about terminals,
for terminal users you must first set your prefered terminal colours in .Xdefaults ,
eg for urxvt:
urxvt*scrollColor: #111111
urxvt*font: xft:Bitstream Vera Sans Mono:pixelsize=13
urxvt*scrollBar_floating: false
urxvt*scrollstyle: urxvt
urxvt*saveLines: 1000
urxvt*foreground: #eeeeee
urxvt*background: #000000
! black
urxvt*color0: #000000
urxvt*color8: #444444
! red
urxvt*color1: #b21818
urxvt*color9: #ee9090
! green
urxvt*color2: #18b218
urxvt*color10: #54ee54
! yellow
urxvt*color3: #968a38
urxvt*color11: #eeee77
! blue
urxvt*color4: #1818b2
urxvt*color12: #9090ee
! magenta
urxvt*color5: #963c59
urxvt*color13: #cf9ebe
! cyan
urxvt*color6: #418179
urxvt*color14: #71bebe
! white
urxvt*color7: #aaaaaa
urxvt*color15: #eeeeee
then you save this example file as ~/.vim/colors/xerxes.vim
" local syntax file - set colors on a per-machine basis:
hi clear
set background=dark
if exists("syntax_on")
syntax reset
endif
let g:colors_name = "xerxes"
hi Normal guifg=white guibg=black
hi Scrollbar guifg=darkcyan guibg=cyan
hi Menu guifg=black guibg=cyan
hi SpecialKey term=bold cterm=bold ctermfg=2 guifg=Blue
hi NonText term=bold cterm=bold ctermfg=darkred gui=bold guifg=Blue
hi Directory term=bold cterm=bold ctermfg=brown guifg=Blue
hi ErrorMsg term=standout cterm=bold ctermfg=grey ctermbg=blue guifg=White guibg=Red
hi Search term=reverse ctermfg=white ctermbg=red guifg=white guibg=Red
hi MoreMsg term=bold cterm=bold ctermfg=darkgreen gui=bold guifg=SeaGreen
hi ModeMsg term=bold cterm=bold gui=bold guifg=White guibg=Blue
hi LineNr term=underline cterm=bold ctermfg=darkcyan guifg=Yellow
hi Question term=standout cterm=bold ctermfg=darkgreen gui=bold guifg=Green
hi StatusLine term=bold,reverse cterm=bold ctermfg=4 ctermbg=15 gui=bold guifg=blue guibg=white
hi StatusLineNC term=reverse ctermfg=white ctermbg=lightblue guifg=white guibg=blue
hi Title term=bold cterm=bold ctermfg=darkmagenta gui=bold guifg=Magenta
hi Visual term=reverse cterm=reverse gui=reverse
hi WarningMsg term=standout cterm=bold ctermfg=red guifg=Red
hi Cursor guifg=bg guibg=Green
hi Comment term=bold ctermfg=6 guifg=#80a0ff
hi Constant term=underline ctermfg=9 guifg=#ffa0a0
hi Special term=bold ctermfg=1 guifg=Orange
hi Identifier term=underline ctermfg=14 guifg=#40ffff
hi Statement term=bold cterm=bold ctermfg=11 gui=bold guifg=#ffff60
hi PreProc term=underline ctermfg=5 guifg=#ff80ff
hi Type term=underline cterm=bold ctermfg=lightgreen gui=bold guifg=#60ff60
hi Error term=reverse ctermfg=darkcyan ctermbg=black guifg=Red guibg=Black
hi Todo term=standout ctermfg=black ctermbg=darkcyan guifg=Blue guibg=Yellow
hi link IncSearch Visual
hi link String Constant
hi link Character Constant
hi link Number Constant
hi link Boolean Constant
hi link Float Number
hi link Function Identifier
hi link Conditional Statement
hi link Repeat Statement
hi link Label Statement
hi link Operator Statement
hi link Keyword Statement
hi link Exception Statement
hi link Include PreProc
hi link Define PreProc
hi link Macro PreProc
hi link PreCondit PreProc
hi link StorageClass Type
hi link Structure Type
hi link Typedef Type
hi link Tag Special
hi link SpecialChar Special
hi link Delimiter Special
hi link SpecialComment Special
hi link Debug Special
now you can start tweaking the theme, use the numbers in .Xdefaults  as your prefered colours in the "ctermfg" and "ctermbg" commands,
now you can use the "colorscheme" command in vim to enable it,
colorscheme xerxes

hello iphitus,
i've edited the first post and if you use that .Xdefaults the following scheme should give you something close to desert,
" Vim color file
set background=dark
if version > 580
" no guarantees for version 5.8 and below, but this makes it stop
" complaining
hi clear
if exists("syntax_on")
syntax reset
endif
endif
let g:colors_name="desert"
hi Normal guifg=White guibg=grey20
" highlight groups
hi Cursor guibg=khaki guifg=slategrey
"hi CursorIM
"hi Directory
"hi DiffAdd
"hi DiffChange
"hi DiffDelete
"hi DiffText
"hi ErrorMsg
hi VertSplit guibg=#c2bfa5 guifg=grey50 gui=none
hi Folded guibg=grey30 guifg=gold
hi FoldColumn guibg=grey30 guifg=tan
hi IncSearch guifg=slategrey guibg=khaki
"hi LineNr
hi ModeMsg guifg=goldenrod
hi MoreMsg guifg=SeaGreen
hi NonText guifg=LightBlue guibg=grey30
hi Question guifg=springgreen
hi Search guibg=peru guifg=wheat
hi SpecialKey guifg=yellowgreen
hi StatusLine guibg=#c2bfa5 guifg=black gui=none
hi StatusLineNC guibg=#c2bfa5 guifg=grey50 gui=none
hi Title guifg=indianred
hi Visual gui=none guifg=khaki guibg=olivedrab
"hi VisualNOS
hi WarningMsg guifg=salmon
"hi WildMenu
"hi Menu
"hi Scrollbar
"hi Tooltip
" syntax highlighting groups
hi Comment guifg=SkyBlue
hi Constant guifg=#ffa0a0
hi Identifier guifg=palegreen
hi Statement guifg=khaki
hi PreProc guifg=indianred
hi Type guifg=darkkhaki
hi Special guifg=navajowhite
"hi Underlined
hi Ignore guifg=grey40
"hi Error
hi Todo guifg=orangered guibg=yellow2
" color terminal definitions
hi SpecialKey ctermfg=darkgreen
hi NonText cterm=bold ctermfg=darkblue
hi Directory ctermfg=darkcyan
hi ErrorMsg cterm=bold ctermfg=7 ctermbg=1
hi IncSearch cterm=NONE ctermfg=yellow ctermbg=green
hi Search cterm=NONE ctermfg=grey ctermbg=blue
hi MoreMsg ctermfg=darkgreen
hi ModeMsg cterm=NONE ctermfg=brown
hi LineNr ctermfg=3
hi Question ctermfg=green
hi StatusLine cterm=bold,reverse
hi StatusLineNC cterm=reverse
hi VertSplit cterm=reverse
hi Title ctermfg=5
hi Visual cterm=reverse
hi VisualNOS cterm=bold,underline
hi WarningMsg ctermfg=1
hi WildMenu ctermfg=0 ctermbg=3
hi Folded ctermfg=darkgrey ctermbg=NONE
hi FoldColumn ctermfg=darkgrey ctermbg=NONE
hi DiffAdd ctermbg=4
hi DiffChange ctermbg=5
hi DiffDelete cterm=bold ctermfg=4 ctermbg=6
hi DiffText cterm=bold ctermbg=1
hi Comment ctermfg=12
hi Constant ctermfg=9
hi Special ctermfg=5
hi Identifier ctermfg=10
hi Statement cterm=bold ctermfg=11
hi PreProc ctermfg=1
hi Type ctermfg=2
hi Underlined cterm=underline ctermfg=5
hi Ignore cterm=bold ctermfg=7
hi Ignore ctermfg=darkgrey
hi Error cterm=bold ctermfg=7 ctermbg=1

Similar Messages

  • [vim syntax] Highlight all occurences of word following keyword

    Is it possible with vim syntax files to have special highlighting for all occurrences of words (preferably excluding occurences in comments and quoted strings) following a keyword? Eg. in the case of declaring variables:
    short <varname>
    I'd like every occurrence of all variables declared as 'short' (preferably including the occurrence in the declaration) to be a specific color.

    You can do `short <varname>` and have that occurence of <varname> be highlighted but you can't have all occurences of <varname> be highlighted. Vim syntax only uses simple pattern matching so it can't determine dynamically what the pattern is after you declare it. Your next best option might be to set hlsearch and use the # and * and related operators.

  • [self-SOLVED]vim + lilypond syntax highlighting

    I'm trying to get vim to use syntax highlighting in lilypond files. Apparently lilypond comes with the necessary files, but I have not been able to make vim find them (?). I am not very experienced with vi(m), so there might be something wrong with my setup.
    I have, of course, both vim and lilypond installed. The files for lilypond syntax highlighting are in subdirectories of /usr/share/lilypond/2.12.3/vim/. Vim syntax highlighting works for other files, such as C++, HTML, etc., so no problem there. My ~/.vimrc file contains
    set runtimepath+=/usr/share/lilypond/2.12.3/vim/
    as per instruction given in http://lilypond.org/doc/v2.12/Documenta … m/Vim-mode (and the path is correctly modified). But when I open a lilypond file (with the correct .ly suffix) all I get is black and white. What's the problem?
    [EDIT: Oh heck, nevermind! Apparently I was getting too tired to read instructions properly. Was missing the ~/.vim/filetype.vim file described in the above link.]
    Last edited by lotuskip (2010-04-12 18:33:42)

    You're right about it being overridden.  This change should be able to be placed in ~/.vimrc though.
    Well  that was foolish - I should have read the comments right below in that file.  It says exactly how to set it in vimrc.  I've now added the following to my ~/.vimrc and this is completely solved without modifying the /usr/... file.
    let g:tex_flavor = "tex"
    Last edited by Trilby (2013-03-29 16:11:26)

  • Lost syntax highlight in Vim after upgrade

    I don't know why, but Vim is not enabling syntax highlight anymore after the upgrade from 7.1.12-1 to 7.1.63-1. I've already searched in Vim's website and with ':help syntax.txt' but no luck. Any guesses?
    EDITED:
    I figured out part of the problem. I've always used the syntax 'vi filename' to open my files because I knew Vi had a link to Vim. But now it's not linking anymore. Opening files with 'vim filename' gives me the syntax highlight. So I guess the last upgrade had removed the link. Any chances to have it back?
    Last edited by alexmatos (2007-08-12 14:07:06)

    I had the same problem too, but the difference is, I always use vim, but after upgrading Arch I lost syntax highlight. After googling a lot and lurking @ vim sites I finally found the indirect answer here!
    I tried the opposite and use vi to open files but bash said vi not found, I did pacman -S vi, and pac said vi is up to date, upgrade? I decided not to believe vi and upgraded, everything's back now.
    So thank you for helping without knowing.

  • [SOLVED] VIM: different syntax highlighting for new vs existing file

    I've had this minor nagging issue for a while that I've been trying to figure out, but I just don't know where to look.
    It is most obvious with LaTeX files (*.tex).  When I create a new file with "vim file.tex" it is recognized as a latex file and I get syntax highlighting, but it seems odd, or off.  When I close then reopen the same file, it gets "propper" syntax highlighting.
    I gather that this must be because of the two different mechanisms for matching the syntax type: filename versus content.  When the file is new, vim only uses the extension.  Once there is a latex comand (e.g., "\documentclass{article}") it recognizes it as something else and the highlighting style is different.
    It turns out just by actually elaborating exactly what the problem was, I was able to find the solution.  I looked for how vim recognizes the files, and found two relevant lines in /usr/share/vim/vim73/filetype.vim on lines 2093 and 2094.  Apparently the .tex filetype is not the same as .latex and others.  I changed it so it was, and I got the desired behavior.
    I thought about just not posting this - but it may be useful for others.

    You're right about it being overridden.  This change should be able to be placed in ~/.vimrc though.
    Well  that was foolish - I should have read the comments right below in that file.  It says exactly how to set it in vimrc.  I've now added the following to my ~/.vimrc and this is completely solved without modifying the /usr/... file.
    let g:tex_flavor = "tex"
    Last edited by Trilby (2013-03-29 16:11:26)

  • [SOLVED] syntax highlighting in vim

    Hi,
    How do you guys set syntax highlighting in your vimrc?  For example, I have a bunch of mutt config files saved as something like alias.muttrc, colors.muttc, etc... and I want them all to use the muttrc syntax.
    Currently, I have this in my vimrc:
    au BufNewFile,BufRead *.muttrc setf muttrc
    This works unless my first line is a comment (or first non-blank line).   Which is annoying because I want to begin with a comment sometimes!
    Also, I noticed that if my main config file--muttrc--is set correctly whether or not it begins with a comment.   (This file is already matched to muttrc syntax without my intervention).
    Does anyone have a better/different way of setting the syntax?
    Last edited by miggy (2009-05-27 16:15:44)

    Thanks for the suggestion but I'm experiencing the same behavior.  Something weird's going on.   Can someone confirm this same behavior?
    file1.muttrc
    color normal white default
    file2.muttrc
    # Comment
    color normal white default
    file3.muttrc
    color normal white default
    # Comment
    As I'm writing these, they all are good, but when I go to edit them, only file1.muttrc has the correct highlighting.  The others can get it if I say :set syntax=muttrc. 
    It's especially weird that the comments are highlighted but nothing else is.  If I'm not using any sort of file detecting then not even the comments are highlighted

  • Vim complex syntax highlight

    I'm trying to create a vim syntax file for writing. I'm detecting matching quote marks so I change the color of quotes, and I'm also detecting plain text stylings like /italics/ and *bold* to modify the style accordingly. However, I can't seem to combine them.
    For example:
    black black black "green green green" black black.
    black black black *bold-black* black
    black black black "green green green *bold-black* green" black.
    Is there a way for vim to preserve the color of the containing element but modify the style (or vice versa)?
    Thanks.

    Hi,
    $ echo $TERM
    xterm
    And
    :set ft
      filetype=php                                     
    :set syntax
      syntax=php 
    Using aterm does work! But is there any option to enable colors under xterm?
    thanks
    phrakture wrote:
    Before you enter vim, what is the output of "echo $TERM".
    When inside vim, what is the output ":set ft" and ":set syntax"?

  • Enable syntax highlighting with configuration file in emacs

    When editing configuration files such as .procmailrc, .fetchmailrc, Emacs won't automatically highlight syntax for me.
    I can enable syntax highlighting in Vim by appending "syntax on"  to the .vimrc.
    I tried adding "global-font-lock-mode t" in the .emacs file, but it didn't solve my problem.
    What is the solution?

    igndenok wrote:
    Some of my config file have this (using conf-unix-mode)
    # this is .somerc
    # -*- conf-unix -*-
    Or using this in your .emacs
    (add-to-list 'auto-mode-alist '("\\.*rc$" . conf-unix-mode))
    I followed your advice, and it does have some syntax highlighting, but less than Vim does.
    For example, Vim will highlight all the names of colors in the .muttrc file, but Emacs doesn't.
    I guess Emacs is not as strong as Vim when it comes to editing configuration files.
    Last edited by yu3k (2011-09-14 10:06:47)

  • /usr/share/nano/js.nanorc configuration: syntax highlighting

    I have a question regarding syntax highlighting with JavaScript using nano. I have tweaked the js.nanorc file to my liking using the colors I prefer:
    ## New updated taken from [url]http://wiki.linuxhelp.net/index.php/Nano_Syntax_Highlighting[/url]
    syntax "JavaScript" "\.(js)$"
    ## Default
    color brightgreen "^.+$"
    ## Decimal, cotal and hexadecimal numbers
    color brightyellow "\<[-+]?([1-9][0-9]*|0[0-7]*|0x[0-9a-fA-F]+)([uU][lL]?|[lL][uU]?)?\>"
    ## Floating point number with at least one digit before decimal point
    color brightyellow "\<[-+]?([0-9]+\.[0-9]*|[0-9]*\.[0-9]+)([EePp][+-]?[0-9]+)?[fFlL]?"
    color brightyellow "\<[-+]?([0-9]+[EePp][+-]?[0-9]+)[fFlL]?"
    ## Keywords
    color brightcyan "\<(break|case|catch|continue|default|delete|do|else|finally)\>"
    color brightcyan "\<(for|function|if|in|instanceof|new|null|return|switch)\>"
    color brightcyan "\<(switch|this|throw|try|typeof|undefined|var|void|while|with)\>"
    ## Type specifiers
    color brightmagenta "\<(Array|Boolean|Date|Enumerator|Error|Function|Math)\>"
    color brightmagenta "\<(Number|Object|RegExp|String)\>"
    color brightmagenta "\<(true|false)\>"
    ## String
    color brightblue "L?\"(\\"|[^"])*\""
    color brightblue "L?'(\'|[^'])*'"
    ## Escapes
    color red "\\[0-7][0-7]?[0-7]?|\\x[0-9a-fA-F]+|\\[bfnrt'"\?\\]"
    ## Comments
    color brightwhite start="/\*" end="\*/"
    color brightwhite "//.*$"
    However, I would also like the rendering to be a little different. For example:
    var code = function(nano) {
    console.log("I would like these parenthesis to be a different color than the keywords");
    The parenthesis and keywords(var, function, for, while....etc) are the same color, how can I adjust the rendering so that the parenthesis or brackets will be a different color?
    Last edited by rg_arc (2012-04-04 13:40:31)

    doug piston wrote:I deal with alot of .mk files and would love to see it there.
    You mean GNU makefiles?
    I'm afraid they might be out of scope for this generic config-file syntax.
    Logically they're not system config files, and technically they're a pretty specialized and complex format (different "types" of rules, rules spanning multiple lines, rules containing arbitrary Bash code, etc.).
    This is how an .mk file currently looks with this highlighting syntax:
    $ nano -Y conf /usr/lib/httpd/build/rules.mk
    And apart from highlighting variables of the form $$abc or $(abc), I'm not sure how much can be improved here without breaking the highlighting for more conventional config files.
    It would probably be better to create a specialized highlighting syntax just for .mk files.
    EDIT: I sat down and did just that, here's the result: nano syntax highlighting: GNU makefiles, and here is how the above makefile snipped looks with it:
    Last edited by sas (2012-02-01 15:18:52)

  • Syntax Highlighting for MATRIXx MathScript and TPL

    There have been some questions about text editors for MATRIXx, so I wanted to let everyone know about an application note that we just posted. It describes how to configure a syntax highlighter for use with MathScript and Template Programming Language (TPL). There is also an example of how Crimson Editor can be configured. I choose Crimson Editor because it was free, but the same thing can be done in other syntax highlighters. Using a syntax highlighter makes MATRIXx code a lot easier to read.
    http://zone.ni.com/devzone/conceptd.nsf/webmain/C43375149CB01C3186256E530081EAA5
    While I am at it, I am going to point out some other resources. The application note is located on Developer Zone section of our website, where
    you can find other MATRIXx examples and tutorials:
    http://zone.ni.com/devzone/devzone.nsf/webcategories/A92DB8BA2DE149F486256CBC00655A0C?opendocument
    If you have code or examples that you want to share with other users you can submit the example to the Example Code Library:
    http://www.ni.com/devzone/dev_exchange/ex_search.htm
    Suggestions and feedback can be submitted from Product Feedback section of Contact NI:
    http://sine.ni.com/apps/we/nicc.call_me?p_action=country&p_lang_id=US
    And of course the main MATRIXx page is:
    http://www.ni.com/matrixx
    Carl L
    National Instruments

    I found another editor with syntax highlighting capabilities for MATRIXx. The editor is VIM which is based on the Unix VI editor, and is available on both Solaris and Windows.
    www.vim.org
    Carl L
    National Instruments
    www.ni.com/matrixx

  • Nano syntax highlighting: catch-all syntax for configuration files

    After years of using nano, I only recently learned that it supports syntax coloring... (Why would they turn that off by default? ) Well, I thought I'll make up for it by making extra good use of it from now on...
    Unfortunately it didn't ship a highlighting syntax for the the kind of files that I use nano the most for: system configuration files.
    So I wrote my own, and after tweaking a bit here and there whenever I encountered a config file for which the highlighting wasn't satisfactory at first, I think the result is now good enough (screenshots below) that it's worth sharing with my fellow Arch users:
    Code & Instructions:
    Here is the syntax definition:
    # config file highlighting
    syntax "conf" "(\.(conf|config|cfg|cnf|rc|lst|list|defs|ini|desktop|mime|types|preset|cache|seat|service|htaccess)$|(^|/)(\w*crontab|mirrorlist|group|hosts|passwd|rpc|netconfig|shadow|fstab|inittab|inputrc|protocols|sudoers)$|conf.d/|.config/)"
    # default text
    color magenta "^.*$"
    # special values
    icolor brightblue "(^|\s|=)(default|true|false|on|off|yes|no)(\s|$)"
    # keys
    icolor cyan "^\s*(set\s+)?[A-Z0-9_\/\.\%\@+-]+\s*([:]|\>)"
    # commands
    color blue "^\s*set\s+\<"
    # punctuation
    color blue "[.]"
    # numbers
    color red "(^|\s|[[/:|<>(){}=,]|\])[-+]?[0-9](\.?[0-9])*%?($|\>)"
    # keys
    icolor cyan "^\s*(\$if )?([A-Z0-9_\/\.\%\@+-]|\s)+="
    # punctuation
    color blue "/"
    color brightwhite "(\]|[()<>[{},;:=])"
    color brightwhite "(^|\[|\{|\:)\s*-(\s|$)"
    # section headings
    icolor brightyellow "^\s*(\[([A-Z0-9_\.-]|\s)+\])+\s*$"
    color brightcyan "^\s*((Sub)?Section\s*(=|\>)|End(Sub)?Section\s*$)"
    color brightcyan "^\s*\$(end)?if(\s|$)"
    # URLs
    icolor green "\b(([A-Z]+://|www[.])[A-Z0-9/:#?&$=_\.\-]+)(\b|$| )"
    # XML-like tags
    icolor brightcyan "</?\w+((\s*\w+\s*=)?\s*("[^"]*"|'[^']*'|!?[A-Z0-9_:/]))*(\s*/)?>"
    # strings
    color yellow "\"(\\.|[^"])*\"" "'(\\.|[^'])*'"
    # comments
    color white "#.*$"
    color blue "^\s*##.*$"
    color white "^;.*$"
    color white start="<!--" end="-->"
    To install, save the above above code snippet as a file called conf.nanorc in the folder /usr/share/nano/ (or /usr/local/share/nano/ or similar if you feel strongly about the /usr <--> /usr/local separation), and then add the following to the end of the file /etc/nanorc:
    ## Configuration files (catch-all syntax)
    include "/usr/share/nano/conf.nanorc"
    Hints:
    The colors I chose look good (imo) with the terminal background and color settings that I use, but might not look good, or even readable, with yours, so simply change the color names in the code snippet to whatever you prefer - valid color names are:
    If you use a console with white background, you'll have to change at least the white color I chose for comments and punctuation.
    The first code line in the snippet includes a regular expression that defines for which file names this syntax highlighting should be used. Whenever you encounter a config file that is not matched by this, but you would still like to open it with syntax highlighting, you can manually select this syntax with nano's -Y switch, like so:
    nano -Y conf myConfigFile
    Technical Note:
    It's implemented as a single catch-all syntax, since nano chooses which syntax to apply based on the filename, and in the case of config files usually not much can be learned about the content format from the file name extension (.conf can by anything from flat key/value tuples to XML, .ini can be the official INI format or something else, etc...).
    This means that some compromises have been made, so with this highlighting syntax probably no config file looks 100% as good as a highlighting syntax that would be specifically optimized for one kind of config format, but all in all the vast majority of config files should look pretty good.
    Screenshots:
    /etc/rc.conf,  /etc/hosts:
    /etc/pacman.conf,  /etc/group:
    xorg.conf,  some .desktop file:
    httpd.conf (Apache config),  php.ini:
    More screenshots:
    /etc/fonts/fonts.conf (uses XML)
    /etc/inittab
    /etc/fstab
    /etc/inputrc
    /etc/mime.types
    /etc/protocols
    /etc/xinetd.conf
    See Also:
    nano syntax highlighting: GNU makefiles
    Update [2012-01-28]: Made some more improvements to the syntax definition (see post)
    Last edited by sas (2012-02-01 15:26:43)

    doug piston wrote:I deal with alot of .mk files and would love to see it there.
    You mean GNU makefiles?
    I'm afraid they might be out of scope for this generic config-file syntax.
    Logically they're not system config files, and technically they're a pretty specialized and complex format (different "types" of rules, rules spanning multiple lines, rules containing arbitrary Bash code, etc.).
    This is how an .mk file currently looks with this highlighting syntax:
    $ nano -Y conf /usr/lib/httpd/build/rules.mk
    And apart from highlighting variables of the form $$abc or $(abc), I'm not sure how much can be improved here without breaking the highlighting for more conventional config files.
    It would probably be better to create a specialized highlighting syntax just for .mk files.
    EDIT: I sat down and did just that, here's the result: nano syntax highlighting: GNU makefiles, and here is how the above makefile snipped looks with it:
    Last edited by sas (2012-02-01 15:18:52)

  • [SOLVED] vim color highlighting not correctly displayed in vc/tty

    For instance visual selection is set up to change fg/bg to black/green but changes fg to green. Under x using urxvt it displays correctly.
    Last edited by Noble (2010-07-26 21:22:19)

    I have written my own syntax highlight theme, post below. If you think your script could do anything about it after looking at the file please post But as I said, vim works fine in urxvt, but not when I switch out of X and run it in the vc/tty.
    :set statusline=#%n\ %y\ %F\ %r\ %=%c\ %l/%L
    :set hlsearch
    :set nocompatible
    :set noexrc
    :set number
    :syntax enable
    :set autochdir
    :set backup
    :set backupdir=~/.vim/backup
    :set directory=~/.vim/tmp
    :set autoindent
    :set ruler
    :set nowrap
    :set nocp
    :set scrolloff=5
    :set sidescrolloff=5
    :set fileformats=unix,dos,mac
    :set title
    :set laststatus=2
    :set tabstop=4
    :set autoread
    :set showcmd
    :set showmatch
    :set shiftwidth=4
    :set smarttab
    :set backspace=indent,eol,start
    filetype on
    filetype plugin on
    filetype indent on
    hi clear
    set background=dark
    if exists("syntax_on")
    syntax reset
    endif
    highlight ErrorMsg ctermfg=red ctermbg=none cterm=bold
    highlight WarningMsg ctermfg=red ctermbg=none cterm=bold
    highlight VertSplit ctermfg=green ctermbg=black
    highlight Folded ctermfg=magenta ctermbg=none
    highlight FoldColumn ctermfg=magenta ctermbg=none
    highlight FoldColumn ctermfg=magenta
    highlight LineNr ctermfg=green cterm=bold
    highlight ModeMsg ctermfg=lightgreen cterm=bold
    highlight MatchParen ctermfg=black ctermbg=green
    highlight Normal ctermfg=white ctermbg=none
    highlight SignColumn ctermfg=magenta
    highlight NonText ctermfg=blue
    highlight Question ctermfg=red cterm=bold
    highlight Comment ctermfg=8
    highlight Constant ctermfg=green cterm=none
    highlight Identifier ctermfg=white cterm=bold
    highlight Statement ctermfg=lightgreen cterm=bold
    highlight PreProc ctermfg=10
    highlight Type ctermfg=2
    highlight Special ctermfg=cyan
    highlight Error ctermfg=red ctermbg=none
    highlight Todo ctermfg=yellow ctermbg=none cterm=bold
    highlight StatusLine ctermfg=black ctermbg=green cterm=none
    highlight StatusLineNc ctermfg=black ctermbg=lightgreen cterm=none
    highlight Directory ctermfg=white
    highlight Search ctermfg=black ctermbg=green cterm=none
    highlight Visual ctermfg=black ctermbg=lightgreen
    highlight WildMenu ctermfg=black ctermbg=cyan cterm=none
    highlight Pmenu ctermfg=black ctermbg=green
    highlight PmenuSel ctermfg=black ctermbg=lightgreen cterm=none

  • Syntax highlighting not working with label on if statement in fortran in Visual studio 2010

    I am having a difficult time in figuring out the syntax highlighting in Visual studio. I am using fortran code and there are labels in if statements as follows: 
                if_2003: IF (FRAC_PBED(NNSED,L).LT.0.0.AND.
         +                   FRAC_PBED(NNSED,L).GT.SMALL_NEG_NO) THEN
                  FRAC_PBED(NNSED,L) = 0.0
           TSED_PBED(1,NNSED,L) = 0.0
         END IF if_2003
    So the problem I am having is when I click on the `if` next to label `if_2003`, then I cannot use `CTRL + ]` to move to the ending `if`. If there is no label before `if`, then the shortcut is working fine. I don't know what I could do so that it would start
    behaving as it is supposed to. 
    In the contrary, when I have do loop as follows: 
        do_410: DO NNSED=1,NSTD
             D50AVG(L) = D50AVG(L) + 
             +                 FRAC_ALAY_SURF(NNSED,L)*D50(NNSED)/10000.  ! BASED ON BED COMPOSITION
        C
             TSED_ALAY_SURF(2,NNSED,L)=TSED_ALAY_SURF(1,NNSED,L)
             TSED_ALAY_BUFF(2,NNSED,L)=TSED_ALAY_BUFF(1,NNSED,L)
             TSED_PBED(2,NNSED,L)=TSED_PBED(1,NNSED,L)
                  END DO do_410
    I can move to the end/start of `do` loop using the keyboard shortcut `CTRL + ]`. Any suggestions is appreciated.  
    Regards, Jdbaba

    Hello Jdbaba,
    Based on my research, your post is related to use fortran in Visual Studio:https://software.intel.com/en-us/articles/intel-math-kernel-library-intel-mkl-for-windows-build-intel-mkl-program-with-intel-fortran-in-microsoft-visual-studio This
    technology is provided by Intel. So the question should be consulted on Intel fortran related forum. Not Visual Studio Setup forum, setup forum is about install/uninstall Visual Studio.
    Best regards,  
    Barry
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Different Styles in PlainView - Syntax Highlighting?

    Hi,
    I've managed to extend PlainView and looking at old JEdit code I have the syntax highlighting working for the most part. However, at certain times while typing the cursor starts to get way ahead of the text it's typing. And as I backspace on the line the cursor eventually gets closer to the character the closer it gets to the start of the line.
    I'm overridding the "drawUnselectedText()" method in PlainView to do the coloring.
    Here's the code, you can see the call to SyntaxUtilities.paintSyntaxLine() which is JEdit's class to do the drawing.
             * Renders the given range in the model as normal unselected text. This
             * is implemented to paint colors based upon the token-to-color
             * translations. To reduce the number of calls to the Graphics object,
             * text is batched up until a color change is detected or the entire
             * requested range has been reached.
             * @param g
             *            the graphics context
             * @param x
             *            the starting X coordinate
             * @param y
             *            the starting Y coordinate
             * @param p0
             *            the beginning position in the model
             * @param p1
             *            the ending position in the model
             * @returns the location of the end of the range
             * @exception BadLocationException
             *                if the range is invalid
            protected int drawUnselectedText(Graphics g, int x, int y, int p0, int p1) throws BadLocationException {
                System.out.println("p0: " + p0 + " p1: " + p1 + " x: " + x + " y: " + y);
                // Get the start of the element
                int lineIndex = doc.getDefaultRootElement().getElementIndex(p0);
                // Get the element for the line
                Element elem = doc.getDefaultRootElement().getElement(lineIndex);
                System.out.println("lineIndex: " + lineIndex + " elemStartIDX: " + elem.getStartOffset() + " elemEndIDX: " + elem.getEndOffset());
                // Get the line text
                doc.getText(p0, p1 - p0, currentLineText);
                // If highlighting, mark the tokens
                if (marker != null) {
                    Token t = marker.markTokens(currentLineText, lineIndex);
                    x = SyntaxUtilities.paintSyntaxLine(currentLineText, t, styles, this, g, x, y, p0, p1);
                    System.out.println("Painted line at: " + x);
                } else {
                    // No highlighting requested, draw normal text
                    Font defaultFont = g.getFont();
                    Color defaultColor = styles[0].getColor(); // Default color of text
                    g.setFont(defaultFont);
                    g.setColor(defaultColor);
                    x = Utilities.drawTabbedText(currentLineText, x, y, g, this, p0);
                // Set the last line processed
                lastLine  = lineIndex;
                return x;
    Here is the code from the paintSyntaxLine() method:
         * Paints the specified line onto the graphics context. Note that this
         * method munges the offset and count values of the segment.
         * @param line
         *            The line segment
         * @param tokens
         *            The token list for the line
         * @param styles
         *            The syntax style list
         * @param expander
         *            The tab expander used to determine tab stops. May be null
         * @param gfx
         *            The graphics context
         * @param x
         *            The x co-ordinate
         * @param y
         *            The y co-ordinate
         * @return The x co-ordinate, plus the width of the painted string
        public static int paintSyntaxLine(Segment line, Token tokens, SyntaxStyle[] styles, TabExpander expander, Graphics gfx, int x, int y, int p0, int p1) {
            Font defaultFont = gfx.getFont();
            Color defaultColor = Color.black;
            FontMetrics fm = gfx.getFontMetrics(defaultFont);
            int offset = 0;
            while (tokens != null && tokens.id != Token.END) {
                int length = tokens.length;
                if (tokens.id == Token.NULL) {
                    if (!defaultColor.equals(gfx.getColor()))
                        gfx.setColor(defaultColor);
                    if (!defaultFont.equals(gfx.getFont()))
                        gfx.setFont(defaultFont);
                } else {
                    styles[tokens.id].setGraphicsFlags(gfx, defaultFont);
    //                fm = gfx.getFontMetrics();//[tokens.id].getStyledFont(defaultFont);
    //                FontMetrics dfm = Toolkit.getDefaultToolkit().getFontMetrics(defaultFont);
    //                System.out.println("Font Info: CharWidth[" + fm.charWidth(line.array[p1])+"], Max Advance[" + fm.getMaxAdvance()+"]");
    //                System.out.println("Default Font Info: CharWidth[" + dfm.charWidth(line.array[p1])+"], DMax Advance[" + dfm.getMaxAdvance()+"]");
    ////                x = fm.charsWidth(line.array, p0, length);
                line.count = length;
                x = Utilities.drawTabbedText(line, x, y, gfx, expander, p0);
                line.offset += length;
                offset += length;
                tokens = tokens.next;
            return x;
    I'm not sure what the problem is..i thought it might be an issue with the View and drawing multiple font styles. Since plain view only deals with a single font color and size. I tried using LabelView but that seems to need a StyledDocument and I had problems when I tried to use DefaultStyledDocument for my syntaxdocument. I was getting strange offset issues when using the Segment class.
    Here's what I posted: http://forum.java.sun.com/thread.jspa?threadID=780801
    I am using PlainDocument because that seemed to be what everyone was using for a syntax editor..since the structure of the document in a Plain Document is less complex.
    I orginally started out using the setCharacterAttributes() method on the DefaultStyledDocument and letting the views draw the text. That all seemed to work except for the "segment offset" issue. And I wasn't sure where the best spot to get the document to redraw subsequent lines in the case of changing a multiline comment, etc.
    So, everything I read about others attempts for syntax highlighters seems to use either StyledEditorKit with a fixed language set with custom parsing and using the setCharacterAttributes method. Or they use the plaindocument approach with a custom view..(which no one seems to share the source) or the project just simply uses the JEditTextArea directly (which we can't do in our product).
    We don't need multiple fonts per-line.. The document will always use one font face (Arial, Helvetica, etc) but may use different styles per word (bold, italic, etc).
    I thought I'd need to use FontMetrics to get the size of the font and such. But there didn't seem to be a difference in measurements based on the style of the font. (i.,e A bold font has the same charWidth('m') size as a regular style.
    At least that's what my test program showed..
    The other thing I noticed is that when the document is successfully colored and I use the mouse to select a region of text, the style of the text reverts back to normal. I'm sure that's because I only override the drawUnselectedText() method.
    Any ideas? Is there anyone who has successfully done this?
    Thanks,
    - Tim

    I just tried using a proportional font in my editor, and now I'm seeing your runaway-caret problem. Specifically, the caret remains in sync with the text as long as no bold characters are encountered, but it gets noticeably farther out of whack with each bold character it passes. I suspect that, when you measured the charWidth, your FontMetrics object wasn't really based on a bold font, because bold versions of proportional fonts are larger. And of course, the model/view conversion methods assume that the same style of the same font is used throughout the document. I've never had to deal with that problem, since I've always used monospaced fonts by preference, and bold versions of monospaced fonts really are the same size as the non-bold versions. I suggest you do the same, because getting this to work with proportional fonts look like a major hassle.

  • Syntax Highlighting for custom file extensions

    Hi everyone.
    I am currently working on a PHP project, and we are using
    *.thtml files for templates. The file isn't supported by
    Dreamweaver, as it's a fictional file extension. First I couldn't
    even open it with Dreamweaver, but after I added it in
    settings/file types, it worked.
    Now my question - how can I activate syntax highlighting for
    this filetype? It contains HTML and PHP, so it should work with the
    same highlighter as all the other file types do..
    Can someone help me out?
    Thanks.
    - Chris

    Got it
    http://alexle.net/archives/119

Maybe you are looking for

  • HT1595 My Apple TV 2 NOT connected to Ethernet, yet doesn't connect to wifi. HELP!

    My Apple TV 2 is NOT connected through Ethernet, yet it keeps telling me: "To switch to wifi, disconnect the Ethernet cable from your Apple TV". Every time I restart  or reset, it randomly works for a while and then displays the same message again.

  • I am getting error code 0x8002006E when trying to burn a DVD

    Hi, I am running the latest Lion update, on my MB Pro, and keep getting the error code 0x8002006E when trying to burn a DVD. Could this be a dirty lens issue in the drive. I see that many others have had the same problem, but relly cant seem to find

  • Parsing XML with Namespace

    Hi, Can somebody help me with the following:- I have an XMLType in pl/sql as follows: <?xml version="1.0" encoding="utf-8"?> <rapdrpProcessCIN:GetCINRes xmlns:rapdrpProcessCIN="http://rapdrp.com/processcin/transactional/model/1.0/" xmlns:xsi="http://

  • SSL: Portal and Third-Party-Tool

    Hello everybody, I need an advice how to solve the following problem: We integrated a Third-Party-WebTool with the Application Integrator. If we lauch the portal and the special iView with HTTP everything works fine but with HTTPS we get an error mes

  • Using hard drive from my damaged iBook G4 as a Web Sharing server?

    I had the idea that the old hard drive which is now housed in a Pluscom enclosure could be used as a Web Sharing device if I had the right kind of connector. Is that possible?