I suspect that the best answer for what I imagine is your use-case would be for someone to write a Word or LibreOffice macro, but I wouldn't even know where to begin with that.
However, you could use Vim for this -- specifically gVim, which has a Windows version. This takes a little bit of setting up, but I think the results are worth it.
Note: While it's nowhere near as mind-bending as its critics would have you think, learning Vim is non-trivial, and beyond the scope of this answer. If you want, once you've installed gVim, you can use the Start menu to search for 'Vim Tutor' (without the quotes) to get an interactive tutorial of the basics. It's well worth learning, if you can get your head around it.
First of all, download & install gVim from here.
You'll also need the abolish.vim plugin for its
:Subvert command. Quick installation instructions for this (once you've already got gVim installed):
- Create the directory
C:\Users\YOURUSERNAME\vimfiles, and then the directories
- Download Pathogen, which is a plugin manager for Vim -- it's easiest to just grab the zip file and unpack it in
- Download the abolish zip and extract it to the bundle directory
- Create a text file called
C:\Users\YOURUSERNAME, and put the following lines within it:
Now you need to create your cypher file. This will actually be a plain text file with commands for Vim. It should look something like this:
"paste from the clipboard into vim:
"The substitute commands
"Make sure you use %S rather than %s
"The 'silent!' prevents error messages
"delete the blank line which vim will have added:
"cut the text into the clipboard:
Let's say you have the following paragraphs:
The quick, brown fox jumps over the lazy dog. The quick, brown fox jumps over the lazy dog.
'Quick!' shouted the dog, uncharacteristically, to the fox: 'Jump over me!'
...and you want to run your cypher over it, so that every instance of 'quick' will be replaced with 'varryn' and so on. First, copy the text from your word document (or whatever). Then, open gVim and type the following (pressing enter at the end):
After this, you can just paste the paragraph back into your word document, et voilà:
The varryn, brown drugar jumps over the lazy foob. The varryn, brown drugar jumps over the lazy foob.
'Varryn!' shouted the foob, uncharacteristically, to the drugar: 'Jump over me!'
You might not want to have to type out the full path to your cypher file; you could put the following line at the bottom of your
command Cypher :source C:\path\to\cypher.txt
With this, you can simply type
:Cypher (and press enter) without having to remember where the file is each time.
Additionally, if you type
@: within Vim, the previous command-line mode command (those starting with a
:) will be repeated; so if you were translating multiple paragraphs, you would only need to type
:Cypher the first time, and for all additional occasions (for as long as you leave Vim open) you could just use
Note on the Cypher File
You stated in one of the comments that you already have a cypher set up. You can use gVim to transform this into the syntax needed here, rather than typing it all up again.
I'm assuming your cypher is set up in a way similar to this -- if it's not, you can drop a comment & I'll modify this accordingly:
Copy the lines from whatever file they're currently stored in, and open gVim. Type the following:
"*p -- this will paste from your system's clipboard (rather than one of Vim's many internal clipboards -- called 'registers' by Vim).
(If you're using non-English letters, some of them might not show up properly, because the default typeface is not very good. On Windows, you should have access to the excellent Consolas; type
:set guifont=Consolas:h10 (you can put this command in your
_vimrc, or alternatively in a
_gvimrc file, if you like).)
Then type the following command (and press enter at the end):
:%s/\([^ ]*\) \(.*\)/silent! %S\/\1\/\2\/g
It's quite a long one, so if you're afraid of mistyping it, you can copy it from this answer, and then type into Vim
q: (which should bring up a little frame at the bottom of you gVim window), followed by
"*p to paste the command in, and then press enter.
You should now have lines like this:
Next you need to insert the other commands needed to run the cypher. Type the following commands (pressing enter at the end of each one):
After these, you should have a file that looks something like this:
Now you just need to save it:
And exit gVim with
- Vim is a plain text editor -- it has no idea what 'italics' or 'bold' mean, so running rich text through it will strip away that stuff. There might be a way around this, if it really matters to you, but it will involve installing additional programs. (Or you could write your novel in markdown, like all the cool kids :V )
- There's no problem with single-quotes (
'), but if you want to include the double-quote anywhere in your cypher text you'll have to precede it with a backslash (because
" is used for comments in Vim command files)