This is my iVim setup.
VIM and iOS, finally together, with Git and Plugins.
There are numerous nice editors on the iPad, such as Textastic. But if you’ve spent years establishing the muscle memory with Vi(m), switching to a non-vim-like editor is hard. I recently came across iVim, an excellent port of Vim to iOS. With new support for mapping hardware keyboards in iOS 3.4, you can even have an escape key, or map caps-lock to something useful.
I’ve taken keeping my .vimrc
file relatively bare in recent years, offloading the complexity to plugins instead. Replicating the use of Plugins on the iPad turns out to a little painful. I found some useful guides online, but I wanted an approach that (a) had minimal faffing amount, and (b) was versioned.
Here’s where another fabulous iPad app steps in: Working Copy, a git app for the iPad that is easier to use than the apps on the Mac (go buy this right now—it is awesome!).
- Get iVim on your iPad (it’s free, but for the price of breakfast, you can support this project).
- Get Working Copy on your iPad (again, free for just cloning. But well worth the money for a pro upgrade).
- Clone this repo using Working Copy. This repo is full of submodules (these are the plugins). Working Copy will ask if you want to clone all the submodules too. You’ll need to do that too. If you neglect to do it at first, you can clone them by going into each separate folder and selecting “clone”.
- The home folder of ivim is
On my iPad/iVim
. iVim will have easy access to everything in this folder (it can access other things using theidocument
command — see the docs). We want to put this repository and all the submodules into that folder. Working copy has an easy way to do this, via itsSynced Directory
functionality. Whilst in the ivim folder in Working Copy, hit the share button (the up-arrow on the top right), and pickSetup Directory Sync
. Then create a folder calledivim
under theOn my iPad/iVim
folder and sync it. Working copy will synchronise that folder with the repo folder, so everything you just cloned is now copied to that folder. - The last thing to do is to open iVim and create your
.vimrc
file to take advantage of all the plugins. You just need to add one line to this file:source ~/ivim/vimrc
. Your.vimrc
simply loads thevimrc
file that is in the repo, and synced to this folder. This file uses pathogen to load all of the plugins in the submodules. - Exit iVim and restart it. If all has gone well, all of the plugins will be available.
- Make any configuration changes to this
vimrc
and not in your actual.vimrc
in the home folder. Any changes will be synced to Working Copy, and you can commit and push them to your git repo.
The set of plugins in this repo are what I’m currently playing with on the iPad. They’re mostly for writing in markdown or LaTeX, some additional buffer/file handling, and a great set of colour schemes. Many modern plugins rely on other system tools that aren’t available on the iPad. So I’ve chosen plugins that require only vim-script (VimTeX is an exception; but I only use some parts of it). There are plenty of other plugins you can install, but be not all of them will work on the iPad.
Although Working Copy supports submodules cloning, I have not found an easy way of adding and removing submodules on the iPad, so I do this my Mac.
Clone the repo locally, then add or remove plugins using the git submodule commands. Adding submodules is easy, removing them requires a bit of faffing about.
Adding a new plugin:
[~/code/ivim]$ git submodule add https://github.com/frazrepo/vim-rainbow
Removing a plugin (details here):
[~/code/ivim]$ git submodule deinit vim-rainbow
[~/code/ivim]$ rm -rf .git/modules/vim-rainbow
[~/code/ivim]$ git rm -f vim-rainbow
Updating your plugins:
[~/code/ivim]$ git submodule update --rebase --remote
Push any changes, then use Working Copy to update everything on your iPad.
Raise an issue if you have questions.