💾
ITmatic101
  • ITmatic101 - Tech Blog
  • 🧙‍♂️Linux
    • SSH certificate authentication
    • SSH key authentication for LDAP login
    • Using GPG to encrypt/decrypt files or messages
    • Understanding SUID, SGID and Sticky Bit
    • Unleashing VIM
  • 🐍Python
    • Setting up a Python developer environment
  • 🚀Ansible
    • Setting up LXD Lab with Ansible
    • Ansible Vault
    • Ansible WireGuard workflow on Linode
  • 🍨Virtualisation
    • SSH key management in LXD
    • Customise VM template with cloud-init on Proxmox
  • ⚒️Homelab
    • Setting up AdGuard Home
    • SSH key authentication on Windows
  • 🧲Networking
    • MikroTik networking lab setup with Containerlab
    • Mikrotik IPsec Tunnel Setup
    • Mikrotik VLAN Trunking
    • Mikrotik QinQ VLAN trunking and policy based routing
    • Mikrotik Use Cases - PPPoE, ECMP, Failover, Recursive Routing and WireGuard
    • Mikrotik RouterOS Hardening for your home internet connection
  • 💀OffSec
    • Kali Linux with Vagrant for HTB
    • HTB: Lame Write-Up
    • HTB: Bank Write-Up
Powered by GitBook
On this page
  • Multi-lines actions
  • Macros

Was this helpful?

  1. Linux

Unleashing VIM

This page is the how-to note on VIM as new tricks learned.

Multi-lines actions

In VIM, it is quite useful to utilise the visual mode and multi-line actions when you are commenting out multiple lines for troubleshooting or documentation.

Here is how to comment out multi-lines.

  1. Ensure that we are in normal mode.

  2. Move the cursor to the first line you want to comment out and press Ctrl + v to put the editor into visual mode.

  3. Select the lines you want to comment out with VIM's key j or arrow down key.

  4. After that, press Shift + i to put the editor into insert mode inside visual mode and then press # which will add a hash to the first line.

  5. Then press Esc to insert # character on all other selected lines.

Here is how to remove comment from multi-lines.

  1. Ensure that you are in normal mode.

  2. Move the cursor to the first line you want to comment out and press Ctrl + v to put the editor into visual mode.

  3. Select the lines you want to comment out with VIM's key j or arrow down key.

  4. Then press x to delete # character on all lines.

The same workflow can be used to perform any other multi-lines actions in VIM as well.

Macros

It can be quite powerful to use macros in VIM for the same repetitive task in your editor. For instance, a specific set of motions and actions you are about to perform at multiple places can be recorded as a macro.

Here is how to record a macro in VIM.

  1. Ensure that you are in normal mode.

  2. Press q + w to register w as macro.

  3. Perform the commands/actions while it shows recording @w.

  4. If it is in the insert mode, press Esc to get out of it.

  5. Then press q to end the recording which stores the commands/actions in @w.

To reuse the recorded macro, move the cursor to where you want to perform the same commands/actions in VIM, and press @w to recall the macro.

PreviousUnderstanding SUID, SGID and Sticky BitNextSetting up a Python developer environment

Last updated 1 year ago

Was this helpful?

🧙‍♂️
Page cover image