Wednesday, March 20, 2013

Sync That File!

I've been using komodo edit as my primary code editor for a spat of time now and I'm finding it to be a respectable weapon.  I mostly made the switch because I read somewhere that komodo edit supports vi emulation and I missed my vi-fu.

Another handy feature I'm really, really loving lately is the ability to kick off OS commands from within the komodo editor. For example, I'm in the process of porting some cold fusion code to php. My source files are located on a network share. When I test my updates, I copy the files to a virtual machine and then view the results there. It was getting more and more painful to use windows explorer to copy the files over and click through the overwrite 'are you sure' dialog boxes. Even without dialogs, the mere task of leaving the editor and giving focus to one window followed by moving focus to another grows tedious after a few repetitions.

Here's how I improved my workflow using komodo edit. I created a new run task by clicking 'Tools -> Run Command' which opened a dialog box. Then it was a simple matter of filling out the Command text box and adding a key binding by clicking on the 'Key Binding' tab and choosing the desired key combo. Now I sync my files by simply hitting 'ctrl-.' (the binding I chose) within komodo edit. Slick!

Advanced options include scoping commands globally, by project, or individual files. It's also possible to pass selections as input to the command or dump output from the command into your file. Refer to Komodo's help for all the gory details.

I configured the run command to use robocopy to facilitate the actual file transfers since it's very powerful and ships standard with win 7.

In this particular example I used robocopy with the /mir option which keeps folders (and sub-folders) sync'd (mirrored). This includes deleting files in the destination folder if necessary. A word of warning, robocopy doesn't warn or second guess. It just does. I accidentally nuked a couple folders on my file system when I supplied an erroneous destination path the first time around.

Example Command:
robocopy C:\code\P\php\sample \\webserver\d$\phpincludes\apps\sample /mir


  1. Everyone knows Emacs is the One True Way (TM). :D

    1. LOL. I feel an editor war coming on. I gave Emacs a try a decade or so ago. For whatever reason, it just didn't mesh with my brain. I do recall it possessing some cool functionality.