Vim programming environment settings memo

Source: Internet
Author: User

The following are the settings used for C/C ++ programming using vim and common operations.

First, we need to cut the actual Vim image at work:

1. Display Settings

Add the following to the vim configuration file/etc/vimrc:

Set cindet # Set to C language indent Mode

Set num # Set to display row number

Set tabstop = 4 # Set a tab key to four spaces

Set shiftwidth = 4 # Set the indent value to 4 spaces

Hi comment ctermfg = 6 # Set the C language annotation color to light blue

2. Start Vim

Ctags-r generates tags for the source files in the current directory

Vim-P 1.C 2.c 3.c open multiple files in tag Mode

3. Edit buttons

ESC --------------- return to normal mode

: -------------------- Enter the command mode. Enter the command

/-------------------- Search

V -------------------- enter the visual mode

 

J --------------------- move the cursor down a row

K -------------------- move the cursor up a row

H -------------------- move a character to the left

L --------------------- move the cursor to the right to a character

 

2yy ----------------- copy a total of 2 rows starting from the current row

P -------------------- paste the clipboard content under the current line

X --------------------- Delete the character where the cursor is located

2dd ------------------- Delete the row where the cursor is located and the row below. There are two rows in total.

 

I -------------------- enter the editing mode and start editing before the character where the cursor is located

A ------------------- enter the editing mode and start editing after the character where the cursor is located

 

O -------------------- enter the editing mode, insert a row under the row where the cursor is located, and start editing

O ------------------- enter the editing mode, insert a row above the row where the cursor is located, and start editing

 

$ ------------------- Move the cursor to the last character at the end of the line

0 ------------------- move the cursor to the first character of the line

Gg ----------------- move the cursor to the first line of the file

24gg -------------- move the cursor to the object's 24th rows

G ------------------ move the cursor to the last row of the file

3 = 45 ------------- sort the content between 3rd rows and 45th rows according to C language indent

Gg = g ------------- re-orchestrate and indent the entire file

 

CTRL + W, J --------- move the cursor to the next window (for opening multiple windows at the same time)

CTRL + W, K -------- move the cursor to the next window (for opening multiple windows at the same time)

GT ------------------ move the cursor to a tab window on the right (for multiple tab Windows)

GT ----------------- move the cursor to a tab window on the left (for multiple tab Windows)

5gt -------------- move the cursor to 5th tab windows (for multiple tab Windows)

 

CTRL +] ------------ locate the file that defines the variable or function name where the cursor is located and open

CTRL + O ----------- return to the original file location

4 command

: W --------------------- save the file

: Q ---------------------- exit Vim

The preceding two functions can be used at the same time: WQ and A, indicating that there are multiple files. This is the case when multiple files are edited at the same time.

: Tabe (DIT) ------------- file name ---- open a file in the new tag

: Copen --------------- open the compilation connection error window. In this window, press enter in the error message line to automatically jump to the row where the source file is located.

: Make ---------------- compile

: Sh -------------------- open a new shell. When exit is executed in this shell, return to the vim interface.

: S/old/new/g -------- in the current row, replace old with new

: % S/old/new/g ------ replace old with new in the current file

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.