Vi/Vim End Of Line

Thursday, Aug 8, 2024 | 3 minutes read | Update at Thursday, Aug 8, 2024

@ İsmail Baydan

Vim/Vi is very popular command line text editor for Linux. Vim/Vi provides different shortcuts for different operations. Jumping end of the line in Vim/Vi is popular operation and can be done with different shortcuts or command. In this tutorial we examine different ways to jump end of the line in Vim/Vi

  1. Move to the end of the current line: We can use the $ key directly jump to the end of the current line. This will jump end of line where cursor is located.

    • Command mode:
      $
      

    Moves the cursor to the end of the current line.

  2. Append text at the end of the current line: The A can be used to jump end of the line for the current line and start append mode. We can append new content to the end of line easily with the A .

    • Command mode:
      A
      

    Moves the cursor to the end of the line and enters Insert mode.

  3. Delete from the cursor to the end of the line: We can jump end of the line by deleting from the cursor current location to the end of line. After this operation the cursor will be end of the line.

    • Command mode:
      D
      

    Deletes from the cursor position to the end of the line.

  4. Change (replace) text from the cursor to the end of the line: We can jump end of the line from the cursor current location to the end of line and the INSERT mode will be start which simply means we are replacing from the cursor location to the end of line.

    • Command mode:
      C
      

    Deletes from the cursor position to the end of the line and enters Insert mode.

  5. Yank (copy) from the cursor to the end of the line: We can use y$ to copy from the cursor to the end of the line.

    • Command mode:
      y$
      

    Copies from the cursor position to the end of the line.

  6. Move to the end of the next line: Some times we may need to jump to the next lines end of line. We can use j$ to jumpx end of the next line.

    • Command mode:
      j$
      

    Moves the cursor down one line and then to the end of that line.

  7. Move to the end of the previous line: We can use the k$ shortcut in order to move end of the previous line.

    • Command mode:
      k$
      

    Moves the cursor up one line and then to the end of that line.

  8. Delete from the cursor to the end of the line in visual mode: We can use d$ to delete from cursor current location to the end of line.

    • Visual mode:
      d$
      

    Deletes the selected text from the cursor position to the end of the line.

  9. Replace a character at the end of the line:

    • Command mode:
      $r
      

    Moves the cursor to the end of the line and allows you to replace the last character of the line by typing the replacement character.

These commands showcase various ways to navigate to, modify, and interact with the end of a line in Vim, providing efficient text editing capabilities.

© 2024 Linux and Python Tutorials

🌱 Powered by Hugo with theme Dream.