Default Open/Save Dialog Directory

Whenever you need to open or save a file/directory, the open/save dialog window will display the contents of a directory. Sometimes that directory is the one that you want, but other times you may find yourself constantly using the file system browser features in the dialog window to change the directory. This can get tiresome if you are doing this often, but TKE can offer some help by making the default directory smarter and more customizable.

To change the way TKE chooses the default directory in the open/save dialog windows, head on over to Preferences (Edit / Preferences / Edit User – Global menu option) and go to the General tab within the General panel.

 

The last option in the tab specifies “Set default open/save browsing directory to:” with a dropdown list containing four options:

  • Last accessed:  TKE will remember the last directory that was in use in an open/save dialog window and use that directory as the default directory the next time the open/save dialog window is used.
  • Current editing buffer directory:  The directory containing the file which is the current editing buffer will be used as the default directory.
  • Current working directory:  The current working directory will be used as the default directory. The current working directory is always displayed in the title bar of the main window and can be changed at any of the methods discussed in our Current Working Directory post.
  • Use directory:  When this option is selected, a directory selection window will be displayed. Use it to navigate to the directory that you want to use as the default directory for subsequent open/save dialogs. The selected directory name will be displayed in the preferences window.

You can change this preference option at any time and, like most TKE preference changes, its selected value will be immediately applied within TKE.

If you using TKE in Vim mode, you can also change this option without needing to open Preferences. Just use the :browsedir value (or :bsdir value) command option and in place of value, use the values of:

  • last: Same as “Last accessed”.
  • buffer: Same as “Current editing buffer directory”.
  • current: Same as “Current working directory”.
  • Or specify the absolute or relative pathname of the directory to use.

Note that changing the default directory using the Vim command will not be remembered when you quit TKE (the preferences value will be the one used upon application startup), so using this method is a terrific way to temporary override the current behavior.

Sweet.

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

Default Open/Save Dialog Directory

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

Sidebar Ordering and Keyboard Selection

A couple of quick sidebar tips for you.

Tip #1: File/Folder Ordering

Depending on your operating system and personal preferences, you may be more accustomed to having all of the folders grouped at the top of a folder’s listed contents while all files are listed below. Or perhaps you prefer to have your files and folders intermixed in alphabetical order. Whichever way you prefer to view files/folders in the sidebar, TKE has you covered.

To switch the sidebar file/folder ordering, head on over to preferences (Edit / Preferences / Edit User – Global menu option), select the Sidebar panel and make sure that the Behaviors tab is selected. Simply toggle the checkbutton labeled Show Folders at Top to cause the sidebar to display folders first or folders intermixed.

image-2

Tip #2: Keyboard Selection

If the sidebar has keyboard focus, you can quickly select a file or folder within the current folder by typing the name of the file. As long as you enter the successive characters within a second of each other (the default time), the characters will be appended to the current search string; otherwise, waiting beyond a second will cause the search string to clear out and entering another key will select the first file/folder matching the new search string.

If one second between characters is not enough or too much time, you can adjust the value within the same Sidebar / Behavior tab within preferences, by increasing/decreasing the Append characters to search string if entered within: value.

And since we are on the topic of using the keyboard within the sidebar, you can always select the parent folder by hitting the left arrow key and you can open the currently selected folder by hitting the right arrow key. This means that you can quickly change the selection of any file/folder within the sidebar using only the keyboard.

Your mouse or trackpad might get a bit lonelier with these tips.

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

Sidebar Ordering and Keyboard Selection

Deleting Vs. Trashing

The TKE sidebar is a powerful tool for managing your project’s file system, including the ability to quickly create, rename, duplicate and delete files and folders without leaving TKE. But the sidebar has a somewhat hidden trick which allows you to choose whether to delete an item or send that item to the trash.

