Thursday, June 19, 2014

Custom Vorax Status Line

Vorax does a pretty well job when it comes to display the status line of the output window. It shows a lot of stuff like: the current output funnel (PAGEZIP, VERTICAL or TABLEZIP), the APPEND or STICKY flag and, of course, the current Oracle connection.


However, it looks a bit too minimalist, especially with all these nice statusline management plugins around:
I've played a little with all the above plugins and in the end I decided on Airline. Even Lighline is more KISS oriented, I didn't want to spend too much time on configuring everything: NERDTree, quickfix window etc. Unlike Lighline, Airline is designed to be extensible and plugins like NERDTree, vim-fugitive etc. may contribute with their own airline extensions in order to configure the look of the status line.

So, below is Vorax with airline:


It'a nice improvement, and the information from the status line is better highlighted. In addition, I configured the current Oracle connection to be also displayed in a Vorax buffer (sql or plsql), just to be sure we know where we're connected to, especially if the output window is not shown (it can be toggled, I'm sure you know this).

So, let's see how we can achieve this. I put the following in my .vimrc file:

" Let me choose the statusbar
let g:vorax_output_force_overwrite_status_line = 0

function! VoraxOutputFlags()
  let funnel = ["", "VERTICAL", "PAGEZIP", "TABLEZIP"][vorax#output#GetFunnel()]
  let append = g:vorax_output_window_append ? "APPEND" : ""
  let sticky = g:vorax_output_window_sticky_cursor ? "STICKY" : ""
  let heading = g:vorax_output_full_heading ? "HEADING" : ""
  let top = g:vorax_output_cursor_on_top ? "TOP" : ""
  return join(filter([funnel, append, sticky, heading, top], 'v:val != ""'), ' ')
endfunction

function! VoraxAirPlugin(...)
  let session = '%{vorax#sqlplus#SessionOwner()}'
  let txn = '%{vorax#utils#IsOpenTxn() ? "!" . g:vorax_output_txn_marker : ""}'
  if vorax#utils#IsVoraxBuffer()
    let w:airline_section_b = get(w:, 'airline_section_b', g:airline_section_b) . session
    let w:airline_section_warning = get(w:, 'airline_section_warning', g:airline_section_warning) . txn
  endif
  if &ft == 'outputvorax'
    let lrows = '%{exists("g:vorax_limit_rows") ? " [LIMIT ROWS <=" . g:vorax_limit_rows . "] " : ""}'
    let w:airline_section_a = '%{vorax#utils#Throbber()}'
    let w:airline_section_b = airline#section#create_left([session])
    let w:airline_section_c = 'Output window'
    let w:airline_section_x = ''
    let w:airline_section_y = g:airline_section_z
    let w:airline_section_z = airline#section#create(["%{VoraxOutputFlags()}"])
    let w:airline_section_warning = get(w:, 'airline_section_warning', g:airline_section_warning)
    let w:airline_section_warning .= airline#section#create([lrows, txn])
  elseif (&ft == 'connvorax') || (&ft == 'explorervorax') || (&ft == 'oradocvorax')
    let w:airline_section_a = ''
    let w:airline_section_b = ''
    let w:airline_section_c = (&ft == 'connvorax' ? 'Connection Profiles' : &ft == 'explorervorax' ? 'DB Explorer' : 'Oracle Documentation')
    let w:airline_section_x = ''
    let w:airline_section_y = ''
    let w:airline_section_z = ''
  endif
endfunction
call airline#add_statusline_func('VoraxAirPlugin')

" Let the statusbar as it is for inactive windows
let g:airline_inactive_collapse=0
That's all! The next logical step would be to defeat my lazyness and submit a real Airline extension for Vorax. I'm going to add this to my procrastination list.

Tuesday, October 22, 2013

Vorax 4.0 Preview

Well, it's been awhile since I posted my last Vorax article here. Funny enough, it was about Vorax 3.0 improvements ideas. Meanwhile Vorax 3.0 was released into the wild, but at that time I didn't want to make such a big fuss because I wasn't sure it had the right implementation.

Now Vorax4 is in beta-testing and I'm quite pleased by the results: it's much faster, it has a smarter code completion and it's more KISS compliant.

So, please check it on: http://talek.github.io/vorax4/
Your feedback is highly appreciated!

Tuesday, May 3, 2011

Ideas for a completely rewritten VoraX 3.0

One year ago the first version of VoraX was released. It initially started as a proof of concept tool but, step by step, evolved into a more complex application. Unfortunately, at that time, my experience in writing Vim plugins was a bit poor. Now, when I'm looking to the code I wrote for implementing several functionalities I don't feel very proud: it's rude, not DRY and hard to maintain/understand. That's one of the reasons I think VoraX 3.0 should be a completely rewritten version. There are also some new features/improvements that I have in mind, the most important ones being:
  • a better DbExplorer tree. The main improvement I see here is the possibility to register custom plugins to provide additional functionality. For example, an user may write a very simple plugin to display DBMS_SPACE statistics for various objects within the tree. The same functionality provided by NERDTree via plugins may be also implemented for DbExplorer.
  • a tree based connection profile window with a XML file behind to store all profiles. I think this would be better than the actual implementation where these profiles are spread out in several files which, of course, is not very intuitive.
  • all VoraX config files should reside in $HOME/.vorax instead of directly in $HOME, messing up the user's home folder.
  • the possibility to configure one output window per tab. Sometimes is useful to open another tab and querying the database from there while preserving the old tab, including the output window.
  • text HTML output. The idea is to display the output of a query in a more friendly format without a lot of "column format" trickery. The main benefit would be that all columns will have the right size. The drawback is that the user must wait for the query to finish and only after that the output will be displayed. That's different than the way it is now when you have immediate feedback and the result is spit out as soon as it is available into the sqlplus out buffer. However, the user should have an easy option to switch from one type of output to another.
  • support for ruby 1.9? I don't know if both versions, 1.8.7 and 1.9 should be supported or not. The problem is that the PTY mechanism used by VoraX for Unix systems has changed in ruby 1.9. As far as Windows platforms are concerned, I must check if win32-api.gem can be used on ruby 1.9. However, being prepared for ruby 1.9 doesn't sound like a bad idea, does it?
  • move to GitHub. I already created a repository for VoraX 3.0. Despite I have little experience with this versioning system I'm eager to learn it because it seems more open to collaboration.
  • completion for various VoraX commands. For example, the :VoraxConnect command may provide completion based on registered connection profiles.
  • new commands. It would be nice to have the possibility to open packages or triggers directly using VoraX commands instead of navigating through the DbExplorer. This may be really handy, especially combined with a smart completion.
  • testing. It would be really nice to have a regression test suite or something in order to validate that the changes made to the code doesn't hurt the current functionality. There are some VIM plugins which may be used to test VimL code but I don't have any experience with any of them. Nevertheless, investing effort in this area would be really helpful.
If you have other ideas (or useful hints) please let me know. VoraX is an open source project therefore everybody is welcome to contribute.

Friday, April 1, 2011

VoraX on MAC OS

A few weeks ago I received an issue about the fact that VoraX doesn't work on MAC OS. For me it wasn't such a big surprise as I never tested VoraX on MAC OS, simply because I didn't have this platform available.

"It's time for action!" I said to myself having in mind the possibility to install this OS as a virtual machine and test VoraX on it. So, I grabbed a vmware MAC OS image and I tried to run it using vmware player. It's not a big deal, isn't it? Well, apparently this can't be done on my old PC because a CPU with VM-x stuff is needed. Damn it! Yeap, it's time for a CPU upgrade. I ordered an Intel Dual Core Duo 8400 and I patiently waited to arrive. Yesterday the new CPU was on my desk, ready to be installed. The installation was a piece of cake, the new CPU being recognised by my old motherboard except for the virtualization feature, that VT-x I was looking for. Buying a new motherboard didn't sound very appealing so I decided to look for a BIOS update. My MB is a Gygabyte and it already had the last stable BIOS installed. There was also a beta firmware available but that "beta" seemed a little bit scary. However, I had nothing to loose therefore I decided to go with the beta version. Aaand, after the upgrade, what a surprise! A brand new option called "Virtualization" was available in BIOS. Yesss! With this VT-x feature available I was able to run the vmware MAC OS image.

Hmmm... my very first time on MAC OS. It looks nice, kind of glossy but nothing to complain of. Well, maybe my lack of knowledge about this OS. However, having previous experience with a *NIX system is a big advantage. As soon as you get a terminal window it's like an usual *NIX box. I was able to check for ruby version and to install antlr3 gem. Mac OS 1.6.X is quite ready for VoraX. Then I downloaded macvim which has ruby support enabled. Then I installed the oracle instant client. I was a little bit surprised about the fact that the last available version for MAC is 10.2.0.4 and not 11.2.0.2. In the end I installed VoraX (the linux way into the ~/.vim dir) and I created a very basic .vimrc file:

set nocompatible
filetype plugin on


Below is the final result.


Yeap, VoraX on MAC. It's time to update the site/documentation to let people know that VoraX is also supported on MAC. Have fun guys!

Monday, January 24, 2011

Knock, Knock... Who's there?... VoraX 2.8

Hey folks! I feel bad for VoraX 2.7. It really had a short life, just a week... If you're the kind-hearted type then you may choose to keep VoraX 2.7 and make it happy. But, would you be also happy without these new VoraX 2.8 goodies? Well, let's see...

First of all, VoraX 2.8 is faster because it has a redesigned OS interface. This becomes obvious especially on Cygwin. Till now, there was an annoying delay immediately after a statement was finished executing. That was because another call was made in order to get connection information, which was further used to update the VoraX title. In VoraX 2.8 this is no longer true, the connection info is gathered in one step, as part of the statement execution itself.

Another useful feature is the monitoring capability of the results window. If you have a long running statement and you want to be notified when it's done then this is perfectly doable in VoraX 2.8. And because a picture worths one thousands words, below is a screen-shot showing this feature on my Ubuntu box:


Just put the following snippet into your .vimrc:
" Nice notification for my monitored long runinng queries
function VoraxNotification()
  let cmd = "notify-send -i 'terminal' 'VoraX' 'Execution of your monitored statement on ". 
            \ &titlestring . " has just finished.'" 
  exe 'silent! !' . cmd
endfunction
let g:vorax_notify_command = "call VoraxNotification()"

On Windows I have no idea how to configure this but I guess there are some "cool" command line programs to display those annoying balloons in your tray.

And that's not all. Did you noticed the re-polished status line for the results window? Much better, isn't it?

As far as bug fixes are concerned I recommend you to upgrade because this version has a fix for a quite critical bug reported by Shaun Batterton. The bug description goes like this: if your statement has an "end" somewhere in between then a "/" will be appended. For example, if you execute something like:

alter tablespace muci_tbs add datafile size 100m autotextend on;

behind VoraX will rewrite (in a wrong way because of the bug) as:

alter tablespace muci_tbs add datafile size 100m autoextend on;
/

I know it's stupid but because the statement has an "end" (in autoextend) we end up adding two datafiles which, of course, is not what we've meant. Thanks Shaun for this bug report.

There's also another bug fix in connection with virtualedit setting but that's not something to pay too much attention in this post.

Okey, that's all. You may find additional details about these new features within the VoraX updated documentation.

Monday, January 17, 2011

VoraX 2.7 Released

By this post I want to let you know that VoraX 2.7 is available for download. The most important improvement this version brings out to light is a better way to define your key mappings for VoraX commands. No more VoraX event handler bullshit! Starting with this version you may define these mappings using a few g:vorax_key_for_* global variables. For example, my vimrc file contains now the following:

let g:vorax_key_for_exec_buffer = "<F8>"
let g:vorax_key_for_exec_sql = "<Leader>e"
let g:vorax_key_for_exec_one = "<Leader>1"
let g:vorax_key_for_describe = "<Leader>d"
let g:vorax_key_for_describe_verbose = "<Leader>D"
let g:vorax_key_for_explain_plan = "<F5>"
let g:vorax_key_for_explain_only = "<S-F5>"
let g:vorax_key_for_fuzzy_search = "??"
let g:vorax_key_for_goto_def = "gd"
let g:vorax_key_for_toggle_logging = "<Leader>l"

Of course, you're free to choose whatever you want. You are no longer bound to the default VoraX key mappings.

There are also a couple of bug fixes. They are detailed into the changelog.

Wednesday, January 5, 2011

VoraX on Vim 7.3

Apparently the VIM pack from Lucid repository has a nasty bug which causes VoraX to crash on my Ubuntu box with VTALRM signal (Virtual timer expired). I can't reproduce this behavior at will but it happens quite often to encounter this crash which, of course, is very annoying as I also loose all the work I did into my unsaved buffers.

So, I decided to compile the latest VIM version (7.3 at the time of writing this post) in order to get rid of this bug. Below are the steps I've done:

1. remove the actual VIM packages:
FITS\alec@tia ~ $ dpkg --list | grep vim
vim-common                            2:7.2.330-1ubuntu3                    Vi IMproved - Common files
vim-gnome                             2:7.2.330-1ubuntu3                    Vi IMproved - enhanced vi editor - with GNOM
vim-gui-common                        2:7.2.330-1ubuntu3                    Vi IMproved - Common GUI files
vim-runtime                           2:7.2.330-1ubuntu3                    Vi IMproved - Runtime files
vim-tiny                              2:7.2.330-1ubuntu3                    Vi IMproved - enhanced vi editor - compact v

FITS\alec@tia ~  # sudo apt-get remove vim-common vim-gnome vim-gui-common vim-runtime vim-tiny

2. install dependencies
sudo apt-get install libncurses5-dev libgnome2-dev libgnomeui-dev \ 
libgtk2.0-dev libatk1.0-dev libbonoboui2-dev \ 
libcairo2-dev libx11-dev libxpm-dev libxt-dev

3. download vim7.3 from: ftp://ftp.vim.org/pub/vim/unix/vim-7.3.tar.bz2

4. unpack the archive: tar -jxvf vim-7.3.tar.bz2

5. configure, make and install:
cd vim73/src/
./configure --with-features=huge --enable-gui=gnome2 --enable-rubyinterp
make
sudo make install

Simple as that! VoraX seems to be stable now. I didn't experience any VTALRM crashes since then.

Update 1: Ups, today I received a VTALRM crash. I think the problem is not Vim but ruby itself. On Ubuntu ruby is compiled with libthread which may cause troubles. I will try with a pthread-less ruby to see if it makes any difference.

Update 2: I asked Vim community for help here. With the provided patch I didn't experience any new VTALRM crashes.

Update 3: The fix is included in Vim 7.3.118.

Tuesday, December 14, 2010

VoraX 2.6 Released

Vorax 2.6 is available for download. It has two small improvements and a few bug fixes. The first improvement is the possibility to configure the quick fix window geometry. You may use the g:vorax_quickfixwin_command variable to setup the layout of this window. Thanks koelner.r for this suggestion.
The second improvement allows to define your custom function to be called after a statement is executed in VoraX. Using this feature you may define post-processing actions, like notifying the user when a long running query has finished or to apply post formatting settings for the result window. Thanks Spratek for suggesting this improvement. For additional details about the way this feature is supposed to work please see the docs.

Friday, October 29, 2010

Keep your VIM updated with VAM

I'm a huge fan of VIM. In fact, that's one of the main reason I've developed VoraX. However, I still feel that I have a lot to learn, but that's the beauty of this beast.

One thing that I always considered annoying is the installation of a fresh VIM. I use Unix and Windows boxes. On both VIM is a MUST-HAVE editor. To install the standard package is not a big deal: you just use your distro repository or, on Windows, you download the installer, next, next, next and you're done! But, wait a minute! Where are my killer plugins, and those neat mappings I customized for myself? And hey, I don't want the default color-scheme either. Okey, it's clear I have a problem because the installation of VIM cannot be considered finished until I have all my plugins and settings in place.

The quick and dirty method would be to copy all plugins along with the .vimrc file from a computer where's everything is in place. Whiles this always work without a problem it has a major drawback: it's difficult to maintain all these files across many computers. For example, at work it happens to discover a new cool vim setting which I put it right away in my .vimrc. Then I go home and when I open VIM from my personal computer I discover it looks different. This means I have to access the .vimrc file from my office and then to manually synchronize those files. That's so ugly!

So, at that point was clear that I needed a central repository to put those files and to access them in a shared way. I goggled to see how other people solved that and I find out that many prefer using a SCM repository. That seemed to be a solution, so I subscribed to a free SVN account on http://www.xp-dev.com/ and I put all my plugins and my .vimrc file there. This approach was fine but I found it cumbersome to use. First of all, installation of a new plugin was not so easy because you had to download it, to put it into the right location under your vim runtime path and then to also add those files to the SVN and then to commit. As far as .vimrc was concerned it also happened to change something and then to simply forget to commit the change. A SCM is the right solution for source code but not so good for my VIM plugins/.vimrc management... so I kept searching...

The good news is that I ended up with a nice solution I want to share with you. First of all, forget SVN and other source repositories and give a shot to Dropbox. It is a file sharing repository with automatic synchronization across computers. You may access your files from Windows, Unix, Mac... basically from everywhere. A change on a file maintained by Dropbox is automatically synchronized so there's no need to commit anything. And the basic functionality is provided for free. So, we have a nice shared repository where we are going to put our .vimrc file.

Usually vim expects to find .vimrc in a certain location which, for sure, is not into the Dropbox folder. Nevertheless, you can always create a symbolic link for your .vimrc to the one from your Dropbox folder. For example, on my Ubuntu box I can use:
cd ~
ln -s Dropbox/.vimrc .vimrc
On Windows it's not so easy because of the leak of the symbolic link functionality for files. The only option you have is to create hard links. For example, on my XP system I've downloaded the coreutils package and then I've created a link like this:
ln "c:\Documents and Settings\alec.FITS\My Documents\My Dropbox\.vimrc" "c:\Documents and Settings\alec.FITS\.vimrc"
It's also possible to use fsutil tool:
cd %HOME%
fsutil hardlink create .vimrc "C:\Documents and Settings\alec.FITS\My Documents\My Dropbox\.vimrc"
There is a problem however with this hard link on Windows: the changes on the underlying dropbox file are not correctly propagated. My assumption is that Dropbox synchronize the changed files by deleting the old file and recreating it afterwords. The side effect is that our hard link is broken and will not point to the dropbox .vimrc file anymore. The only solution I found is to create a dummy .vimrc file which source the .vimrc file from my dropbox folder. For example, you may put this into your $HOME/.vimrc:
exe 'source ' . expand('$HOME') . '\My Documents\My Dropbox\.vimrc'
Great! Now, we have one single copy of the .vimrc, shared by more than one computer. You might say: hey, let's put the plugins too into our nice Dropbox. We can, but I have a better solution. Let's use a plugin management engine for Vim.

There are a few such vim addons which provide plugins management like: Vimana, Vim Script Management System or Vundle. However, the best I like is VAM (Vim Addons Management). It's actively developed and you get quick feedback in case of troubles. Mark Weber has done a great job with this add-on. You can automatically install/update various plugins and because VAM puts every new installed plugin into its own directory is quite easy to uninstall them by simply deleting the corresponding folder. Those who already use Pathogen should be familiar with this concept.

Now, the best thing out of this is the fact that you can basically have just the .vimrc around and the rest will be done by VAM, even when you are running a fresh installation of Vim. If you're using plugins published on vim.org then a plain curl and the proper tools to unpack the downloaded archives are enough, but VAM also provides the possibility to install plugins via git, mercurial or subversion. However, all these are nicely explained by the VAM documentation.

Another cool feature of VAM is that it maintains a so-called well known plugins repository. Using it you may install whatever plugin you want without knowing where it's located, if is provided as a zip archive or as a vba etc. You simply don't care. Whiles this repository is very handy to install and to experiment with various plugins I tend to avoid it on my “production” Vim. The main reason is because some bundles have ugly names. For example, SQLUtilities plugin can be found under the “SQLUtilities_-_SQL_utilities_-_Formatting_generate” name which means it will be installed into that long ugly directory. That's not VAM fault, it's because the list of vim plugins is automatically generated based on the script names provided by their own developers on vim.org site.

So, instead of relying to the well know plugins repository I like to stick to a fixed list of plugins, manually specified into my .vimrc file. Below is how my .vimrc starts:

" Maintainer: talek
" Version: 2.0 - 29/10/10 10:45:58
" Description: configuration for vim

" We don't want vi compatibility.
set nocompatible

" Activate Addons Management
let g:vim_script_manager = { 'known_repos_activation_policy' : 'never', 'auto_install' : 1, 'plugin_sources' : {} }
let g:vim_script_manager.plugin_sources['nerd_commenter'] = {'type': 'git', 'url': 'git://github.com/scrooloose/nerdcommenter.git'}
let g:vim_script_manager.plugin_sources['surround'] = {'type': 'git', 'url': 'git://github.com/tpope/vim-surround.git'}
let g:vim_script_manager.plugin_sources['repeat'] = {'type': 'git', 'url': 'git://github.com/tpope/vim-repeat.git'}
let g:vim_script_manager.plugin_sources['supertab'] = {'type': 'git', 'url': 'git://github.com/ervandew/supertab.git'}
let g:vim_script_manager.plugin_sources['align'] = {'version': '35/41', 'url': 'http://www.vim.org/scripts/download_script.php?src_id=10110', 'vim_version': '7.0', 'date': '2009-03-04', 'vim_script_nr': 294, 'type': 'archive', 'script-type': 'utility', 'archive_name': 'Align.vba.gz', 'author': 'Charles Campbell'}
let g:vim_script_manager.plugin_sources['sqlutil'] = {'version': '4.00', 'url': 'http://www.vim.org/scripts/download_script.php?src_id=13576', 'vim_version': '7.0', 'date': '2010-08-15', 'vim_script_nr': 492, 'type': 'archive', 'script-type': 'utility', 'archive_name': 'sqlutil_400.zip', 'author': 'David Fishburn'}
let g:vim_script_manager.plugin_sources['taglist'] = {'version': '4.5', 'url': 'http://www.vim.org/scripts/download_script.php?src_id=7701', 'vim_version': '6.0', 'date': '2007-09-21', 'vim_script_nr': 273, 'type': 'archive', 'script-type': 'utility', 'archive_name': 'taglist_45.zip', 'author': 'Yegappan Lakshmanan'}
let g:vim_script_manager.plugin_sources['fuzzyfinder'] = {'type': 'hg', 'url': 'http://bitbucket.org/ns9tks/vim-fuzzyfinder'}
let g:vim_script_manager.plugin_sources['nerd_tree'] = {'version': '4.1.0', 'url': 'http://www.vim.org/scripts/download_script.php?src_id=11834', 'vim_version': '7.0', 'date': '2009-12-01', 'vim_script_nr': 1658, 'type': 'archive', 'script-type': 'utility', 'archive_name': 'NERD_tree.zip', 'author': 'Marty Grenfell'}
let g:vim_script_manager.plugin_sources['L9'] = {'type': 'hg', 'url': 'http://bitbucket.org/ns9tks/vim-l9'}
let g:vim_script_manager.plugin_sources['xptemplate'] = {'version': '0.4.8-r994', 'url': 'http://www.vim.org/scripts/download_script.php?src_id=13740', 'vim_version': '7.2', 'date': '2010-09-01', 'vim_script_nr': 2611, 'type': 'archive', 'script-type': 'utility', 'archive_name': 'xpt-0.4.8-r994.tgz', 'author': 'drdr xp'}
let g:vim_script_manager.plugin_sources['xptemplate']['strip-components'] = 0
let g:vim_script_manager.plugin_sources['command-T'] = { 'type' : 'git', 'url' : 'git://git.wincent.com/command-t.git' }
let g:vim_script_manager.plugin_sources['tcalc'] = {'version': '0.11', 'url': 'http://www.vim.org/scripts/download_script.php?src_id=8028', 'vim_version': '7.0', 'date': '2007-12-05', 'vim_script_nr': 2040, 'type': 'archive', 'script-type': 'utility', 'archive_name': 'tcalc.zip', 'author': 'Tom Link'}
let g:vim_script_manager.plugin_sources['bufexplorer'] = {'version': '7.2.7', 'url': 'http://www.vim.org/scripts/download_script.php?src_id=12904', 'vim_version': '7.0', 'date': '2010-04-26', 'vim_script_nr': 42, 'type': 'archive', 'script-type': 'utility', 'archive_name': 'bufexplorer.zip', 'author': 'jeff lanzarotta'}
let g:vim_script_manager.plugin_sources['ack'] = {'type': 'git', 'url': 'http://github.com/mileszs/ack.vim.git' }
let g:vim_script_manager.plugin_sources['genutils'] = {'version': '2.5', 'url': 'http://www.vim.org/scripts/download_script.php?src_id=11399', 'vim_version': '7.0', 'date': '2009-09-17', 'vim_script_nr': 197, 'type': 'archive', 'script-type': 'utility', 'archive_name': 'genutils-2.5.zip', 'author': 'Hari Krishna Dara'}
let g:vim_script_manager.plugin_sources['matchit'] = {'version': '1.13.2', 'url': 'http://www.vim.org/scripts/download_script.php?src_id=8196', 'vim_version': '6.0', 'date': '2008-01-29', 'vim_script_nr': 39, 'type': 'archive', 'script-type': 'utility', 'archive_name': 'matchit.zip', 'author': 'Benji Fisher'}
let g:vim_script_manager.plugin_sources['arpeggio'] = {'type': 'git', 'url': 'http://github.com/kana/vim-arpeggio.git' }
let g:vim_script_manager.plugin_sources['minibufexplorer'] = {'version': '6.3.3', 'url': 'http://www.vim.org/scripts/download_script.php?src_id=13838', 'vim_version': '7.0', 'date': '2010-09-15', 'vim_script_nr': 3239, 'type': 'archive', 'script-type': 'plugin', 'archive_name': 'minibufexplpp.vim', 'author': 'Oliver Uvman'}
let g:vim_script_manager.plugin_sources['vorax'] = {'title': 'vorax', 'version': '2.5', 'url': 'http://www.vim.org/scripts/download_script.php?src_id=14147', 'vim_version': '7.0', 'date': '2010-10-02', 'vim_script_nr': 3154, 'type': 'archive', 'script-type': 'utility', 'archive_name': 'vorax-2.5.zip', 'author': 'Alexandru Tica'} 

func ActivateMyAddons()
let addons_base = substitute(expand('$HOME') . '/vim-addons', '\\\\\|\\', '/', 'g')
" check if addons_base folder is there
if finddir(addons_base, '') == ''
call mkdir(addons_base, '')
endif
let addons_manager = addons_base . '/vim-addon-manager'
exe 'set runtimepath+=' . escape(addons_manager, ' ')
if finddir(addons_manager) == ''
" The addons manager is not installed. Install it now!
exe 'cd ' . addons_base
exe '!git clone git://github.com/MarcWeber/vim-addon-manager.git'
endif
call scriptmanager#Activate(['nerd_commenter',
\  'surround',
\  'repeat',
\  'supertab',
\  'align',
\  'sqlutil',
\  'vorax',
\  'taglist',
\  'L9',
\  'fuzzyfinder',
\  'nerd_tree',
\  'genutils',
\  'bufexplorer',
\  'matchit',
\  'command-T',
\  'minibufexplorer',
\  'vorax',
\  'tcalc',
\  'arpeggio',
\  'ack',
\  'xptemplate'])
endfunc
call ActivateMyAddons()
As you can see I have a list of plugins I always want to have them installed. I just extracted their definition from the well know plugins repository and I've tailored the names to look nicer. For the complete list you may check this list.

