Sign in to follow this  
Followers 0
nitro322

AutoIt Vim syntax file

38 posts in this topic

#1 ·  Posted (edited)

Edit 05/17/2009: Updated for AutoIt 3.3.0.0, including support for the MANY new UDFs and constants added in recent versions.

Edit 10/09/2008: Updated for AutoIt 3.2.12.1.

Edit 02/24/2008: Updated for AutoIt 3.2.10.0. As usual, this update includes support for all keywords, functions, macros, etc. in the latest stable version of AutoIt.

Edit 06/10/2007: Updated for AutoIt 3.2.4.9. This update includes support for all keywords, functions, macros, etc. in the latest stable version of AutoIt. Version 1.5 of the script, which supported AutoIt 3.2.2.0, is included in the official 7.1 release. To add support for the newer syntax items, simply replace the default autoit.vim file with this new version.

Edit 01/11/2007: Updated for AutoIt 3.2.2.0. This update includes support for all keywords, functions, macros, etc. in the latest stable version of AutoIt. It will also be included in the next official Vim release.

Edit 08/27/2006: Updated for AutoIt 3.2.0.1. This update includes support for all keywords, functions, macros, etc. in the latest stable version of AutoIt.

Edit 05/13/2006: Updated for AutoIt 3.1.1.123-beta. As before, this updates includes all of the new keywords, UDFs, macros, etc. I also added new sections for Autoit Constants, GUI_Constants, and special Send() keys ({ENTER}, etc.). And finally, I modified the variable highlighting so that there's now a clear distinction between user variables and all of the predefined constants, options, etc. Good stuff all around. :-)

Edit 10/07/2005: Updated for AutoIt 3.1.1.78-beta. This includes all of the new keywords, UDFs, macros, etc. I also added a new section for AutoIt options, so that "correct" option entries are distinguished. Also, the syntax file jumped from 301 lines for 3.1.0 to 477 lines for this version. That's a HUGE increase. All I can say is, AutoIt devs, keep on rockin'. :)

The "official" home for this script is the vim.org site. I just updated that page as well:

http://www.vim.org/scripts/script.php?script_id=1239

I'm a big Vim fan, so I was delighted when I found a syntax file AutoIt scripts on vim.org. Unfortunately, it was somewhat outdated, and didn't support any of the new functions and macros in 3.1.0 (especially all of the GUI-related functions). So, I updated the syntax file to support everything in 3.1.0.

Here's a copy, for anyone other Vim fans out there. Installation instructions are included in the script. Enjoy!

HOWTO USE IT (INSTALL):
1) Copy autoit.vim to the file VIM syntax folder
2) Add following line in your filetype.vim file to recognize .au3 files by extension:
    au BufNewFile,BufRead *.au3 setf autoit

Note:  This should be added in the "augroup filedetect" section

autoit_19_vim.zip

Edited by nitro322

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Woot! I was using the old one, until now :)

Thanks

:wq

*edit*

I added the file so you dont have to copy & paste it

autoitvim.zip

Edited by Ejoc

Start -> Programs -> AutoIt v3 -> AutoIt Help File -> Index -> (The Function you are asking about)----- Links -----DllStruct UDFsRSA Crypto UDFs

Share this post


Link to post
Share on other sites

Oh yea one other thing, you probably know this already but it something I forget if I go awhile w/o coding in vi. So new vim'ers might find this helpful:

In your autoit script you can add:

#CS
vi:ts=4 sw=4:
#CE

This will let you place any :set commands in the file so it is formatted the way you want it when it is opened. Handy if you use different tab sizes like I do, then when someone else views it, it is formatted the way you wrote it.


Start -> Programs -> AutoIt v3 -> AutoIt Help File -> Index -> (The Function you are asking about)----- Links -----DllStruct UDFsRSA Crypto UDFs

Share this post


Link to post
Share on other sites

ok, never used vim before, but it looks interesting (and i love trying new text editors). i moved the syntax file to the syntax folder but i'm not sure where to place the specified line in the filetype.vim file.


AutoIt3 online docs Use it... Know it... Live it...MSDN libraryglobal Help and SupportWindows: Just another pane in the glass.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

ok, never used vim before, but it looks interesting (and i love trying new text editors). i moved the syntax file to the syntax folder but i'm not sure where to place the specified line in the filetype.vim file.

<{POST_SNAPBACK}>

I placed mine:

" Automake
au BufNewFile,BufRead [mM]akefile.am        setf automake

" Autoit
au BufNewFile,BufRead *.au3 setf autoit

" Avenue
au BufNewFile,BufRead *.ave         setf ave

and here is my filetype.vim, its the regulare filetype.vim w/ just the autoit modification.

