May 13, 2017
I wanted a quick and convenient cheatsheet to use with Vim. Additionally, it needed to be dynamic such that it only included the things I was trying to learn. And once those things were ingrained in my fingertips, there should be a way to remove the tips (the cheatsheet tips, not my fingertips) from my cheatsheet. And ideally, adding and deleting tips from my cheatsheet should be quick and relatively effortless. That’s when I came upon the idea of having my screen background become my cheatsheet.
Create a file called vim-background.txt. While you can keep it anywhere on
your filesystem, a good place might be in your .vim directory. If you’re using
vim to write this file, you may want to :set softtabstop=44 :set tabstop=44
:set shiftwidth=44
and set columns=132
so that you can have two or three
columns of information and easy tabbing to keep your columns neat and ordered.
Update the file with your favorite vim related commands and difficult to remember keybindings. Obviously this will change with time, so easy editing and deploying of this file as a background makes sense.
Converting the background text file to a PNG file is done with the convert
utility that is found in the Imagemagick package. You may have difficulty
getting the convert
command to work if some of the permissions are too
restrictive in your default Imagemagick installation. You can liberate those
permissions by editing /etc/Imagemagick/policy.xml
and changing the rights
from none
to read|write|execute
for pattern="TEXT"
and pattern="@*"
.
/etc/ImageMagick-6/policy.xml
...
<policymap>
...
<!-- <policy domain="resource" name="temporary-path" value="/tmp"/> -->
...
<!-- <policy domain="coder" rights="none" pattern="TEXT" /> -->
<policy domain="coder" rights="read|write|execute" pattern="TEXT" />
...
<!-- <policy domain="path" rights="none" pattern="@*" /> -->
<policy domain="path" rights="read|write|execute" pattern="@*" />
</policymap>
Once those changes are made to your ImageMagick setup, change to the directory where you’ve created your vim-background.txt file and run the following command:
convert -size 1500x1500 canvas:DarkSlateGray -font "FreeMono-Bold" -pointsize 24 -fill white -annotate +15+15 "@vim-background.txt" -trim -bordercolor gray -border 10 +repage vim-background.png
Change your background to the newly generated file vim-background-image.png
.
How this is done varies depending upon your window manager and set up.
And lastly, might I suggest an alias for the above convert
command. It’s a
bit much to type and not so easily remembered.