Pasting with Lua
Lua is a nifty little programming language that is quick and easy to implement in VoodooPad. In this tutorial you are going to replace all the text on the current page with something else, effectively pasting in other content. You are 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
You 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 you are working on can just be thrown away later, so it is 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 not replacing the text on the page, it is simply appending it. If replacing all the text on the page is what you wish to do, you will need to start out the script with this: windowController:textView():selectAll()
This will start the script off by doing a Select All, when you paste the text in after that, it will replace everything else.
Saving
When you are happy with the result, choose Save Page as Lua Plugin. Give it a nice name, but make sure it ends with .lua.
You will now notice there is another option under Plugin ▸ Lua. It is the script you just made!
Binding a Shortcut Key
In order to make your 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 VoodooPadLuaPluginSnippets
Back to VoodooPad ▸ VoodooPadTips

