PW0N's Blog

Sharing more techniques for like-minded people to learn and communicate together.

0%

Common Pitfalls in Vim-Input Method, Navigation, and Saving Files

Common Pitfalls in Vim: Input Method, Navigation, and Saving Files

Vim is a highly efficient text editor, but many users encounter pitfalls, especially when switching between different input methods or trying to perform basic tasks like searching and saving. In this article, we’ll cover some common issues, and provide solutions to navigate Vim more effectively.

Switching Between Input Methods in Vim

When typing in Chinese or other non-English languages, pressing ESC might not immediately exit insert mode. Here’s a solution:

  1. Problem: Pressing ESC while typing in Chinese doesn’t exit insert mode.
  2. Solution: First, switch to the English input method. Then press ESC followed by : to enter command mode, allowing you to execute commands as usual.

Vim Navigation with H, J, K, L Keys

After pressing ESC in Vim, you can use the following keys to navigate without relying on the arrow keys:

  • H = Left ()
  • J = Down ()
  • K = Up ()
  • L = Right ()

You can also use PgUp and PgDn to scroll up and down a page quickly.

Searching in Vim: Use ? and / Commands

When searching in Vim, many users coming from Windows expect to use Ctrl+F. However, Vim has its own search commands:

  • First, exit insert mode by pressing ESC.

  • Use ? or / followed by your search term to search within the file:

    ?example
    /example