When editing files, sometimes it is necessary to execute a shell command and paste the results into your edited content. In a basic editor, this would be accomplished by starting a terminal, entering the command, and then copying/pasting the result back into the editor. However, with TKE, you can accomplish this task without leaving the editor and without installing a plugin.
There are essentially two different ways to insert shell output into an editor. One method uses a menu command and the other is available when editing in Vim mode.
Menu-based Command Insertion
Start by entering in the shell command that you would like to execute into the editing buffer at the position where you would like the command results to be placed. In this example, we want to place the directory contents starting at line 3, so we enter the command “ls” which is the standard Unix command for listing the current directory content.
Once we have our command entered to execute, place the cursor anywhere on the line containing the shell command and select the “Text / Replace Line With Script” menu command. This will remove the shell command and replace it with the returned output of the command.
Vim Mode-based Command Insertion
If you are a Vim user, you can insert a shell command result into the editing buffer by placing the insertion cursor one line above the line where you want to insert the text and using the command:
So in our example above, our starting text would look like:
With the cursor placed on line 2, we enter the command:
which results in the same output as we saw in the above example.
Of course, if you are running on a Windows box, you would replace the “ls” command with the “dir” command. Any commands executed are executed in the current working directory (as shown in the title bar).
To see more information about the TKE code editor, visit http://tke.sourceforge.net