All Projects → yuanqing → Vim Basics

yuanqing / Vim Basics

✌️ Just the basics to get you up and running with Vim

Projects that are alternatives of or similar to Vim Basics

Aws Cli Cheatsheet
☁️ AWS CLI + JQ = Make life easier
Stars: ✭ 94 (-23.58%)
Mutual labels:  cheatsheet
Xg2xg
by ex-googlers, for ex-googlers - a lookup table of similar tech & services
Stars: ✭ 10,218 (+8207.32%)
Mutual labels:  cheatsheet
Reading Material
List of some useful blogs, books, courses, papers etc. 📚
Stars: ✭ 116 (-5.69%)
Mutual labels:  cheatsheet
Python Cheatsheet
Basic Cheat Sheet for Python (PDF, Markdown and Jupyter Notebook)
Stars: ✭ 1,334 (+984.55%)
Mutual labels:  cheatsheet
Docs
OpenBMC Documentation
Stars: ✭ 105 (-14.63%)
Mutual labels:  cheatsheet
C Sharp Cheatsheet
C# Cheatsheet
Stars: ✭ 111 (-9.76%)
Mutual labels:  cheatsheet
Vue Cheat Sheet
📚 My cheat sheet for vue.js most basic stuff https://boussadjra.github.io/vue-cheat-sheet/
Stars: ✭ 90 (-26.83%)
Mutual labels:  cheatsheet
Defaultcreds Cheat Sheet
One place for all the default credentials to assist the Blue/Red teamers activities on finding devices with default password 🛡️
Stars: ✭ 1,949 (+1484.55%)
Mutual labels:  cheatsheet
React Redux Cheatsheet
React Redux Cheat Sheet on Workflow & Concept
Stars: ✭ 1,453 (+1081.3%)
Mutual labels:  cheatsheet
Cheatsheet
Pretty cheat sheets, or ``reference cards'', obtainable from Org files.
Stars: ✭ 116 (-5.69%)
Mutual labels:  cheatsheet
Active Directory Exploitation Cheat Sheet
A cheat sheet that contains common enumeration and attack methods for Windows Active Directory.
Stars: ✭ 1,392 (+1031.71%)
Mutual labels:  cheatsheet
Oscp Prep
my oscp prep collection
Stars: ✭ 105 (-14.63%)
Mutual labels:  cheatsheet
Pico8 Api
Unofficial PICO-8 API with a lovely design ! ::
Stars: ✭ 115 (-6.5%)
Mutual labels:  cheatsheet
My Cheat Sheets
A place to keep all my cheat sheets for the complete development of ASIC/FPGA hardware or a software app/service.
Stars: ✭ 94 (-23.58%)
Mutual labels:  cheatsheet
Oscp
My OSCP notes
Stars: ✭ 117 (-4.88%)
Mutual labels:  cheatsheet
Cheatsheet Maker
Cheetsheet (cheat sheet or quick reference) generator. Use it for guides, instructions or study. Made in Python 3
Stars: ✭ 91 (-26.02%)
Mutual labels:  cheatsheet
Pyspark Cheatsheet
🐍 Quick reference guide to common patterns & functions in PySpark.
Stars: ✭ 108 (-12.2%)
Mutual labels:  cheatsheet
Scc
An Offline cheat sheet and a quick reference command line tool for HTML, CSS and JS .
Stars: ✭ 123 (+0%)
Mutual labels:  cheatsheet
Kubectl Sheetcheat
The Definitive Kubectl Sheetcheat. ⭐ Give it a star if you like it. Work (always) in progress !
Stars: ✭ 119 (-3.25%)
Mutual labels:  cheatsheet
Web Ctf Cheatsheet
Web CTF CheatSheet 🐈
Stars: ✭ 1,726 (+1303.25%)
Mutual labels:  cheatsheet

Vim Basics

Just the basics to get you up and running with Vim

This guide assumes some familiarity with the terminal. (See Unix Basics for a quick overview.)

Quick start

  1. Launch Vim via the terminal:

    $ vim Main.java
    

    You are now in Vim’s Command mode.

    (You should see the contents of Main.java if the file already exists. Otherwise you will see an empty text editor window.)

  2. You cannot type into or edit your file while in Command mode. To start typing into the file, you must switch to Vim’s Insert mode. Press i to do so. You should see -- INSERT -- on the bottom-left hand corner of your window. Now you can type as you would with any other text editor.

  3. When you’re done typing, press <Esc> to go back to Command mode. (The <Esc> key is your friend! Hitting <Esc> will bring you back to Command mode.)

  4. And… that’s about it, really! Now type :w and <Enter> to save the file, followed by :q! and <Enter> to quit Vim.

Commands

Almost all operations in Vim occur while in Command mode. Listed here are the more important commands that you should know.

Switching between Command and Insert mode

Action Keys
Switch to Command mode <Esc>
Switch to Insert mode i
Switch to Insert mode, moving the cursor to the end of the current line A
Switch to Insert mode, adding a new line under the current line, and moving the cursor to the new line o

Moving the cursor around the file

Action Keys
Page up <Ctrl> + u
Page down <Ctrl> + d
Move the cursor to the next word W
Move the cursor to the previous word b
Move the cursor to the start of the current line 0
Move the cursor to the end of the current line $
Move the cursor to a particular line of the file (eg. line number 9) 9G

Of course, you can also move the cursor using any of the arrow keys (, , , ), but it will be a lot faster to use the above commands.

Delete/cut

Action Keys
Delete the line under the cursor dd
Delete the word under the cursor dw
Delete the character under the cursor x

Because whatever you delete is copied into Vim’s clipboard, these 3 commands are akin to performing a cut.

Copy and paste

Action Keys
Copy the current line yy
Copy a particular number of lines, starting from the current line (eg. 3 lines) 3yy
Paste p

You can also specify the text to be copied using a text selection. It is a bit more involved, though:

  1. While in Command mode, press v to switch to Visual mode. You should see -- VISUAL -- on the bottom-left hand corner of your window.
  2. Move the cursor to adjust the text selection.
  3. When you have selected the text that you want to copy, press y. This will bring you back to Command mode, and the selected text will have been copied into Vim’s clipboard.

Undo and redo

Action Keys
Undo u
Redo <Ctrl> + r

Fixing code indentation

Action Keys
Fix the code indentation of the file gg=G

Save and quit

Action Keys
Save the file :w then <Enter>
Save the file then quit :wq then <Enter>
Quit without saving the file :q! then <Enter>

Settings

These are some of the commands to customise the display:

Action Keys
Enable syntax highlighting :syntax on then <Enter>
Enable line numbers :set number then <Enter>

Vim will look for a settings file named .vimrc in your home directory. You can avoid having to type the above settings for every new Vim session by putting the following in your ~/.vimrc:

syntax on
set number

The <Ctrl> + z “problem”

Remember that the command for undo is simply u, not Ctrl + z!

If you’d accidentally pressed Ctrl + z, you will find yourself back in your terminal, where you will see something like the following:

[1]+  Stopped                 vim Main.java

A quick fix is to issue the fg command:

$ fg

This will bring us back to Vim, and all is well with the world.

(Explanation: Pressing <Ctrl> + z places the currently-running program in the background. Here, the currently-running program is Vim. The fg program simply brings the most recent “backgrounded” program back to the foreground.)

See also

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].