ATIX AG
  • Services
    • Consulting
      • Linux Platform Operations​
      • Infrastructure Automation
      • Container Platforms and Cloud
      • DevOps Processes, Tooling and Culture
      • Cloud Native Software Development
    • Products
      • orcharhino
        • About orcharhino
        • Support
        • orcharhino operation
      • Hangar
        • About Hangar
        • Hangar Roadmap
        • Hangar Community
    • Technologies
      • Ansible
      • Docker
      • Foreman
      • GitLab
      • Istio
      • Kubernetes
      • Linux Distributions
      • OpenShift
      • Puppet
      • OpenVox
      • Rancher
      • Rundeck
      • SaltStack
      • SUSE Manager
      • Terraform
  • Trainings
    • Ansible Training
    • Container Training
    • Docker Training
    • Git Training
    • Go Training (Golang)
    • Istio Training
    • Kubernetes Training
    • OpenShift Training
    • orcharhino Training
    • Puppet Trainings
    • Terraform Training
  • Events
    • Webinars
  • Blog
  • Company
    • About Us
    • References
    • Corporate values
    • Social engagement
    • Newsroom
    • Newsletter
    • Contact us
  • Career
  • Search
  • Menu Menu

Registers and Macros in Vim

Chemnitz Linux Days 2023—and ATIX in the thick of things! In his talk, our Senior IT Consultant Jan Bundesmann presented registers and macros in Vim. The contents in a nutshell:

▶ Registers in Vim are named clipboards
▶ Access to a system clipboard via registers + and *
▶ Macros allow recording of repetitive work
▶ Macros are stored as registers

Below, you can find a few excerpts from the presentation:

Short introduction of the terminology

Clipboard CTRL + (SHIFT +)C / Copy & Paste
Primary selection

Marked text, can be inserted in a different place with the middle mouse button

Registers Internal intermediate storage in Vim

Copy and paste in Vim

{ycd} yank / change / delete until the end of the movement
yy|cc|dd yank / change / delete der vollständigen Zeile
p|P paste vor oder nach der Cursorposition
{ycdp} perform yank / change / delete on the visual selection

Registers

▶ Save data in registers and call up from there
▶ Named Registers

”x{ycdp} Access to Register x for the next activity
””{ycdp} Access to Default or Unnamed Register for the next activity

“presentation”>48 available registers

see :help registers for reference
unnamed
read-only
%
named a to z alternate file
small delete
expression
numbered
0 to 9 last search
selection
*, +, ~ black hole
_

Macros

▶ Every action in vim is a set of key strokes.


Activities can be repeated in two ways:

▶ Write down keyboard shortcut
▶ Store them as macros


Recording

1. Startrecordingmacros x by pressingqx
2. Enter your commands
3. Stop recording by pressing q again


Replay

1. Press @x to replay macro x
2. If desired place a multiplier in front: 5@x
<n</n


Modifiy macros

Vim saves macros in registers. That becomes obvious when you look at all registers (:registers). To make changes, simply overwrite the existing register:


1 “xp
2 # modify macro and visually mark it
3 “xy

This is how you create a similar macro:

1 “xp
2 # modify macro and visually mark it
3 “zy


Recursive macros

What happens when a macro x calls itself?

1. Make sure the macro is empty: qxq

2. Record macro, don’t forget to call it at the end
1 qx
2 <do< span=””> SOMETHING></do<>
3 @x
4 q

The macro will run until it produces an error.

Hier you can find the entire presentation and a video stream of the talk. Enjoy!

You might also like
orcharhinoHow to install a WLAN access point on Fedora
Migrating Git
Terraform vs. OpenTofuTerraform vs. OpenTofu: Which solution is right for your company?
Btrfs vs ZFS: Die Zukunft der Dateisysteme ATIX BlogBtrfs vs ZFS: The future of file systems
fpm – the fast track to the parcel
orcharhinoMigrating CentOS 8 to Rocky Linux 8 or AlmaLinux 8 using orcharhino

Jan Bundesmann
+ postsBio
  • Jan Bundesmann
    https://atix.de/en/blog/author/janb/
    ATIX at ConfigMgmtCamp 2024
  • Jan Bundesmann
    https://atix.de/en/blog/author/janb/
    Switching from Docker to CRI-O
  • Jan Bundesmann
    https://atix.de/en/blog/author/janb/
    Installing OpenShift through Foreman
  • Jan Bundesmann
    https://atix.de/en/blog/author/janb/
    Mouse-free
Expertise that Drives your IT Forward

🔔 Technology. Trends. Dates.
Stay up to date with the latest IT developments and upcoming events. Subscribe now and stay informed.
👉 Subscribe to our newsletter »

💡 Tackling complex IT challenges?
We consult — strategically and hands-on. Future-proof your IT with expert consulting.
👉 Learn more »

ISO Certified Certificate
Newsletter
Never miss anything again. Sign up for the ATIX newsletter!
Sign up now
Blog
  • Blog Start Page
  • ATIX Insights
  • Cloud Native
  • Container Plattformen und Cloud
  • DevOps
  • Hangar
  • Infrastructure Automation
  • Linux Platform Operations
  • orcharhino
Privacy & Legal

Privacy Policy

Imprint

Terms and Conditions

B2B

Twitter     Facebook    LinkedIn    Xing     Youtube     mastodon=

© Copyright – ATIX AG

Scroll to top