A beginner's guide to VIM (Text editor).

VIM logo.
credit: Wikipedia.
sudo apt install vim
touch text.txt
vim text.txt
  1. Normal mode
  2. Insert mode
  3. Command mode
  4. Visual mode
Your time is limited, so don't waste it living someone else's life. Don't be trapped by dogma – which is living with the results of other people's thinking.The way to get started is to quit talking and begin doing.If you set your goals ridiculously high and it's a failure, you will fail above everyone else's success.

Navigate

  • One character left — h.
  • One character right — l.
  • One line up — k.
  • One line down — j.
  • Start of the next word (forward) — w.
  • End of the next word (forward) — e.
  • Start of the previous word (backward) — b.
  • Start of the line — 0.
  • End of the line — $.
  • Next paragraph — }.
  • Previous paragraph — {.

Insert

  • Where the cursor stay — i.
  • After where the cursor stay — a.
  • Next blank line where the cursor stay — o.
  • The previous blank line where the cursor stay — O.

Remove

  • One character — x.
  • One word — cw.
  • Entire line — cc.
  • From cursor to the end of the line — c$.
  • From cursor to the start of the line — c0.

Undo and Redo

  • Undo changes — u.
  • Redo changes — ctrl + r.

Copy

  • To active visual mode — v.
  • To copy select text — y.
  • To copy one word — yw.
  • To copy one line — yy.

Cut

  • To cut select text — d.
  • To cut one word — dw.
  • To cut one line — dd.

Paste

  • To paste — p.

Search

  • To match from the start of the word — /pattern .
  • To match from the end of the word — ?pattern .

Replace

  • Only one matched word — :%s/search/replace.
  • All the matched word — :%s/search/replace/g.
  • To replace anything by asking for permission — :%s/search/replace/gc.
  • Replace one character — r.

Save

  • To save — :w .
  • To save as a new file — :saveas filename

Quit

  • To quit — :q .
  • To save and quit together — :wq.
  • To quit by avoiding changes — :q!.

Tips

  • Never forget to use this. When you want to execute a command n times, we can just prepend the number before that command like 100h.
  • When you want to perform the last command again instead of use that command again just press . (dot/period).
  • When you are in insert mode, you have made a spelling mistake to remove that word instead of using backspace use ctrl + w. or you made so many mistakes use ctrl + u . This will get things done faster.
  • To get help from VIM enter :help.
  • when you stuck just enter your terminal vimtutor .

Conclusion

Resources

--

--

--

MERN Stack Developer | Book lover | Also a Procrastinator

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Basics of High-Order functions in JS and React

errors connecting to mongo db in node js application

React: Day 32

React: Day 32

Secrete Website 😱. Every Developer should know. Part 2

Build a scalable GraphQL server using TypeScript and Apollo Server

Web Scrapping and Screen Capture Using CasperJS

Create Twitter Bot using NodeJs and Deploy on Heroku

Module 1: Basic Concepts of Ruby Object Oriented Programming

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Akibur Rahman (Akib)

Akibur Rahman (Akib)

MERN Stack Developer | Book lover | Also a Procrastinator

More from Medium

Steps to Containerize your app locally and deploy it on Cloud Run

How to Make Your Images Adapt to Dark & Light Modes in GitHub Markdown

Writing a HTML Code

Mac 1Password Setup