If you havent used vim before... well its somewhat cryptic but very powerful when you learn the commands, plus you have the added benifit of knowing a text editor that exists on almost every OS out there.

And I have a screenshot of what it looks like w/ syntax highlighting and autoit

Edited by Ejoc

Start -> Programs -> AutoIt v3 -> AutoIt Help File -> Index -> (The Function you are asking about)----- Links -----DllStruct UDFsRSA Crypto UDFs

Share this post


Link to post
Share on other sites

I pretty much only use unix and linux. VIM is my favorite editor, emacs second. Good job.


-I am the giver of life and the bringer of death.

Share this post


Link to post
Share on other sites

I've noticed a few items that dont highlight

#notrayicon

some of the _Date

Nothing Major


Start -> Programs -> AutoIt v3 -> AutoIt Help File -> Index -> (The Function you are asking about)----- Links -----DllStruct UDFsRSA Crypto UDFs

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

I just posted a new version of the Vim syntax file, updated for the very latest version of AutoIt (which at this time is 3.1.1.78-beta). This should fix all of the gaps mentioned above, as well as add some new capabilities.

Details and a new download link are included in the top post. Enjoy!

BTW, since a few people have traded Vim tips above, I have one suggestion that's saved me a whole lot of time. Add these two lines to your .vimrc file (second one is optional):

map <F5> :silent ! start %<CR>
map <F6> :silent ! start % /silent<CR>

This lets you execute your AutoIt script directly from Vim by pressing <F5>. I also have a few scripts that I've coded to support /silent switches for unattended execution. Using the code above, I can test this as well with <F6>.

I'm actually in the middle of a huge Vim customization project right now, focusing mostly on Windows and AutoIt support. If anyone's interested in my results when I'm done (configuration, custom packages, etc.) I'd be happy to share. Anyway, time to get some sleep now. Hope someone out there finds this helpful.

Edited by nitro322

Share this post


Link to post
Share on other sites

FYI, I updated the syntax file again. This version covers all AutoIt changes/additions through version 3.1.1.123-beta. I also added some useful new features, so any Vim users out there should check this out. I modified the first post to include details and download links.

Please let me know if you have any questions or issues with it. Thanks.

Share this post


Link to post
Share on other sites

By the way, I just realized that this syntax file is also compatible with Vim's new Omni Completion capabilities available in version 7.0. So, I can begin typing any function name, option, constant, etc. that's declared in the syntax file (and after last night, everything should be included), then hit Ctrl-N to get a list of all matches. This is freakin' sweet!

Of course, it doesn't support the function argument list syntax that Scite4AutoIt does, but it's still very useful nonetheless. Just wanted to pass it on, since I only just discovered this myself.

Share this post


Link to post
Share on other sites

Hi all!

It's my first post here. I just started autoit-ing 2 weeks ago. I'm also a Vim junk, so I'll try to share my tips 'n' tricks

Ctrl-N is not omni-completion, It's only auto-completion of words appearing on the same file and it was already available.

With vim new capabilities, it's very easy to make an omni-completion script.

If you enable omni-completion in autoit files c-x c-o will complete the word with autoit defined functions, or user defined ones. It's not fully functional, but it helps. I've working on a indent file, but it's still a bit crappy :)

one should add these lines (modified unless you use spanish WinXP) in autoit.vim ftplugin

if exists('&ofu')

source C:\Archivos de programa\Vim\vimfiles\autoload\autoitcomplete.vim

endif

Please:rename its extension to .vim XD

Comments are welcome.

I prefer to fine tune it before releasing in vim.org

Hope this helps

autoitcomplete.au3

Share this post


Link to post
Share on other sites

kidd, thanks for clearing up my misunderstanding. I'll play around with this next chance I get (probably over the weekend) and let you know how it works for me.

Share this post


Link to post
Share on other sites

I'll be honest, vim is too much for me. It seems very powerful and all, but its seems far far far too complex for an average coder. Props to you whom can handle it, and nice to see the syntax.


Share this post


Link to post
Share on other sites

It is a bit advanced. It is nice but advanced.

I have used it a few times as I do use Linux on some of my PC's I like it there, but for now I will stick with SciTE.

JS


AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Share this post


Link to post
Share on other sites

new vim'ers...

What, in the 21st century? Unlikely!

-mu

Share this post


Link to post
Share on other sites

#17 ·  Posted (edited)

Ok, some comments. This is my first experience using OmniComplete, so take them with the requisite grain of salt.

