Find/Replace Transmogrification

Do you ever find yourself with the editing situation where you need to transform a text pattern to a string that contains information in that pattern? For example, suppose you want to convert all Tcl style assignments to C-style assignments.

Tcl:
set foo “some value”

C:
foo = “some value”;

This may seem like a time-consuming task until you know that TKE supports this type editing with the “Find / Find and Replace” capability. Because “Find and Replace” supports regular expression syntax, you can place any text that you would like to use in the “Replace” field by surrounding them with parenthesis in the “Find” field. You can then reference these matched text values in the “Replace” field by specifying a backslash () character followed by a number with corresponds to the left parenthesis order (starting at a value of 1).

So to implement a solution to the problem above, we could search the text for the pattern:

(s+)sets+(w+)s+(.*)$

This will place the preceding whitespace into variable “1”, the variable name of the Tcl “set” command into variable “2” and the value being assigned to the variable in variable “3”. We can then perform the text transformation in the replace entry field with the value:

12 = 3;

Once the text has been input, all Tcl set commands found in the editing buffer will be transformed into the C equivalents.

Pretty slick right? Use this powerful editing feature to make quick work of complex, repetitive editing tasks.

To see more information and download your copy of the TKE code editor, visit tke.sourceforge.net

Find/Replace Transmogrification

Exporting

If you are writing documentation with Markdown, it can be useful to generate HTML from the Markdown source for use in viewing on the web. Though there are some really great Markdown to HTML applications out there, TKE provides a built-in method for converting your Markdown into HTML via the File/Export… menu option.

If your document is in Markdown format and you select this option, TKE will display a save dialog window where you can specify the directory and name of the generated HTML file. Clicking on the ‘Save’ button within the window will create the associated HTML file.

Want to go even further with your export prowess? TKE also allows you to embed TKE snippet syntax into a document. Using the File/Export… option and selecting a save file will cause TKE to expand all embedded snippets in the document and output the resulting file. What’s even cooler is that the file doesn’t have to be in Markdown format for snippet export expansion to occur, you can place snippet text in any type of file.

To embed a snippet, simply surround normal snippet text in your file with the following syntax:

<tke:ExportString>…</tke:ExportString>

Snippet expansion is a super cool feature that you don’t find in most editors. Think of the possibilities. You could embed date-producing snippet text in your document and export the document to automatically include the date when the file was last generated. You could embed some file-related snippet text to cause the exported filename to be included in the file.

The possibilities are really endless.

To see more information and download your copy of the TKE code editor, visit http://tke.sourceforge.net

Exporting

Indentation Formatting

If you have ever looked at someone’s code that seems to have no regard for proper (or even consistent) indentation in their code, you will immediately appreciate TKE’s indentation formatting feature.

To adjust the indentation formatting for an entire file, open the file in an editing buffer and, while the editing buffer is the current buffer, select the “Edit / Indentation / Format Text” menu option. After a few moments, like magic, TKE will automatically adjust the indentation of the entire file.

Hard to read code
Easy to read code (and that’s why the function failed to compile)

 

 

To adjust a portion of the file, simply highlight the text to adjust, select the same “Edit / Indentation / Format Text” menu option and only the selected text will have its indentation adjusted.

If you want to guarantee that none of your indentation adjustments are accidentally saved to the file (i.e., if you are simply attempting to better understand a piece of code rather than take ownership of said code), simply lock the editing buffer using either the “File / Lock” menu option or right-click on the editing buffer’s tab and select the “Lock” option there. As long as the file is locked, you may make all of the file adjustments that you like without worrying about saving those changes to the file.

Now go and tell that individual that he/she needs to start using TKE with its awesome auto-indentation capabilities so they can start writing some code that everyone can feel better about!

To see more information and download your copy of the TKE code editor, visit http://tke.sourceforge.net

Indentation Formatting

The current_line Plugin

Perhaps its just a case of aging eyes, but sometimes I find myself searching for the current line that the cursor is on. I could adjust my theme’s cursor color to change it to make it easier to find; however, there is a plugin called the “current_line” plugin which highlights the entire line that the insertion cursor is currently on.

To install the plugin, click on the “Plugin” menu in the main menu and select the “Install…” menu option. In the resulting plugin preview window either type a portion of the name “current_line” or use the up/down arrows to find and select the plugin and hit the RETURN key. At the bottom of the TKE main window, a message indicating that the current_plugin is now installed will be displayed.

 