If you rather want to go with the know-addons-repository and get up-to-date plugins then the following code should do the job:
" Maintainer: talek
" Version: 2.0 - 29/10/10 10:45:58 
" Description: configuration for vim

" We don't want vi compatibility.
set nocompatible 

" Activate Addons Management
let g:vim_script_manager = { 'known_repos_activation_policy' : 'autoload', 'auto_install' : 1 }

func ActivateMyAddons()
  let addons_base = substitute(expand('$HOME') . '/vim-addons', '\\\\\|\\', '/', 'g')
  " check if addons_base folder is there
  if finddir(addons_base, '') == ''
    call mkdir(addons_base, '') 
  endif
  let addons_manager = addons_base . '/vim-addon-manager'
  exe 'set runtimepath+=' . escape(addons_manager, ' ')
  if finddir(addons_manager) == ''
    " The addons manager is not installed. Install it now!
    exe 'cd ' . addons_base
    exe '!git clone git://github.com/MarcWeber/vim-addon-manager.git'
  endif
  call scriptmanager#Activate(['The_NERD_Commenter', 
                              \  'surround', 
                              \  'repeat', 
                              \  'supertab',
                              \  'Align294', 
                              \  'SQLUtilities_-_SQL_utilities_-_Formatting_generate',
                              \  'vorax',
                              \  'taglist',
                              \  'L9',
                              \  'fuzzyfinder',
                              \  'The_NERD_tree',
                              \  'genutils',
                              \  'bufexplorer.zip',
                              \  'matchit.zip',
                              \  'Command-T',
                              \  'minibufexpl.vim_-_Elegant_buffer_explorer',
                              \  'vorax',
                              \  'tcalc',
                              \  'arpeggio',
                              \  'ack',
                              \  'xptemplate'])
