Text Formatting

When you are editing files with a syntax type that supports text formatting, you can quickly get tired of adding the syntax that is required for doing things like bolding, italicizing, underlining, etc. However, if you are using TKE to do the editing, then your editor has your back.

If you need to italicize some text that you have already typed, simply select the text and use the Edit / Format / Italics (or use the shortcut Command/Control-I). TKE will insert the correct syntax before or around the text. This functionality is super handy and will save a ton of keystrokes, but TKE’s text formatting capabilities don’t stop there.

If you need to bold some text that you are about to type, simply select the Edit / Format / Bold (or using the shortcut Command/Control-B). TKE will insert the proper emboldening syntax and place the cursor at the appropriate spot to start entering the text to be emboldened. Once you have finished entering the formatted text, if there is bold syntax following the text, simply enter the TAB key to move the cursor to the right of that syntax and continue entering text.

Bonus Tip: Any time that you are editing text and you are not filling in a snippet, hitting the TAB key will advance the cursor to the first whitespace character in the current line (unless the cursor is in the first column when the TAB key is entered).

If you need to remove syntax formatting, simply select the text (including the formatting syntax) and then select the Edit / Format / Remove Formatting (or use the Command/Control-minus keyboard shortcut). Any syntax that can be applied via the text formatting feature will be removed from the selected text.

Text formatting support is currently available for the following syntax descriptions:

  • Markdown
  • MultiMarkdown
  • Fountain
  • HTML
  • HelpSystem
  • ManPage
  • Latex

In addition to text formatting options, TKE also supports the following formatting (depending on the availability of the format support in the syntax):

Text Formatting Submenu

Simple, easy, powerful. TKE might just make text formatting fun again.

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

Advertisements
Text Formatting

Markdown Table Beautifier Plugin

In TKE 3.2 a new plugin called the “Markdown Table Beautifier” is included which, when run, cleans up any table syntax found inside of a Markdown document. This essentially involves, making all table columns be vertically aligned and all cell contents be justified according to their column justification indicators. It also will adjust all rows to include the maximum column specified within a table row. All of this cleanup helps make Markdown tables easier to read in Markdown format.

Essentially the Markdown Table Beautifier plugin can run on all tables found within a single Markdown file or it can run only on the table where the insertion cursor is within.

To install the plugin, select the Plugins / Install… menu option, find the Markdown Table Beautifier plugin in the resulting list, highlight it and hit the RETURN key. Once the plugin has been successfully installed, you can run it by simply selecting the Plugins / Markdown Table Beautifier submenu and choosing one of the two available options to beautify all tables or only the currently selected table. Note that these menu options will only be enabled if the file syntax is either Markdown or MultiMarkdown.

Clean and easy to read tables without the fuss? Check and check.

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

Markdown Table Beautifier Plugin

Line Wrapping

To line wrap or to not line wrap, that is the question! For a long time, TKE did not provide the ability to wrap lines. Why? Well, first of all, line wrapped programming code can be a bit hard to read. Second, it is creating an editing view that may be inconsistent with other users of the file, leading to potential formatting issues (this is the same argument as to why TKE generally replaces TAB characters with spaces when editing). Third, adding a feature like line wrapping can lead to some tricky corner cases in code. Finally, and probably not least, there were other features that TKE’s developers wanted to get into the tool before it 🙂 However, the latest version of TKE (3.2 as of this writing) fully supports line wrapping, so let’s briefly go over how you can put it to work.

Line wrapping support is a feature which is enabled/disabled by each programming language syntax file. So a programming language like C++ will have line wrapping disabled by default while a writing language like Markdown will enable line wrapping by default. You can, at any time and with any language, temporarily override the default line wrapping behavior by toggling the state of the View / Line Wrapping menu option. When line wrapping is enabled, lines will wrap at the editing buffer ruler location (which is controllable in the Preferences window in the Editor panel).

If you want the line wrapping behavior to be remembered between invocations of TKE, you can do so in the Preferences window within the View panel. Here you can set how TKE should determine the line wrapping state using the Line Wrapping Default option menu at the bottom of the panel. The three option values are as follows:

  • syntax: Use the syntax-specified line wrapping indication to dictate if line wrapping should be enabled or disabled.
  • enable: Always enable line wrapping mode.
  • disable: Always disable line wrapping mode.

