But there is a way.
Step 1: Create a User-Defined Command
First we’re going to set up a
:VimClippy Ex command to insert the current content of the clipboard into a buffer and set up the autocommand to write the edited text back into the clipboard when the buffer is saved.
Open up your
vimrc1 and enter the following:
function! s:vimclippy() abort edit vimclippy silent put! + $delete 1 augroup vimclippy autocmd! autocmd BufWriteCmd vimclippy %yank + | set nomodified augroup END endfunction command VimClippy call s:vimclippy()
Step 2: Set Up a Shortcut
Next, we need a method of running iVim and immediately calling this command in an AUTOMATED fashion. iVim does support passing in the command line arguments that we used in the shell version, but the mechanism2 isn’t suitable for our purposes.
:help ivim-url-scheme. For a beginner’s guide to URLs and their dastardly schemes, check out my nine-year-old guide to automating your phone with
In Shortcuts, add a new Shortcut and add an
OpenURLs action. For the URL, enter
When the shortcut is run, this will fire up iVim and invoke the VimClippy command we set up in Step 1. Give your shortcut an appropriate name and icon, and then you can “Add to Home Screen”.
Step 3: Configure iVim
Open the iOS Settings app and find the iVim section. Scroll down to the bottom and toggle the URL SCHEME switch to Allow so that iVim will respond to your new URL. Optionally, you can also set Paste from Other Apps to Allow to stop iVim from asking you if you want to paste in your clipboard contents every time the shortcut is run.
Step 4: PROFIT!!!
Try out your new shortcut, and REJOICE at the EASE with which you can now edit your clipboard contents.
If you don’t have a vimrc,
:e ~/.vimrcwill create one for you in the default location. If you do already have one,
:e $MYVIMRCis a better command to use, as it’s set to the location of the vimrc that Vim found during startup. ↩︎
You type them into a textbox in the Settings app. ↩︎
If you have a favourite app launcher (Launch Center Pro is the one I use), then you can use the same URL in that instead. I’m using Shortcuts in this tutorial because it’s free and supported by Apple themselves. ↩︎