It seems to have trouble when being called the first time. For example, if I open an existing AutoIt file, enter a new line and then enter 'str<C-x><X-o>', I get an "Unknown error" erroe message in the status bar. A couple seconds later, the OmniFunc drop-down list appears showing me EVERY function available, automatically selects Abs (since it's the first), and appends Abs to what I had originally typed, so that I'm left with 'strAbs' on the line. If I clear the line and repeat the process, it'll work like a charm, only showing functions that begin with 'str'.

If I initiate omni completion on a function that's already specific enough that there's only one match (eg, 'stringin<C-x><C-o>'), the function name gets completed, but the function syntax is not displayed. The syntax only seems to be displayed when the function is selected from multiple options.

If we're talking about function completion here, maybe it'd be a good idea to automatically add the () as well? Eg, if I select StringFormat from the list, would it be possible to type out StringFormat(), with my cursor in between the parens (shown by the underscore)?

I don't particularly like how the preview window works. Popping up to show me the function syntax is great, but I'd like it to also go away. As it is, I have to hit <C-w><C-o> to make it go away after each and ever OmniFunc call. Would it be possible to automatically hide it after the function entry has been completed? Eg, after the cursor moves outside of the parens, or perhaps when moving to a new line?

Ok, this last one will seem odd. I was poking around through your completion file to see how it works, and noticed that you have all functions detailed on a single line. This is probably the single longest line I've ever seen. So, first of all, props for having the patience to work with that. It would've driven me crazy. ;-). Second, according to some limited testing, it seems that the milista line can be broken up on multiple lines using \. Eg:

let milista = ['Abs ( exp[b][/b]ression )','ACos ( exp[b][/b]ression )',
\ 'AdlibDisable ( )','AdlibEnable ( "function" [, time] )','And',
\ 'Asc ( "char" )','ASin ( exp[b][/b]ression )',
...

This would obviously increase the length of the file significantly, but I find that this single-line approach greatly enhances readability and maintainability. Have you considered changing to this format?

That's all I've noticed so far. Aside from the first two issues they're pretty minor complaints, but you did as for feedback. :-) Thanks again for the script.

Edited by nitro322

Share this post


Link to post
Share on other sites

Wus and JSThePatriot, as you said, Vim is quite advanced. I won't deny that. I was first exposed to it in Linux, and for the first couple years all I really knew how to do was basic editing tasks. However, one weekend I decided to take the time to really learn Vim. I read through a couple quick reference guides, spent some time tweaking a personalized .vimrc file, and jotted down some notes in a "tips" file that I can refer to whenever I want to jog my memory on how to do something in particular. After that, things got much easier. :-)

I also go to the point where I wanted to use a common editing environment on any platform I'm using, and Vim is a perfect fit here. This is why I spent the time working on that AutoIt syntax file - the thought of using a separate editor just for Vim was not a pleasant one. I also spent some time tweaking my .vimrc file specifically for a Windows environment as well, so I find Vim pretty darn comfortable under Windows now.

If anyone's interested, I'd be happy to share my Windows .vimrc file. Even if you don't care to use all of the options I have set in it, it's well documented and should give you some ideas for fine-tuning your own setup. Of particular use are some AutoIt-specific setting that I included:

setfiletype autoit
set omnifunc=autoitcomplete#Complete
map <F2> :exe ':silent ! start "" "'.$PROGRAMFILES.'\AutoIt3\AutoIt.chm"'<CR><CR>
nmap <F5> :silent ! start "" autoit3.exe "%"<CR>
nmap <S-F5> :silent ! start "" autoit3.exe "%" /silent<CR>
nmap <F6> :silent ! start "" aut2exe.exe /in "%" /comp 4 /nodecompile<CR><CR>
iabbrev mbx msgbox(0, 'Test',)<Left>

This automatically enables syntax highlighting and omni completion, has <F2> launch the help file, <F5> execute whatever script I'm editing, Shift-<F5> execute the script with the /silent argument (common for my personal scripts), and <F6> compile the script. I also took advantage of Vim's abbreviation capabilities to create a keyword 'mbx' that automatically expands to a msgbox function. Very handy for debugging. :-D

I know that Vim is not for everyone. If you're willing to try it out, though, spend a little time looking into the options available. It'll greatly improve the experience. Also, let me know and I'll be more than happy to send/post my own .vimrc file.

Share this post


Link to post
Share on other sites

cant say is ill ever use vim that much, but Id love if you posted the vimrc file, cant hurt to try it out for a while


Share this post


Link to post
Share on other sites

Here you go.

My _vimrc:

http://www.legroom.net/~jbreland/transfer/.../support/_vimrc

My _gvimrc (specific settings for GUI):

http://www.legroom.net/~jbreland/transfer/...support/_gvimrc

I also created an installer for VIM under Windows. I find it significantly easier to use than the standard Windows distribution, and it also (optionally) includes my own tweaks. If you'd like to try that as well, you can grab it here:

http://www.legroom.net/~jbreland/transfer/...m_7.0/vim70.exe

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0