Thursday, March 3, 2011

smali syntax highlighting for vim

i've been doing a lot in linux lately and was working on a smali syntax highlighting file for vim, but vierito5 posted a comment with a link to Jon Larimer, who beat me to it. here's the link: (mirror)

it's vim so there are 20 different ways to get it working. google around if this doesn't work, i will be no help. here is how i did it:
mkdir ~/.vim
echo au BufRead,BufNewFile *.smali set filetype=smali >> ~/.vim/filetype.vim
mkdir ~/.vim/syntax
cp smali.vim ~/.vim/syntax


  1. Thanks for posting! Smali code looks much better now!

  2. Thanks for the work, but I found a bug.
    If you have a line similar to the following

    .field public static final CALENDAR:Ljava/lang/String; = ""

    the dalvikName matches "ENDAR:Ljava/lang/String" which is wrong.
    I fixed it including the 'L' and the ';' in the highlight and using this syntax rule:

    syn match dalvikName "\<[A-Za-z0-9_\/]\+\>;"

    Hope it helps. Bye

  3. Ops... I forget an 'L':

    syn match dalvikName "\;"

  4. It cuts out a part. The 'L' goes between the lower sign (<) and the open bracket ([)

  5. thank you HoX, i shall e-mail the maintainer about this change. from what I understand, it should be, as you suggest:
    syn match dalvikName "\;"

    it also seems there are some valid characters not supported by this regex, as per the java specs here:

    namely, the currency symbols and other unicode characters.


Do NOT post about or link to specific apps!