• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

RHEL 7 – RHCSA Notes – vi/vim editor

by admin

RHEL 7 – RHCSA Notes (Cheat Sheets)

The vim editor

Inserting text

Command Action
i Insert text before current cursor position
a Append text after current cursor position
A Append text at the end of the current line
o Open new line below the current line
O Open new line above the current line

Navigating in vi

Command Action
left arrow / h move left 1 character
right arrow / l more right 1 character
up arrow / k move up 1 line
down arrow / j move down 1 line
$ move to the end of current line
0 move to beginning of current line

Deleting text

Command Action
x delete character at current cursor position
dw delete word or part of word to the right of cursor
dd delete current line
D Delete current line starting from the current cursor position

Undoing and repeating

Command Action
u undo the last command
. (dot) repeat the last command

Search and replace text

Command Action
/[string] Search forward for string
?[search] Search backward for string
n Find next occurrence of string
N find previous occurrence of string
:%s/old/new Search and replace first occurrence of string old with string new
:%s/old/new/g Search and replace all occurrence of string old with string new
cw Change the word staring from current cursor position
r Replace character at current cursor position
R Replace/overwrite text on current line

Copying and Pasting text

Command Action
yw Yank the current word in buffer
yy Yank the current line in buffer
p Paste the yanked data below the current line
P Paste the yanked data above the current line

Saving and quiting

Command Action
:w Write change into the file without quitting
:w! write change into the file even if you are not owner of the file
:wq write change into the file and quit
:wq! write change into the file and quit even if you are not owner of the file
:q quits when no changes are made
:q! quits without saving the changes made

Filed Under: Linux, RHCSA notes

Some more articles you might also be interested in …

  1. CentOS / RHEL 7 : How to configure VLAN Tagging using nmcli
  2. fprintd-delete: command not found
  3. arecord Command Examples in Linux
  4. updatedb: command not found
  5. How to recreate LVM device files under /dev directory using vgmknodes
  6. How to show line numbers in Gedit
  7. The Ultimate Beginner’s Guide to Static Website Hosting With Google Firebase (for FREE)
  8. CentOS / RHEL 6 : How do I find my current runlevel?
  9. mkfs.exfat Command Examples in Linux
  10. CentOS / RHEL : How to create and host yum repository over httpd

You May Also Like

Primary Sidebar

Recent Posts

  • raw: command not found
  • raw Command Examples in Linux
  • rankmirrors Command Examples in Linux
  • radeontop: command not found

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright