Sublime Forum

Macro Help

#1

I am trying to make a macro to copy the contents of the current file, open a new one, paste the contents, apply a ROT-13 , copy the result of that, and close the created file

The problem I am having is creating the new file and closing it when I am done.
This is what I have so far :

{
	"args": null,
	"command": "select_all"
},
{
	"args": null,
	"command": "copy"
},
{
	"args": null,
	"command": "new_window"
},
{
	"args": null,
	"command": "paste"
},
{
	"args": null,
	"command": "select_all"
},
{
	"args": null,
	"command": "rot13"
},
{
	"args": null,
	"command": "copy"
},
{
	"args": null,
	"command": "close_file"
},

]

0 Likes

#2

Hi there,

I’m very new to Sublime Text commands (and was sad to discover that the documentation is incomplete/inaccurate), but this should help.

If your goal is to copy all ROT-13’d text to clipboard and leave the source text untouched, there’s no reason to create a new window. Simply ROT-13 it, copy it, then ROT-13 it again.

{ "command": "select_all", "args": null }, { "command": "rot13", "args": null }, { "command": "copy", "args": null }, { "command": "rot13", "args": null } ]

Save as e.g. rot13copyall.sublime-macro in Packages/User. Works for me in Sublime Text 2. Current v3 beta (build 3012) seems to have broken ROT-13.

0 Likes

#3

Thank you I forgot that ROT-13 can do that.

0 Likes

#4

Would it be possible to make it return to the line it was at before the macro was ran?

0 Likes