endfunc
call ActivateMyAddons()
Both methods above check if VAM is already installed and if not than it is fetched using git which, by the way, is the recommended way. This means git has to be available on your platform. So before going on, let's have a look at the external tools needed by VAM:
  1. on UNIX:
    • curl (e.g. apt-get install curl)
    • git-core (e.g. apt-get install git-core)
    • mercurial (e.g. apt-get install mercurial)
    • subversion (e.g. apt-get install subversion)
  1. on Windows:
That's it! If all of the above dependencies are installed and they are working fine then VAM should automatically install the specified plugins. This is huge because, from now on, you'll simply need to have just your .vimrc and VAM will do all the rest.

VoraX 2.5 Released

Hi guys! A new version of VoraX is available for download. As usual, I'm gonna post here what's new in this version.

First of all, VoraX is now able to display the output of a query using a vertical column layout. For those of you who don't like to horizontally scroll through very long lines (e.g. V$SESSION) this is, indeed, a nice feature. But, beyond this, there is also a practical need for such a functionality. It's kind of funny that the implementation of this vertical column layout feature was started because of an issue reported by Spratek, issue which has nothing to do with this "fancy" layout.

As you already know, Sqlplus is very peaky when comes to display BLOB content. The main issue is this stupid "SP2-0678: Column or attribute type can not be displayed by SQL*Plus" error. Damn it! It's a very annoying limitation and apparently this can't be solved that easy. Excluding BLOB columns using "column ... noprint" does not work therefore the only solution is to manually exclude those BLOB columns from your query which it means, of course, that you have to manually specify all the others. Bleah! The last solution was to use the DBMS_SQL package which helped to dynamically process the output of the query and get rid of the BLOB content, if any is present. So, if you have tables with BLOBs keep in mind that this might be your only solution to query them. The shortcut is <Leader>v1 (it's "one" not L) and you should use it only for single queries. Executing multiple queries within the same block is not supported.

Another improvement in this version is that you can now browse materialized views inside VoraX DbExplorer. This was requested by Ingo Olbrigh and might prove to be quite handy if you are working with these kind of objects.

There are also a few other minor improvements. One of them is that you can now control where to leave the focus after something is executed. Until now, the default behavior was to leave the focus into the results window. Starting with this version you may tell VoraX to return to the window from where the statement was executed (thanks Koelner.r for this suggestion). And that's not all. In addition you may now use matchit within your plsql buffers.

VoraX 2.5 comes also with a few bug fixes, already detailed in the changelog.

Have fun!

Update: Starting with 11.1, Sqlplus is smart enough to display BLOB columns without raising SP2-0678 errors. According to the Oracle documentation (New Features in SQL*Plus 11.1):
SQL*Plus supports standard querying of tables and objects containing BLOB and BFILE datatypes.

Saturday, October 2, 2010

VoraX 2.4

I've just released VoraX 2.4. It doesn't contain any new features, just a few bug fixes. You may take a look into the changelog if you are interested in more details.

Tuesday, September 14, 2010

Ready for VoraX 2.3?

Hey, VoraX 2.3 is available for download. It has some new goodies which I'm sure you gonna like. The first one is the ability to get the explain plan (detailed or trace only) for a sql statement. Ingo Olbrich came up with this idea and now, I guess VoraX is closer to what a modern IDE should be. Thanks Ingo!

The next feature which I think is quite handful is that you can now offline search through the html Oracle documentation directly from VoraX. With some GNU Screen trickery and a good text web browser you'll never have to leave your beloved console. :)

Another feature which some might find it useful is the possibility to define your custom key mappings without using ugly auto-command workarounds. There's a good example into the VoraX documentation.

Below is a very short demo with VoraX 2.3 main features:



Enjoy!

Monday, September 13, 2010

How to Install VoraX on Cygwin

I'm coming back with the promised post about how to install VoraX on Cygwin. So, let's begin!

First of all, you obviously need Cygwin. You may download it from here. From the looong list of available cygwin packages I recommend to install the following ones (there's a search text field on top):
  • gcc
  • make
  • bzip2
  • ncurses-devel
  • openssl-devel
  • ruby-1.8.7
  • wget
  • w3m
  • mintty
  • screen
Accept all dependencies cygwin installer suggests and start the installation process. If you'll need any additional packages you may opt to install them later.

Next, go ahead and launch cygwin from your desktop. If you don't like the command window terminal get rid of it and start using mintty. Change the C:\cygwin\cygwin.bat as shown below:

@echo off
C:
chdir C:\cygwin\bin
set CYGWIN=nodosfilewarning
start mintty -e /bin/bash --login -i

Start your new terminal and then customize it to suit to your preferences. You have an "Options" menu item available. I always find myself customizing:
  • foreground/background colors. I like black on white instead of the default opposite
  • block cursor
  • set Consolas 9 font. (if you don't have this font package you may download it from here).
  • right click action: Paste
  • TERM at startup: xterm
  • Scrollbar: none
  • uncheck "Ask for exit confirmation".
Now, it's time to compile vim with ruby support:

1. download vim 7.3 package:

cd /tmp
wget ftp://ftp.vim.org/pub/vim/unix/vim-7.3.tar.bz2

2. uncompress the downloaded archive:

tar -xjf vim-7.3.tar.bz2

3. compile vim with ruby support:

cd vim73/
./configure --enable-rubyinterp --with-features=huge
make
make install

4. install rubygems utility:

cd /tmp
wget http://rubyforge.org/frs/download.php/70697/rubygems-1.3.7.zip
unzip rubygems-1.3.7.zip
cd rubygems-1.3.7
ruby setup.rb

5. install antlr3 gem:

gem install antlr3 -r

6. customize vim via .vimrc and install all your favorite vim plugins including of course VoraX. If you already have a _vimfiles directory in your $HOME then just copy it in your new cygwin home and change the name to .vim. Sqlplus should still be in your cygwin PATH.

Congrats! You have (at least I hope to) VoraX running on top of your Cygwin environment. So, you have the unix shell on your finger tips with all the useful tools you are so used to use: ssh, gnu screen, w3m etc.

However, I think is worth to mention some problems you may have migrating VoraX to Cygwin and some possible workarounds.

Problem 1: Where's my nice colorschema?
The first thing you'll notice is that your nice colorscheme on your gvim doesn't look the same on the console version of vim under Cygwin. There is a simple solution provided by CSApprox plugin. This plugin should seamlessly convert colors from the gui-version to the proper terminal colors. However, in order to have this conversion automatically done, our vim should have been compiled with "gui" support. But, we still have a fallback solution. CSApprox provides a way of creating a snapshot of your current colors into a new colorschema file. So, open your gvim windows version (which I suppose will open with your favorite colorschema) and use :CSApproxSnapshot [mycolors.vim]. This new colors file will be suitable for your terminal version of vim. If you like earendel colors I already have a converted schema. You may get it from here.

Problem 2: The title of mintty terminal doesn't change when a new VoraX connection is done.

This has nothing to do with mintty. You need to put this in your .vimrc:

set title

Problem 3: Under GNU Screen, colors are different and the title is not properly updated.

You may try the following .screenrc configuration:
# no annoying audible bell, please
vbell on

# detach on hangup
autodetach on

# don't display the copyright page
startup_message off

# generous scrollback
defscrollback 1000

# xterm for all new sessions
term xterm

# special xterm hardstatus: use the window title.
termcapinfo xterm 'hs:ts=\E]2;:fs=\007:ds=\E]2;screen\007'

# terminfo and termcap for nice 256 color terminal
# allow bold colors - necessary for some reason
attrcolor b ".I"
# tell screen how to set colors. AB=background, AF=foreground
termcapinfo xterm 'Co#256:AB=\E[48;5;%dm:AF=\E[38;5;%dm'
# erase background with current bg color
defbce "on"

That's it! Below is my VoraX into a GNU Screen session:


At the bottom of the VoraX window is a man page just to prove that we are under GNU Screen. And yes, it's on a Windows XP system. I think Oracle geeks may be happy on Windows too. :)

Wednesday, September 8, 2010

VoraX says Hello to Cygwin

In my previous post I was talking about GNU Screen and how nice this tool may be used in connection with VoraX and other terminal applications. The only problem was on Windows where there's no multiplexing tools available except for GNU Screen on Cygwin. Some Windows guys are happy with this Console but, in my opinion, this is far from what GNU Screen provides. And, if it happens to be on both, Unix and Windows, it's quite nice to have the same tool available, isn't it?

Well, starting from today, VoraX 2.2 is available for download and, as you maybe already guessed, it provides a Cygwin interface. If you don't like Cygwin then this new VoraX interface is not for you, but all of you who appreciate the UNIX style shell and tools on Windows I think will be glad to use VoraX on this platform. You'll also benefit from GNU Screen, ssh, bash scripting etc.

Installing vim with ruby support on cygwin is not quite a blink of an eye therefore I'm going to come back with a new post explaining in detail how to do it.

And because I use to let people know what every new VoraX version brings to light I will also briefly mention the refresh capability of the output buffer. If, for example, you monitor the progress of a rollbacking transaction, it is very likely to repeatedly execute the same query. It is a little bit awkward to go everytime into the sql buffer and to execute that query. Instead, in VoraX 2.2 you may simply press R while in the output buffer and the last executed query will be re-executed automatically.

VoraX 2.2 fixes also some bugs and, in addition, has some tweaks which improve the
fetching performance, especially on Unix.

Saturday, September 4, 2010

VoraX, GNU Screen and Nice Colors

Hi guys! All good there? :)

Today I want to share with you some tips. I discover them myself during my efforts to get the best out of VoraX.

I was asked once about the possibility to offer support for multiple connections within VoraX. Despite this would be quite nice, it is not easy to implement at all. I mean, think about it: you have to link every Vim buffer to a particular oracle connection and have to maintain this relation. When you open a new sql file you have to decide to which connection it belongs. Every connection must have its own output buffer, right? The DbExplorer has to be also aware of multiple connections.

At the beginning of VoraX I thought of this and one idea was to use Vim tabbing support to map one tab to an oracle connection. If you open a new sql file, you open it to the current tab which is supposed to have a connection attached. That sql buffer will inherit the connection from its parent tab. I switch the tab and I'm connected to another session. It sounds pretty good, doesn't it? Well, during my first attempts to implement this I encountered a lot of problems:
  1. vim support for tab events is quite poor. For example, it doesn't provide a tabClose event (aka autocommand). This event is critical in order to force a disconnect when the user simply closes a vim tab. However, I succeeded to manage this with a lot of CursorHold trickery but the final result was not very nice.
  2. the vim tabbing model is not the same as in the most known IDEs/editors. In vim, a tab acts more like a viewport or a layout. This means a particular buffer doesn't stick to its tab. It can be migrated to another tab if you want. This may lead to confusion, because a buffer which was belonging to a connection can suddenly become part of another tab and, as a consequence, mapped to a new unexpected connection.
  3. in addition there's no good support for vim unit testing. There are a few plugins (including this) but I didn't have a pleasant experience with them. So, I didn't want to implement a complex connection management feature without a strong testing/regression support.
But let's come back to the tips part. Okey, how can we have multiple connections in VoraX? Well, if you are on a UNIX based system you may happily use GNU Screen or tmux. They're a few more out there but basically all of them are terminal multiplexers. They allow to map many terminal sessions within the same console which is, of course, just lovely. So, we can use such a tool and have multiple VoraX running in different multiplexed sessions, connected to various oracle sessions. We may switch them as we want while still sharing the same single console.

But, how about VoraX on Windows? Well, here things are not very promising yet. The only multiplexer I know in Windows is GNU Screen on top of Cygwin. This means you'd also need a cygwin version of vim (console mode, not gvim) with ruby support. Most likely you'd have to compile it yourself. Maybe this is not a big deal but the major problem right now is that VoraX doesn't provide a cygwin interface yet. Nevertheless, I'm going to create one in the next future. Till then, all of you guys on Windows, sorry... you'll have to wait!

If you were to ask me, I use GNU Screen for years. I like it a lot and I think it is a great tool. It is a productivity booster and it's worthing to learn some of its key shortcuts. However, one problem I had was with my vim colors. I like the earendel colorscheme. It's light and friendly with my eyes. However, you may notice a big difference between the colors in the GUI version of vim and the colors displayed within the plain console vim. Of course, using gvim and GNU screen doesn't have much sense, so you have to focus on the console version of vim.

First of all, you must have a decent terminal with the ability to display 256 colors. I use gnome-terminal with a "Linux console" built-in schema palette and it's working pretty well. I expect XTerm to be also a good choice. Then, I recommend CSAprox plugin which tries to map vim colors to your terminal as close as possible. This plugin comes with good documentation therefore I'll just skip the details. So after installing this plugin, your vim colors should look fine in your terminal too.

There's one more catch. I noticed that the colors were not displayed correctly when vim is opened into a GNU screen session. They were okey in a plain terminal but not under GNU Screen. I google for this topic and I found a solution. Add this to your .screenrc file:
# terminfo and termcap for nice 256 color terminal
# allow bold colors - necessary for some reason
attrcolor b ".I"
# tell screen how to set colors. AB = background, AF=foreground
termcapinfo xterm 'Co#256:AB=\E[48;5;%dm:AF=\E[38;5;%dm'
# erase background with current bg color
defbce "on"
Restart your GNU Screen and Voila! You have beautiful colors in your screen console:

Above is a screenshot with two of my multiplexed VoraX sessions. Both of them are shown in a split which is not very common but is good for demonstration purposes. In practice is more likely to have one "full VoraX window" session at a time, with the possibility to switch to another one running in background. Isn't it great? In this light I must say: Who needs VoraX multi-connection support anyway?

Wednesday, August 18, 2010

VoraX 2.1 released

Finally, VoraX 2.1 is available for download! You may have a look at the changelog for what's new.

In this post I want however to talk a little bit about the new features this version brings in. The most important one, in my opinion, is the fuzzy search feature. The idea came from a practical need. I don't know about you but, personally, I have troubles remembering various package names, tables, views etc. You may say: okey, but you can use code completion, right? Yes, of course, but what if you don't know how the object name starts? For example, let's say I want to query the AWR snapshots. Frankly, I don't know exactly where these snapshots resides, but I (fuzzy) remember that it's something with "snapshot". So, I am in the middle of:

SELECT * FROM |<-- cursor here in insert mode

Now, I can invoke vorax fuzzy search. While in insert mode type <Leader> vl (vl stands for vorax locate). A prompt will be shown at the top and you can type there: snapshot. Pay attention that the list with the candidate items will start to be populated after you type at least three characters. You should see in the list the view you are looking for: DBA_HIST_SNAPSHOT. Oooh, yea I remember... that's it! Just select it, press ENTER and DBA_HIST_SNAPSHOT will be inserted at the current cursor position. Nice!
Another scenario when this feature may prove to be quite handy is when you have to change a system parameter. Suppose you want to increase the size of your flash recovery area. You are in the middle of:

ALTER SYSTEM SET |<-- cursor here in insert mode

Ookey, now what? I think the name of the parameter is something with recovery... Yeap, it's time for a fuzzy search. Invoke it and type: recovery. Ups, a lot of items are there: views, synonyms, tables. You can narrow down and refine your search knowing that you're actually looking for a parameter. So, you further type ;:param. Now your search pattern looks like: recovery;:param. That's nice: I have now just the parameters which contain the word recovery:

- recovery_parallelism
- db_recovery_file_dest
- db_recovery_file_dest_size


Now, it's clear that we want db_recovery_file_dest_size.
This feature depends on FuzzyFinder plugin so don't forget to install it if you want to have this new vorax feature. You can also customize the search-able database items by modifying the search.sql script located at: &rt/vorax/sql.

Another improvement is the possibility to invoke describe commands directly from the DbExplorer. It was proposed by Shaun and it makes a lot of sense.

VoraX 2.1 comes also with new syntax files for sql and plsql which means your oracle code will look much better. The sqlplus keywords like ACCEPT, PROMPT etc. are also highlighted in sql buffers.

That's it for now! Enjoy!

Friday, August 6, 2010

VoraX 2.0

VoraX has changed its major version number. Ieeei... waves please! :) It feels a little bit more mature, doesn't it? Joking apart, this new release addresses a few nasty bugs and it has some nice new features.

The first one is the ability to store passwords for your Oracle connection profiles. For those of you who's working with a lot of databases and users this feature may prove to be a life saver. Shaun Batterton came up with this idea and he proposed the using of PGP protocol. However, in ruby PGP is not very well supported. There is a project called OpenPGP but I found difficult to use it on windows because of its dependency on Open4 which is not supported on Windows. In the end I gave green light to the RSA keys implementation and you may find additional details about this here.

Shaun also noticed that the fact that after a connection you have to set the [no name] buffer to an sql buffer type it's quite annoying. And he's right, that's why in VoraX 2.0 a scratch.sql buffer is opened on the first connection.

Then Spratek had also a nice improvement idea. Instead of the flat DESC output he (he I guess :D) came up with the idea of a more verbose describe. The idea is to have also comments for columns, constraints, foreign keys and other such critical information for database developers. So, VoraX 2.0 has also this feature. For a table or a view you may invoke a verbose describe using <Leader> vdv mapping.

Also, in VoraX 2.0 you may invoke describe and "go to definition" directly within the results window. This might be handy if you query dictionary stuff and you want to describe a definition directly from that output.

That's it for the moment! Have fun guys!

Monday, August 2, 2010

VoraX and Oracle Documentation Offline Search

Lately, I found myself using VoraX a lot. However, one feature that I miss is searching through the oracle documentation. For example, let's say I've just queried the v$session view and there's a column there called PDML_ENABLED. Okey, what does it mean that? I want to know more about this column. That's not such a big problem... it basically boils down to:
1. open your favorite browser;
2. go to the oracle official documentation and enter the text you want to search. This link should guide you directly to the search facility.
Okey, so is not such a big deal but it can be annoying especially when the Oracle site is slow... and from my experience this happens quite often. You may think that an offline search might help... just download the documentation package and search locally. NO! That's not an option. The search facility always goes through the internet... and if you are not connected to the internet then is sad...
But, don't be too disappointed... there's still a nice solution. You may use Google Desktop to perform offline searches. It works like a charm in connection with vorax... while in VoraX activate google desktop and search for your term. That's it... fast and convenient. However, you have to pay attention to some details about configuring Google Desktop. By default it will index almost everything on your computer: emails, word documents, web history etc. etc. etc. You'll end up having a huge index cache with a lot of information not related to Oracle at all. So, my first idea was to index just one folder, the one with the oracle documentation. Apparently, this doesn't work: all fixed drives are indexed by default. Okey, there's also a section which says: "Add file or folder to exclude". I thought that adding there all my fixed drives and then explicitly telling Google Desktop to index my documentation folder will work. Well, not the case... really! If your documentation is, let's say, within C:\oracle\docs and you exclude the C: drive nothing will be indexed at all. The last thing I tried and it worked was mapping my documentation directory to a logical drive. In windows you may use the following command:
subst x: "c:\oracle\docs"
Then tell google desktop to index your X: drive and exclude all the others. Ieei, that's nice... i have offline search-able oracle documentation which is very easy to access from any application, including VoraX.
There was still a problem. The Oracle documentation is huge and I don't want everything from there. For example, if you search for V$SESSION a lot of results will come from replication documentation which is not really what I am looking for. So, in the end I decided to manually index just the books I found to be the most relevant ones. From the last 11.2 Official documentation I've selected just several directories and I put them as shown below:
X:\
|
+-- official_11_2
    |
    +-- dcommon
    |
    +-- favourites
        |
        +-- e10577
        |
        +-- e10592
        |
        +-- e10820
        |
        +-- e10880

Basically, I've selected the following books:
1. Oracle® Database PL/SQL Packages and Types Reference
2. Oracle® Database SQL Language Reference
3. Oracle® Database Reference
4. Oracle® Database Error Messages
These are the books I use to search a lot when I'm in the middle of writing sql/plsql code. Now, I have just a small set of the whole documentation which is faster to index and easier to browse.
I didn't have the time to try this configuration on UNIX systems but I'm quite confident that it should work.

Update 1: The above directory numbers for each book may be different in your documentation package.
Update 2: Starting with version 2.3 VoraX provides built-in Oracle HTML documentation search. Details may be found here.

Friday, July 30, 2010

VoraX 1.9 is available for download

Hi everybody! I know it's been just one day since I released VoraX 1.8 but I think often/early releases are good. So, I've just uploaded VoraX 1.9. This version addresses several annoying bugs and has a new feature: you may define connection profiles in a special buffer. This may be handy especially if you connect using EZCONNECT and you don't want to remember server host names, ports etc. Spratek came up with this idea! Thanks man! For additional details about this release you may take a look at the changelog.

Thursday, July 29, 2010

VoraX as a Replacement for Your Fancy Oracle IDE

At the time of writing this post VoraX 1.8 was already released. Frankly, I'm pleased about the results. My target was to have a lightweight, simple and efficient Oracle IDE based on VIM. From this point of view I think that, in many ways, the goal is achieved.

In my opinion, a decent Oracle IDE should have:
- basic features to query the database
- code completion
- plsql editing/compiling support
- a database browser/explorer
- navigation through the package code structure
- SQL statements formatting
- source control support
- the possibility to extend the provided features

Nowadays, it's not very difficult to find out such an IDE (commercial or open source)... but, if you are a VIM addicted guy (like me), you'll soon discover that no editor is better than VI. Furthermore, coming back from VI to a fancy Oracle IDE is such a pain. In those environments I always start editing with "jjj", "kkk"... WTF? It takes a few seconds to realize I'm not in my friendly VI editor.

In this post I'm going to show you how to configure VIM/VoraX as your new Oracle IDE. First of all, dont't forget VoraX is just a plugin therefore is critical to have your VIM properly configured. I know you already know that VIM is highly customizable therefore it's up to you to configure it so that to be the perfect editor you always wanted. Useless to say, VIM provides an "eco-system" of plugins which may prove to be quite useful. You can browse them on the official vim site but, as far as VoraX is concerned, we'll be especially interested in the following ones:

- vcscommand: allows working with various source control systems.
- bufexplorer: provides navigation through VIM buffers.
- supertab: may be used to invoke code completion using the TAB key, much more convenient than C-X C-O.
- NERDTree: a nice file browser directly in VIM.
- NERD Commenter: maybe used to comment the code.
- xptemplate: provides nice snippets/templates. These are met in many modern IDEs.
- taglist: may be used to browse the code structure.
- align and SQLUtilities: provides SQL beautifier functions.

If you look at the above plugins and the features they provide and add all the advanced features of VIM itself, you realize we're quite close to what a modern Oracle IDE might be.

Below is my .vimrc configuration file. Once again, it's up to you to configure it as you want. These are the settings which, over time, proved to be the best for me:

" Maintainer: talek

" Version: 1.0 - 16/04/10 10:09:12


" Description: configuration for vim




"""""""""""""""""""""""""

" => General section


"""""""""""""""""""""""""

" We don't want vi compatibility.


set nocompatible

" How many lines of history to remember


set history=300



" Automatically detect file types.


filetype plugin on

filetype indent on



" Set to auto read when a file is changed from outside


set autoread

 

" Set a more convinient map leader


let mapleader=','

let g:mapleader=','



" Set a shorter timeout


set timeoutlen=250



" Fast exit from insert mode


imap jj <Esc>



" Fast saving


nmap <leader>w :w!<cr>



"""""""""""""""""""""""""

" => VIM user interface


"""""""""""""""""""""""""

if has('gui') && (has('win32') || has('win64'))

  " only on windows GUI version


    set guifont=DejaVu_Sans_Mono:h9

endif



" no toolbar, menu or scroll bars


set guioptions=



" Turn on wild menu


set wildmenu



" Always show current position


set ruler

 

" Set numbering


set nu



" Command bar height


set cmdheight=2



" Change buffer without saving


set hid



" Set backspace config


set backspace=eol,start,indent

set whichwrap+=<,>,h,l



" Ignore case when searching


set ignorecase



" Highlight search things


set hlsearch



" Incremental search please


set incsearch



" We want magic for regular expressions


set magic



" Matching brackets with blink


set showmatch

set mat=2



" We don't like noise on errors


set noerrorbells

set novisualbell

set t_vb=



"""""""""""""""""""""""""

" => Colors and fonts


"""""""""""""""""""""""""

" Enable syntax colloring


syntax enable



" Configure colorscheme


set t_Co=256

set background=light

colorscheme earendel



" In gui mode get rid of the toolbar


if has("gui_running")

  set guioptions-=T

endif



" Set encoding


set encoding=utf8

try

    lang en_US

catch

endtry



" Set default file format


set ffs=unix,dos,mac



set showcmd



"""""""""""""""""""""""""

" => Files and backups


"""""""""""""""""""""""""

" Turn backup off


set nobackup

set nowb

set noswapfile



"""""""""""""""""""""""""

" => Tabbing/indenting


"""""""""""""""""""""""""

set expandtab

set shiftwidth=2

set tabstop=2

set smarttab



set lbr

set tw=500



" Auto indent


set ai

" Smart indent


set si

" No wrap


set nowrap



"""""""""""""""""""""""""

" => Useful mappings


"""""""""""""""""""""""""

" Smart way to move btw. windows


map <C-j> <C-W>j

map <C-k> <C-W>k

map <C-h> <C-W>h

map <C-l> <C-W>l



" Expand/Shrink pane


map <C-Down> <C-W>+

map <C-Up> <C-W>-



" Close the current buffer


map <leader>bd :Bclose<cr>



command! Bclose call <SID>BufcloseCloseIt()

function! <SID>BufcloseCloseIt()

   let l:currentBufNum = bufnr("%")

   let l:alternateBufNum = bufnr("#")



   if buflisted(l:alternateBufNum)

     buffer #

   else

     bnext

   endif



   if bufnr("%") == l:currentBufNum

     new

   endif



   if buflisted(l:currentBufNum)

     execute("bdelete! ".l:currentBufNum)

   endif

endfunction



"""""""""""""""""""""""""

" => Status line configuration


"""""""""""""""""""""""""

" Always hide the statusline


set laststatus=2



" Format the statusline


set statusline=\ %F%m%r%h\ %w\ \ CWD:\ %r%{CurDir()}%h\ \ \ Line:\ %l/%L:%c





function! CurDir()

    let curdir = substitute(getcwd(), '/Users/amir/', "~/", "g")

    return curdir

endfunction



"""""""""""""""""""""""""

" => Abbrevs


"""""""""""""""""""""""""

iab xdate <c-r>=strftime("%d/%m/%y %H:%M:%S")<cr>



"""""""""""""""""""""""""

" => Misc


"""""""""""""""""""""""""

set cf  " Enable error files & error jumping.

set clipboard+=unnamed  " Yanks go on clipboard instead.

 

"""""""""""""""""""""""""

" => Supertab


"""""""""""""""""""""""""

let g:SuperTabDefaultCompletionType = "<c-x><c-o>"

set completeopt+=longest

let g:SuperTabLongestEnhanced=1



"""""""""""""""""""""""""

" => bufExplorer plugin


"""""""""""""""""""""""""

let g:bufExplorerDefaultHelp=0

let g:bufExplorerShowRelativePath=1



"""""""""""""""""""""""""

" => NERDTree config


"""""""""""""""""""""""""

let g:NERDTreeHighlightCursorline = 1

map <leader>ff :NERDTreeToggle<CR>



"""""""""""""""""""""""""

" => XPTemplate config


"""""""""""""""""""""""""

" avoid key conflict


let g:SuperTabMappingForward = '<Plug>supertabKey'



" if nothing matched in xpt, try supertab


let g:xptemplate_fallback = '<Plug>supertabKey'



" xpt uses <Tab> as trigger key


let g:xptemplate_key = '<Tab>'



" use <tab>/<S-tab> to navigate through pum. Optional


let g:xptemplate_pum_tab_nav = 1



" xpt triggers only when you typed whole name of a snippet. Optional


let g:xptemplate_minimal_prefix = 'full'



" Navigate


let g:xptemplate_nav_next = '>>'

let g:xptemplate_nav_prev = '<<'



" Don't like blanks for brackets


let g:xptemplate_brace_complete = '('

let g:xptemplate_vars = "SParg="



"""""""""""""""""""""""""

" => Taglist config


"""""""""""""""""""""""""

" Taglist configuration


let Tlist_Auto_Update=1

let Tlist_Show_One_File = 1

nmap <leader>t :TlistToggle<cr>



"""""""""""""""""""""""""

" => SQL Format config


"""""""""""""""""""""""""

xmap <leader>fo :SQLUFormatter<cr>

 

Okey, now some comments about the above settings, other than the ones directly specified into the script. First of all, what's with the mapleader setting? Well, by default, leader key in Vim is \. On my keyboard this is hard to type and I really don't want to broke my finger reaching for such an used key. Instead, this is remapped to "," which is very convenient to type. Second of all, what's with that "jj" remap? Personally, I don't like to type "ESC" key whenever I want to exit from the insert mode. Pressing "jj" is, again, very convenient.

Pay attention also to all new mappings used to navigate through VIM windows. I think it's much better than C-w j, C-w k etc. <leader>bd is also nice because it allows deleting the last buffer without closing its window, otherwise all remaining windows will be rearranged and this will mess up your layout.

The other settings I guess are obvious and do not deserve the time to explain now here. Of course, customizing VIM is a never-ending story but that's the beauty, really.