🦲
mind
  • cleber's mind
  • plans
    • fact checking
    • personal assistant
  • self-management
    • agenda and tasks
    • mails and emails
  • knowledge
    • career
    • programming
      • Big O Notation
      • browsing data
      • C/C++
      • databases
      • eclipse
      • gradle
      • java
        • apache camel
      • javascript
      • naming convention
      • mysql
      • prolog
      • regex
      • REST
      • ssl/tls
      • version control
        • git commands
      • web-semantics
      • wot
    • research
      • mas
      • planning
      • math
        • probability
      • machine learning
      • nlp
      • speech recognition
      • data sources
      • data visualisation
    • it
      • asterisk
      • containers
        • installing docker
        • deploying busybox
        • deploying a sample
        • deploying node-red
        • deploying from the hub
      • clusters
        • installing kubernetes
        • deploying bootcamp
        • deploying nginx
        • deploying jacamo-rest
        • grafana
      • deploy
        • heroku
      • linux
        • tmux
        • vim
        • startup
      • networks
      • pdf
        • ssh
    • productivity
    • language
      • expressions
        • nice signposts
        • linking expressions
      • latex
      • scientific
      • writing
    • sailing
    • financial
      • assets
    • emergency
    • out of boxes
  • teaching
    • eletrônica digital
      • Conversão decimal para binário
      • Conversão binário para decimal
      • Sinais analógicos vs digitais
    • programação I
    • cabeamento estruturado
  • moments
    • insightful ai facts
    • ai4industry-hackathon
    • previous activities
  • brasil
  • external links
    • personal webpage
    • my github
Powered by GitBook
On this page
  • Vim modes
  • Navigating into a document
  • Changing a document
  • Selecting
  • Copying and pasting
  • Searching and replacing
  • Saving and quitting

Was this helpful?

  1. knowledge
  2. it
  3. linux

vim

A gentle guide to vim

PrevioustmuxNextstartup

Last updated 4 years ago

Was this helpful?

Vim is an improved version of . Its interface can be scary at the beginning but after understanding its modes and a few commands, it can be very productive.

Vim modes

Vim has two important modes to know:

  • command mode: this is the default mode, you can go to other modes from the command.

    • From the command mode type i to go to insert mode.

  • insert mode: this is for editing a file as you are expecting, i.e., what you type will be inserted where the cursor is blinking.

    • Press ESC to go back to command mode.

Navigating into a document

  • h, J, k and l move the cursor one character to left, down, up and right. Arrow keys also work.

  • 0 (zero) and $ move the cursor to the beginning and end of the line. Home and End keys also work.

  • w and b move the cursor to the next and the previous word. Using Ctrl + left and right arrows move from words separated by spaces.

  • gg and G move the cursor to the beginning or end of file. Ctrl+Home and Ctrl+End also work.

The commands can also be executed multiple times when preceded by a number, e.g., 3w will move the cursor 3 words forward.

Changing a document

  • d delete from cursor, e.g., dh deletes the character on the left, d0 deletes until the beginning of the text.

  • u and Ctrl+r undo and redo.

Selecting

  • v, V and Ctrl+v go to visual from the cursor, entire line and by columns

Copying and pasting

  • y copy

  • p and P: paste after current line and on the current line

Searching and replacing

  • /text and ?text search "text" going forward and backward

  • n and N go to next occurrence going forward and backward

  • :%s/text/new text/gc and :%s/text/new text/g replace "text" by "new text" asking to confirm on every occurrence and replacing without asking.

Saving and quitting

  • :q! discard changes and quit

  • :w save changes

  • :wq save and quit

vi editor