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.
I don’t know about you, but in the past, I’ve spent a lot of time editing files where I write a line of code which contains a number, duplicate that line a bunch of times, and then proceed to change the number in each line such that they increment by one. The following animated GIF illustrates the problem.
Wouldn’t it be nice if our editor helped us do this type of enumeration more quickly? With multicursor capability, TKE can make this editing task no longer a chore.
After creating the lines of code and duplicating them, hold the SHIFT and ALT/OPTION keys and click and drag a block selection on the numbers in each line. Once all numbers have been selected, select to the Edit / Insert / Enumeration menu option and enter the number “1” in the field at the bottom of the window followed by hitting the RETURN key. This will cause the first line to be numbered a decimal value of 1 and have each line be incremented by 1. Finally, hit the ESCAPE key to exit multicursor mode.
TKE also supports creating enumerated values for other bases besides decimal, including binary, octal and hexidecimal. Here’s a few other examples of how to specify the starting value (we’ll use our graphical example to show its effect).
“32’dd10” => “This is line 32’d10. This is line 32’d11. This is line 32’d12…”
“b0+2″ => “This is line 0. This is line 10. This is line 100…”
“0oo6” => “This is line 0o6. This is line 0o7. This is line 0o10…”
“0xxf-1″ => “This is line 0xf. This is line 0xe. This is line 0xd…”
“16’hhf” => “This is line 16’hf. This is line 16’h10. This is line 16’h11…” (i.e., ‘x’ and ‘h’ both indicate a hexidecimal number)
By default, if nothing is entered in the number entry field and the RETURN key is pressed, a decimal value of 0 will be used as the starting value.
Special note for Vim users: If you select the numbers using the “s” and “Shift-s” keys to cause multicursors to placed at the beginning of each number, you can use “dn” to delete the number and use “#” (pound key) to bring up the enumeration field. Super quick way to do this type of edit without touching the mouse.
So why risk repetitive strain injury? Use your time and keystrokes to get more complicated things done with TKE.
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.
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:
When the opening tag is completed (with the closing “>” character).
When the start of the closing tag (the “</” characters) is entered and then use some inference logic to insert the correct closing tag.
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.
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.
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.
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.
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.
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.
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.
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.