What’s the difference between deleting and trashing? When you delete an item, that item is permanently removed and cannot be easily recovered. Because of its nature, TKE will always ask the user for confirmation before allowing a delete command to take place. When you trash a file, you are basically moving the file to a special directory on your computer which has the ability to remember where its contents came from, allowing you to quickly put the file/folder back where it came from. Trashes also have the ability to delete all of their contents with a single command and they generally make their content read-only. Because sending a file to the trash can be easily reversed, TKE will not bug you with a confirmation dialog when you send something to the trash.

So how do you choose between deleting and trashing within TKE? Head on over to preferences (Command-. on macOS or Control-. on Windows/Linux) and change the Show Move To Trash for local files/directories instead of Delete checkbox to the desired value.

img-alternative-text

It’s important to note that you cannot move remote files (i.e., any file system that was opened via FTP, SFTP or WebDAV) to the trash, you can only delete those files. If you have the preference setting to show the Move to Trash option in the sidebar menus and you show the sidebar menu for a remote file, the Delete option will automatically be displayed.

Sweet.

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

Deleting Vs. Trashing

Syntax Management

You know that TKE has syntax highlighting and editing support for lots of programming languages and file formats which helps make TKE useful for a wide spectrum of users. However, because any one individual probably only uses a dozen or so in their normal workflow, displaying all of those unused languages is unnecessary. Fortunately, TKE has a solution that helps eliminate the language clutter in the UI.

Go to the Preferences window (Edit / Preferences / Edit Global – User), select the General pane and then the Languages tab as shown in the image below.

Language Preference Table

The languages table displays a listing of all supported languages within the application. To hide a language from view in the View / Set Syntax submenu and the syntax menu in the lower right-hand corner of the main application window, simply deselect the checkbox next to the syntax to hide. Likewise, you can unhide a language from view by selecting the checkbox.

Though hiding a syntax helps keep language clutter from occurring in the menus, it does not disable TKE from identifying and highlighting files of hidden languages if they those files are opened.

Since we are in the language management table, we’ll also point out that this table displays the syntax extensions for each language. If a file of a particular extension is opened, TKE will use the information from this table to automatically identify which syntax highlighting to apply to the file. The default extensions come from the TKE syntax description files. If you need to add, delete or change file extensions, simply click on the table cell to edit and make the appropriate changes.

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

Syntax Management

Managing Themes

Themes in TKE control the look of the editor. Themes can alter the look of the window elements such as color, size, thickness, etc. They can set the colors used in syntax highlighting. They can also set the various icons used throughout the application.

TKE has several different themes that you can choose from via the View / Set Theme submenu. Just select a theme from the available list to cause the UI to immediately update. However, using the menu will only cause the theme to be changed while the application is running. If you close TKE and restart it, TKE will use the theme that was set in the preferences area.

To change the theme via the preferences window, launch the preferences (via Edit / Preferences / Edit User – Global menu option) and select the Appearance panel in the sidebar. The first option in the panel will allow you to set the default theme to use when launching TKE.

image-12
Setting Default Theme in Preferences

But what if you want to try out more themes can come built into TKE? Well, TKE has a way to import new themes using the Manage Themes tab in the Appearances Panel. Selecting that tab will display the list of all themes that are currently available within the application.

image-86
Theme Manager

The theme table displays all of the available themes within TKE. You can change the visibility of themes by clicking on the checkbox in the Visible column of the table. If a theme’s visibility is turned off, the associated theme will not be displayed in any of the theme selection menus. This can be useful for hiding built-in themes that you are not interested in using.

To get new themes, click on the Get More Themes… button in the lower right corner of the panel. This will launch your web browser to the new TKE themes page where you can browse, filter and download other available pre-built free themes. When you download a theme from the website, to install the theme you can click on the Add button which will launch a file selection dialog window. Find the downloaded theme and click on the Open button to install the theme.

In addition to installing new themes, you can also delete previously imported themes by selecting the theme and clicking on the Delete button. You can also edit any theme by selecting the theme and clicking on the Edit button. This will launch the theme editor (which will be a topic of future conversation).

Themes are not just eye candy within TKE. Each saved session can set its own theme, making themes useful for session identification.

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

Managing Themes

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