Add a TK shortcut in your LaTeX editing process

What’s “TK” anyway?

You may simply put TK as “to come” in publishing, i.e., the word signifies that there will be more information right on where you put the word. In my opinion, it’s like a shorthand of todo for authors, placed exactly in their writing. For example, one may write

The elegant Euler formula was found by Euler in . He approached . . . 

In this case, the author didn’t know the exact age when Euler wrote the formula, but he wanted to add it later.

Put it in LaTeX!

“How does TK have anything to do with LaTeX?” you may ask. However, in rapid typing process, one may solely puts a reminder indicating future work, instead of heading to the trivial searching process. Hence, such reminders, as TK in traditional publishing, are necessary in LaTeX.

To achieve this, I utilize the IMAP() function in LaTeX Suite Macro, which allows you to add custom mappings in Vim. In this case, I solely added one line in tex_latexSuite.vim:

call IMAP('TK', "\\textbf{Todo:<+ type your todo here +>} -> <+ waiting to be filled +>", 'tex')

The function IMAP(), with the arguments, will be called once I edit a file with tex file type. There are three main arguments for the function: IMAP(lhs, rhs, ft). When the string set as lhs are typed, the function directly transfers the string into that in rhs, while ft indicates which file type to apply (in this case, tex). Notice that there are several special characters in rhs to indicate the setting of the output, such like <+, +>, or \\textbf{} in this case.

Hence, in tex file, when I type

TK

it would immediately turns into

\textbf{Todo: <+ type your todo here +>} -> <+ waiting to be filled +>

When the line shows up, your Vim editor will turn into SELECT mode, with the range covered by <+ and +> selected. Hence you may type what you are going to add later without any further movement of your cursor. Moreover, after you finish your sprint of writing, you only need to press Ctrl + j to jump between each TK.

Screencast

TK.gif

References

  1. Making your own Macros via IMAP()
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s