- 1 Vapor IO Brings OpenDCRE to General Availability
- 2 VMware Takes the Wraps Off vRealize Automation and vRealize Business
- 3 Microsoft Previews Hyper-V Containers for Windows Server 2016
- 4 Mirantis Led FUEL Project Gets Installed Under OpenStack Big Tent
- 5 Red Hat Enterprise Linux 7.2 Adds Security, DR Features
Open Source Software Shortcut, Permanently Storing Macros in Vim
A really useful feature of the open source editor Vim is the macro command, which allows you to record and reply a series of commands. To start recording, hit "q" then "a" (or any other lowercase letter identifier). The status bar at the bottom will show recording. Enter your commands as normal, then hit "q" again to stop recording when you're done. To replay the macro, type @a.
So far, so good, but a macro saved like this will not last between sessions. However, the macro is saved into a normal register in the same way as yanked text. To save it permanently, open your ~/.vimrc file in the same session, and use "ap" to paste in the macro commands. Then edit the line to add a mapping, so it looks like this:
map ,PARA v}y}p
This maps the command, PARA to a short macro, which copies the next paragraph, then pastes it underneath. This mapping will be loaded every time you open a new Vim session.
If you find yourself doing this often, it may be worth checking out the marvim vim script, which provides hotkeys to store macros and templates. This also allows you to tab-complete macro names, which is helpful if you have a lot of them.
For occasional use, however, it's just as fast to do it by hand.
Juliet Kemp has been messing around with Linux systems, for financial reward and otherwise, for about a decade. She is also the author of "Linux System Administration Recipes: A Problem-Solution Approach" (Apress, 2009).