For Vim users, wrapped lines offer a few additional cursor motion commands which are as follows (note that logical lines share the same line number within the file but displayed lines are created due to wrapping):

  • g0: Moves the cursor to the first character of the currently displayed line.
  • g^: Moves the cursor to the first non-whitespace character of the currently displayed line.
  • g$: Moves the cursor to the last character of the currently displayed line.
  • gm: Moves the cursor to the middle-most character of the currently displayed line.

Once you have “wrapped” your mind around this feature, you can take your editing to new levels of Zen.

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

Line Wrapping

Auto-completing HTML/XML tags

HTML editors have many different methods for handling the auto-completion of tags, that is, when an opening tag is entered in the editing buffer (i.e., “<div>”), the closing tag is inserted immediately after by the editor, saving the user time and keystrokes. Various editors use different strategies for detecting when/how to auto-complete:

  1. When the opening tag is completed (with the closing “>” character).
  2. When the start of the closing tag (the “</” characters) is entered and then use some inference logic to insert the correct closing tag.
  3. Do nothing at all.

Each of these solutions have their pros and cons. For example, solution #1 generally performs quickly since it is relatively easy to get the just entered tag name; however, if the user only wants to insert a starting tag at the current insertion point, the editor is inserting text that the user will now have to spend time removing, saving no time and perhaps taking a bit more time to edit. Solution #2 doesn’t have the downside of #1 since the editor only inserts the closing tag when/where the user chooses; however, it can have a bit of a performance impact since the editor needs to infer which closing bracket to insert. Solution #3 has the most flexibility, but obviously doesn’t attempt to help the user in the more common cases.

For HTML/XML tags, TKE takes a slightly different approach to tag auto-completion, relying on its built-in Emmet support. To insert a tag with Emmet, simply enter the name of the tag without the angled tag brackets and enter the Control-E shortcut. This will replace the tag name with both the starting and closing tags as shown in the animated GIF below.

img-alternative-text

If you need to wrap a block of text with a given tag, select the text to wrap, and select the Edit / Emmet / Wrap With Abbreviation menu option. An entry field will be displayed at the bottom of the window, allowing you to enter the tag name to wrap. After entering the tag name, hit the RETURN key to cause the opening/closing tag to be inserted around the selected text. What is even cooler is that TKE will adjust the indentation so that the code looks good after the insertion occurs.

Using Emmet for tag auto-completion has all of the upsides without the downsides since it gives the user all of the control and then some.

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

Auto-completing HTML/XML tags

Vim Modelines

Everyone seems to have their own favorite editing preferences regarding things like:

  1. Should tabs be converted to spaces?
  2. How many spaces should be used if I hit the tab key?
  3. How many spaces should be for an indentation?

And so on and so forth.

Most editors, including TKE, allow you to specify these various editing preferences to your individual liking, but how should these settings be handled if you are sharing a file with a wider audience? If everyone uses different values and makes edits to the file, the structure of the file is going to look really bad, making the code harder to read and understand.

In smaller circles, you could make a “rule” that everyone must never use tab characters, but this rule is hard to enforce, especially in a larger audience.

Fortunately, for most editors that support Vim, which includes TKE, there is the concept of the Vim modeline. This is a line towards the top or bottom of a file which tells the editor how to handle formatting for the given file. These formatting options are specific to the file and will not mess up your preference values.

To create a Vim modeline to your file, it is best to put it inside a comment block in either the first or second line of the file or at the very bottom of the file. TKE allows you to specify how many lines at the top or bottom of the file to look for a modeline.

The following graphic shows an example of what a modeline might look like:

img-alternative-text

This example modeline sets the file format (endline character) to use the unix format, sets the shiftwidth value to 4 spaces and forces the editing buffer to treat the file as Tcl syntax.

You can learn more about modelines in the official Vim documentation at vimdoc.sourceforge.net.

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

Vim Modelines

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

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