Pasting with Lua
Lua is a nifty little programming language that is quick and easy to implement in VoodooPad. In this tutorial we're going to replace all the text on the current page with something else, effectively pasting in other content. We're then going to bind it to a shortcut key for quick use later. This can be great if you want to have multiple page templates for one pad, or if you just have to paste something in a lot and would rather have a shortcut key for it.
Note: This works with VoodooPad and VoodooPad Pro, but not for VoodooPad Lite.
Setting up a Work Area
We need to start with a blank page. You can create this in a document you already have, or by starting a new one. The page that we're working on can just be thrown away later, so its really not important.
Programming
In that blank page, paste this:
windowController:textView():insertText ("Hi")
Choose the menu
Plugin->Lua->Run Page as Lua Plugin
You'll see it paste the word "Hi" (without the quotes).
Edit where it says "Hi" with whatever you want. Make sure that whatever you do is surrounded by quotes and ends with ")". If you need to make a new line, you should write "\n" without the quotes instead of hitting return. If you need to make a few lines just keep typing \n.
Test out your script by choosing the
Run Page as Lua Plugin option as many times as you want. Just make sure to delete the results before trying again.
You might have noticed that this isn't replacing the text on the page, its simply appending it. If replacing all the text on the page is what you wish to do, you'll need to start out the script with this:
windowController:textView():selectAll()
This will start the script off by doing a
Select All, when we paste the text in after that, it will replace everything else.
Saving
When you're happy with the result, choose
Save Page as Lua Plugin
Give it a nice name. Just make sure it ends with .lua
You'll now notice theres another option under
Plugin->Lua. Its the script you just made!
Binding a Shortcut Key
In order to make our script into a keyboard shortcut, go into
VoodooPad->Preferences->Shortcuts. Navigate to
Plugins->Lua->ScriptNameHere and give it a shortcut key. If the keyboard shortcut is already being used by something else, VoodooPad will prompt you, asking what to do.
If you want to do additional steps, or go in a different direction, it might be helpful to check out a list of easy to use
Lua Snippets
Back to
VoodooPad ->
Tips and Tricks