From that point on, all editing buffers will highlight the current line. What’s nice is that if you change the theme, the current line plugin will continue to work, adjusting the current line to go nicely with the theme’s background color.

To see more information and download your copy of the TKE code editor, visit http://tke.sourceforge.net

The current_line Plugin

Pane Alignment and Synchronized Scrolling

Every once in a while, I find myself needing to visually compare two files side-by-side. Unfortunately, there are few tools available (apart from difference tools which typically only allow a read-only view) that allow you to quickly align textual lines and keep them in sync when scrolling one of the files.

Now in TKE (as of version 2.8) there is a great solution. Simply open the two files in separate panes. You can do this by opening the two files, selecting one of the files, right click on the tab and choose the “Move to Other Pane” option.

Once both files are in view, place the insertion cursor on the line in each file that you want to synchronize (you will only the insertion cursor in the active editing buffer but TKE remembers the last insertion point in an editing buffer). The lines do not need to be aligned, just in view. Then select the “View / Panes / Align Panes” menu option. This will cause both of the lines in each buffer to align themselves to each other.

Once the panes have been aligned, you can keep those lines aligned by choosing the “View / Panes / Enable Synchronized Scrolling”. When either buffer is scrolled, the other pane will match itself. Nice.

You can visually know that synchronized scrolling is enabled for the two buffers because the scrollbars in each buffer will be colored differently (usually in a red color but this can be changed within the theme editor). What’s even better is that pane synchronization is remembered for pairs of editing buffers. Change one of the pane’s buffers and synchronized scrolling is disabled for that pair. Re-select the original editing buffers and they will remain synchronized. Very nice.

To see more information and download your copy of the TKE code editor, visit http://tke.sourceforge.net

Pane Alignment and Synchronized Scrolling

Changing Fonts

Starting with version 2.6, TKE now allows the user to change the font used in the editing buffer, the command launcher entry field, and the command launcher preview display. To make these changes, launch the general user preferences using the Edit / Preferences / Edit User – Global menu option and select the Appearances category in the preferences sidebar.

 

The middle section shows the application fonts that can be permanently set in the application preferences. You’ll notice that next to each font description is a sample of the current font used. To change a font, simply click on the Choose button next to the font. This will display a font chooser dialog window.

The editing buffer fonts will be limited to available monospace fonts installed on your system. The fonts that can be used for the other two font types can be any installed font on your system. To change a font, choose a font name, font style and/or font size and click on the Choose button which will update the associated font immediately within the application. Click on the Cancel button to leave the font alone.

Super simple to change the fonts to your liking with the newer versions of TKE so feel free to make your editing environment your own.

To see more information and download your copy of the TKE code editor, visit [tke.sourceforge.net](http://tke.sourceforge.net).

Changing Fonts

Current Working Directory

The current working directory is the directory on your filesystem where all file system commands made within TKE are executed relative to. The current working directory is used in a few contexts within TKE:

  • Used as the initial directory for open/save file browsing windows when the “Set default open/save browsing directory to:” preference option is set to the value of “current”.
  • Serves as the “Current Directory” search directory for the Find in Files function.
  • Relative filename paths are executed relative to the current working directory (i.e., if the current working directory is /a/b/c/d and a filename is entered as ../foobar, the resulting filename will be /a/b/c/foobar).

The current working directory is stored in the session data so that it is always remembered from session to session. The current working directory is always displayed in the TKE title bar within the square ([]) brackets.

title bar

Setting the Current Working Directory

There are a few different ways to change the current working directory within TKE.

File menu option

Selecting the File / Change Working Directory menu option will display a file browser that will allow you to select a directory to make the current working directory.

Sidebar

Right-clicking on any directory within the sidebar will display the contextual menu for the directory. Select the Make Current Working Directory option to make the selected directory be the current working directory.

sidebar menu

Preferences + Tabs

If the preferences Automatically set the current working directory to the current tabs directory General option is selected, selecting a tab in the tab bar will cause the current working directory to be automatically set to the directory containing the selected file. Note that selecting a tab which does not show a file from the file system will not cause the current working directory to be changed.

img-alternative-text

To see more information and download your copy of the TKE code editor, visit tke.sourceforge.net.

Current Working Directory