[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.

Similar Messages

  • 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

  • [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)

  • 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)

  • [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)

  • 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)

  • Acrobat 8 Pro-how do I search 1000's of pdf's & yellow highlight all occurrences of 12 words/phrases

    my computer: windows xp pro svc pack 3, dual processor, 2 gig ram
    software: Adobe Acrobat8 Pro. Problem: I have 8,000 1-2 page pdf's in (1) directory, that are all located within 5,000 sub-directories. All were converted by Acrobat fm *.txt docs in the same directories, so all are ocr text searchable, but the time to search all docs and manually highlight each (frequent) occurrence in thousands of docs, then repeat the process for the next 11 words/phrases will take forever.
    If anyone knows how to batch process search for multiple words/phrases AND have Acrobat automatically highlight and index each occurrence, that would be awesome and greatly appreciated.
    desones

    Hi David, I've developed a script that does this (well, it does it for a single document, but can easily be used for multiple ones using a batch process, and the dialog boxes can be replaced with a pre-defined piece of text).
    See here for some more info: http://try67.blogspot.com/2008/11/acrobat-highlight-all-instances-of.html
    and contact me by email to discuss it further.

  • 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] 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"?

  • Syntax Highlighting w/ Swing Text Package

    I have a question for you that I hope ever so much that you could answer just in the most abstract sense, I will figure out the code from what you have said hopefully. Any relavent parts that you think I should know, please point out.
    My question is, I'm trying to implement Syntax Highlighting for a code editor in Java (yes I know, like everyone else. It would REALLY be helpful if you did an updated Demo of a SyntaxEditor for JDK 1.4 BTW) anyway, I have already implemented Syntax Highlighting by overriding the PlainView and changing its drawLine method to parse the line, find the key words then draw them accordingly. However I cannot get over the sinking feeling that there is a better way to do this in JDK 1.4, I'm not worried about backward compatability. I'm only interested in the "sexiest" way to do this with Java. I started looking into the GlyphView, and that seems more of what I want, it has more control over the text elements and strong drawing abilities, I also noticed the GlyphPainter1 and GlyphPainter2, I tried to extend GlyphPainter2 and use it with my extended GlyphView and just change its paint method to parse the lines, but the class complains about not being public, even though in the source its class definition is "public class GlyphPainer2 extends GlyphView.GlyphPainter" which confused me.
    But at any rate, my basic question is how would YOU, implement Syntax Highlighting (code coloring) if you could do it from scratch with all the facilities of the 1.4 JDK. ALso, should I look into the Java2D API or is this over kill for what I'm doing? I just need a basic code color'er, nothing fancy. But I need the fonts and styles to be able to change, that's all. And international support would be nice.
    The type of answer I'm hoping for is something like "Create a new editor kit and then extend the GlyphView class and override its XYZ method to do your line parsing and then override the ABC method to do the actual painting of the line, this is the best way to do this in java"
    Best wishes,
    -rsk123

    I am searching for text highlighting code in java during 7 days.
    And I also agree with Mr. rsk123 's thought.
    I want to make editor to highlight code using java's general text package.
    But I can't find good source or class to satisfy me.
    Some code run well but it's not use the original java text package.
    Some code was made by using java text package but have a bug and not run pefectly.
    Now, I must choice a code for text highlighting.
    But until now I can't find a free code or comecial code for it.
    Anyway, I summarize my suffing result until now.
    ** I have stuied,
    . About java's text package in Swing Connection site.
    It's useful a little to understand the text package structure.
    (http://java.sun.com/products/jfc/tsc/articles/index.html)
    . How to make own EditorKit in 'Java Swing' book chapter 24.
    I think it's good. But difficult to read.
    (published by O'REILLY. Robert Eckstein)
    ** I have found program and have tested.
    1) JEdit (http://www.jedit.org)
    2) Jext(http://www.jext.org)
    3) Sun's sample using the JavaEditorKit
    (http://java.sun.com/products/jfc/tsc/articles/text/editor_kit/index.html)
    4) Ostermiller's Syntax editor (http://ostermiller.org/syntax/editor.html)
    5) j (http://armedbear-j.sourceforge.net/)
    6) je 1.66 (http://mathsrv.ku-eichstaett.de/MGF/homes/grothmann/je/)
    *** Detail descriptions of the test
    1. May be run well but not use java text package.
    ==> JEdit (http://www.jedit.org), Jext(http://www.jext.org)
    - I executed JEdit and Jext program. it works very well.
    I think It's greate programs.
    - The editor class for these programs are
    org.gjt.sp.jedit.textarea.JEditTextArea class.
    The JEditTextArea class extends JComponent, not java text component.
    - JEditTextArea class started from 'jedit syntax package project'.
    You can download the syntax package if you only use syntax highlighting
    from http://syntax.jedit.org/ .
    - JEdit and Jext use for editor 'jedit syntax package' but have upgrade that
    package their own effort(may be)
    - For me, It's an only product run well without error.
    But unfortunately it's not use java text component.
    So I hesitane to use it.
    Because I should make almost code to support general editor function which
    supported in JTextComponent.
    2. Provided by Sun's developer site.
    ==> JavaEditorKit (http://java.sun.com/products/jfc/tsc/articles/text/editor_kit/index.html)
    - It's made using JEditorPane. Great!!
    And have a good architecture. (I think)
    - But It use Scanner class which located in tools.jar package and
    have a bug which not supporting well comment syntax /* */.
    (Refer to http://developer.java.sun.com/developer/bugParade/bugs/4323090.html)
    Futhermore it display terrible exception message when typed "/*" string
    in the end position of java file. (I tested it)
    - I heard in the forum, someone made the own scanner class.
    (http://forum.java.sun.com/thread.jsp?thread=120564&forum=57&message=316083)
    He said,(he = rofshi)
    I wrote for my purposes a scanner based on the StreamTokenizer
    cl*** and set a corresponding object in the JavaView cl*** of
    the JavaKitTest.
    Then I placed the method of my Scanner cl*** that parses the
    given string and paints tokens in the method drawUnselected
    Text (instead of previous code).
    Of course, I erased all of the previous code related to the
    java Scanner.
    - For me, I like this style code and want to use it.
    But Scanner class have some bug and I can't cure that bug. Terrible...
    3. using JTextPane
    ==> http://ostermiller.org/syntax/editor.html
    - At first it's too slow.
    My computer is PentiumIII 350MHz Ram:256M Windows2000Por
    But when I press pgDown key quickly the display couldn't follow it.
    - And may be not support unicode.
    When I typed international code, exceptions displayed.
    (too much exceptios. may be caused repeating by thread.)
    (ArrayIndexOutOfBoundsException in JavaLexer.java 1022 ?)
    - For me, supporting international code is essential.
    So I can't use it.
    4. Do work well. But it use not understandable code for me.
    (not use general java text package)
    1)http://armedbear-j.sourceforge.net/
    2)http://www.rene-grothmann.de
    *** Finally, I have plan to make my own code using Mr rsk123's idea.
    (using GlyphView in jdk1.3 or jdk1.4)
    *** If you have a good information for text highliting of free code or
    comecial code pleas notify me.
    My address is [email protected]

  • Highlight All Matching Variables (mark occurrences)

    I just downloaded the latest CFB to try out. I have had the ability to have all matching variables highlighted in Eclipse for as long as I can remember. It works in CFEclipse, but I cannot figure out how to double click on text and have all matching text found.
    It seems that "mark occurances" in the main prefs->general->editor->annotations does nothing and there are no annotations available in CFBuilder standalone. In the toolbar, the go to next occurance drop down doesn't work either. Am I missing something or do I scrap this IDE?

    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.

  • 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.

  • How to enable syntax highlighting for jspf files on Dreamweaver CS5.5 on Mac

    I ran into an issue where I couldn't get the color coding (color coding style) for java server pages fragments (.jspf) files to show syntax highliting.
    I followed the adobe instructions on Changing and adding file extensions recognized by Dreamweaver without any luck.
    Here is the solution that worked for me:
    On a Mac:
    1. Edit the /Users/YOUR USER/Library/Application Support/Adobe/Dreamweaver CS5.5/en_US/Configuration/DocumentTypes/MMDocumetTypes.xml
    Note: the Adobe instructions tell you to edit /Applications/Adobe Dreamweaver CS5.5/Configuration/DocumentTypes/MMDocumetTypes.xml (Editing this file didn't do anything for me, so you need to change the file above instead)
    Find,
    <documenttype id="JSP" servermodel="JSP" internaltype="Dynamic" winfileextension="jsp,jst" macfileextension="jsp,jst" file="Default.jsp" writebyteordermark="false" mimetype="text/html">
    Replace with,
    <documenttype id="JSP" servermodel="JSP" internaltype="Dynamic" winfileextension="jsp,jst,jspf" macfileextension="jsp,jst,jspf" file="Default.jsp" writebyteordermark="false" mimetype="text/html">
    2. Edit the /Users/YOUR USER/Library/Application Support/Adobe/Dreamweaver CS5.5/en_US/Configuration/Extensions.txt
    In the All: section on top add the jspf extention right after jsp in my example it looked like this
    HTM,HTML,SHTM,SHTML,HTA,HTC,XHTML,STM,SSI,JS,JSON,AS,ASC,ASR,XML,XSL,XSD,DTD,XSLT,RSS,RDF, LBI,DWT,ASP,ASA,ASPX,ASCX,ASMX,CONFIG,CS,CSS,CFM,CFML,CFC,TLD,TXT,PHP,PHP3,PHP4,PHP5,PHP-D IST,PHTML,JSP,WML,TPL,LASSO,JSF,VB,VBS,VTM,VTML,INC,SQL,JAVA,EDML,MASTER,INFO,INSTALL,THEME,CONFIG,MODU LE,PROFILE,ENGINE,SVG:All
    and I added the jspf and it looks like this now,
    HTM,HTML,SHTM,SHTML,HTA,HTC,XHTML,STM,SSI,JS,JSON,AS,ASC,ASR,XML,XSL,XSD,DTD,XSLT,RSS,RDF, LBI,DWT,ASP,ASA,ASPX,ASCX,ASMX,CONFIG,CS,CSS,CFM,CFML,CFC,TLD,TXT,PHP,PHP3,PHP4,PHP5,PHP-D IST,PHTML,JSP,JSPF,WML,TPL,LASSO,JSF,VB,VBS,VTM,VTML,INC,SQL,JAVA,EDML,MASTER,INFO,INSTALL,THEME,CONFIG,MODU LE,PROFILE,ENGINE,SVG:All
    That's it, Quit Dreamweaver and open it up again. Open the .jspf file and see the color coding (syntax highlighting)
    Hope this helps you and seves you time figuring it out. If this helped, do a good thing, next time you figure something out, tell others about it to save their time too, like I did. Enjoy.

    TheGrandNabib wrote:
    I don't seem to have a user Library folder, my only Library folder is on the same level as my Users folder.
    From Locating your personal configuration folder in the Dreamweaver FAQ:
    In Mac OS X (Lion and Mountain Lion), open Finder and press Shift-Cmd-Go. Type ~/Library/Application Support in the dialog box, and click Go. You should then be able to find the configuration folder.

  • Syntax highlighting in JSPs: How do they do that?

    In this forum, for example, if write code tags you write Java code that is automatically highlighted:// a comment
    public static void Main( String args[] )
       /* blah blah blah*/
    }which is great!
    I'd like to know how it's done, esp if there's a generic prcedure to it as I'm developing a site that will require syntax highlighting for several languages.
    Thanks JSP gurus!

    You can do this yourself. Create a table of key
    words. You can scan
    through the text to get the individual words. If they
    are in your
    table then add the bold tags. The trickiest part
    would be finding
    the end of comments, but this is not too difficult
    either.Yeah, this really isn't too difficult, having finished something myself. With comments, if you open with a //, you can simply consider everything between that and a newline as a comment, and with the /* comment, everything between it and a */ is also a comment.
    If all goes well, and you plan everything out, you should be able to place all necessary code formatting tags into the code with one iteration.

Maybe you are looking for

  • HT1495 how to delete apps when using one account for iphone 4s and ipod4, can delete from phone but not ipod

    How do we delete apps from ipod 4 when using same account as iphone 4s, we can delete from the phone but not the ipod, and when i get an app on my phone it automatically comes up on the ipod and visa versa, now ipod is full,

  • Calling RFC-enabled function as web service using XI 3.0

    Hi, I have a problem when trying to use web services (sending a soap-req. to XI 3.0 based on the generated WSDL from Integration Directory). According to the message monitoring, all steps in the central pipeline executes just fine until the last step

  • Weekly Group Total and associated YTD total

    Hello, I need to show current week group total and total year to date of the same group.  My columns are Model, Department, Issue.  Currently, the report is grouped on Model, Department and Issue with a filter for date.  Can this be done?   Thank you

  • Volume Bar wont show

    Bottom Line: volume bar wont show ive tried cleaning the dock connecter with a tooth brush, with a paper towel, blowing it, nothings working Ive also tried erasing, restoring, reseting, turning the phone on/off, going to settings > music > sound chec

  • Identical Usernames Cause Permission Issue w/ Officejet via Bonjour

    Mac Mini shares the officejet via Bonjour - default user is 'Bob.' MacBook default user is also 'Bob', it can see and connect to the officejet, but when you look at the local queue there is message saying "Can't Get Status - Forbidden!" Other machine