I Love Quicksilver’s way with text files
Why would I need this?
You work with text files often, and would love a way to easily add, change, or delete text within those files on the fly, without opening them.
And yes, Quicksilver does that!
How do I …
We’re going play with part of a text file from Mathias Bynens’ OS X dotfiles, which lists a number of Terminal commands to change your Mac’s settings. (I highly recommend checking it out. There may be some settings there you didn’t know you could change!) Below is a screenshot of some of the commands, saved as a text file.
We want to add a note to the second comment without opening the file, searching for the line, saving the file and closing the window. (Waaaay too much work.) To do this, we’re going to use the
Change To… action, which allows you to change a line within a text file. In our screenshot below, we’ve got our text file in our first pane. (We selected the file in Finder and then pressed
command-escape to pipe the file into Quicksilver. We could have also typed in some of the letters of the file name to have Quicksilver search for the file.)
To the right, there is an icon of a gear with the words
Large Type below it. That is the second pane of Quicksilver, where we select the action we want to perform.
By the way, it’s best if the file is closed while performing these actions. In certain situations, you can edit a text file using Quicksilver while that file is open and have the changes you make via Quicksilver save, but that’s not always the case.
If your Quicksilver looks different from the screenshots, we’re using the Cube Interface, available in Preferences > Plugins. After installing it, go to Preferences > Appearance to select and customize it.
right arrow key gives us every single line within our text file, each as a separate actionable item in our results window. (We can do this with any text file, as long as it has a
text extension.) We’ve resized the results window to see more of the lines.
We know that the line we want to change contains the word
screenshot. To reduce the number of results returned, we’ll type this so Quicksilver can fine-tune our search results.
With less results to wade through, we can easily find and select the line we want to change. Now that we’ve done that, we can press
tab to go to second pane.
In the second pane, we’ll type
change to until it appears. On the left is a minimized icon of our text document, sitting in our first pane. At the top, a summarization of what we’ve entered so far. On the right, a minimized icon of text in our third pane. There’s a reason it’s not empty. Let’s
tab there and find out why.
Our third pane comes pre-populated with the line of text we want to edit, already selected. Quicksilver placed it here when we selected the line of text we wanted to act upon. Since we only want to add to the line, so we’re going to press the right arrow key to move the cursor to the end of the line. (If you make a mistake and start typing, unintentionally erasing text you want to keep, press
control-z to undo.)
We’ve pasted a note to the end of the line. Now, we’ll press
enter to add our edits to the file.
Opening our file, we can see the line has been updated.
Other useful actions are
Append Text… and
Append To…. We’ll talk about the difference between two after looking at
We’re going to work with a different text file containing other commands from Bynens’ OS X dotfiles.
Wait. We forgot to add a command, and it’s a really useful one. We’ve copied the forgotten command on our clipboard; now, let’s add it to our file.
Activate Quicksilver. Below, we’ve typed
findef to search for our file and it appears in the first pane. (If a different file appeared, we could either press the
down arrow key or wait a few seconds for Quicksilver to present a window of the other files which matched our search.)
We want to use a different action, so we’ll tab to the second pane and type
append. The first action which matches is
Append To…. After a brief delay, Quicksilver displays the other match,
Let’s tab to the third pane to enter the text we want to append. Here is where we paste the text we want to append and press
enter. Before we do, one thing to note is that Quicksilver will add a new line if the last line of your text file is not blank. If the last line of your text file is a blank line, Quicksilver will add your text on that last blank line.
To add blank lines before the text we’re appending, we’ll press
option-enter before pasting our text.
Let’s go check our file.
And there’s our addition, at the end of the file
Append To is the essentially the same action, except that the first pane contains the text you want to append and third pane contains the file.
Prepend Text… and
Prepend To… work the same way, except that they add text to the beginning of the file.
What if you need to add text before or after a line in a text file? That’s easy. You can select a line of the text file (as we did earlier in when using the
Change To… action), then use
Prepend Text… to place your new line of text before or after the selected line. Similarly, you can place your new line of text in the first pane, choose the
Append To or
Prepend To… actions, then select the line of text to place your new line of text before or after.
Wait! We almost forgot
Delete Line, which does exactly what it says it does. In the screenshot below, I’ve already selected the text file, displayed the lines contained within, and navigated to the last line of our file.
Now, we simply tab to the second pane, type
delete line (or
delline or even
leten), and press
enter when the
Delete Line action appears.
Our file now is missing that last line. All of this with a few keystrokes, and Quicksilver.
Why doesn’t it work on my Mac?
Note that in order to use these actions, you need to install the following plugins and you may need to change your Quicksilver preference settings:
- Text Manipulation Plugin
After you’ve installed the plugin, you’ll want to enable the actions you want to use. In our screenshot below, only the append actions are enabled. If you plan to use all the actions, you’ll want to check the others as well.