Linux Ubuntu 002 -- vim and C/C ++ environment Configuration

Source: Internet
Author: User

Commonly used compilers in Linux include VI (UBUNTU), VIM (VI improved), and Emacs. I prefer the vim editor in Ubuntu. I am not familiar with the emacs editor. I have read the two source code writing editors. Currently, I think Vim is easier to learn, so we should select Vim as the starting point for learning Linux.

Let's take a closer look at the vim tutorial tonight. By the way, I will write an article to consolidate it.

 

The Vim editor has two modes: 1. Normal Mode (command mode) and 2. insert mode. Note: The two modes are converted using the ESC key.

I. Operations in Normal Mode

In command mode, you can use "colon + command" to perform operations. The first basic operation is to save and exit the operation:

 
: Q # exit. If it is not saved, an error message is displayed:W<FILENAME># Saving files: WQ # saving and exiting (Common Operations): Q! # Force exit

Edit data in Normal Mode:

X Delete the character at which the current cursor is located
Dd Delete the row where the current cursor is located
DW Delete the word at the current cursor position
D $ Delete the content from the current cursor position to the ending line
J Delete the linefeed at the end of the row where the current cursor is located (concatenate rows)
U Undo the previous edit command
A Add data to the current cursor
A Append data at the end of the current cursor row
R char Use Char to replace the word character at the current cursor position
R text Overwrite the data at the cursor position with text until you press the ESC key.

Copy and paste:

YW indicates copying words, y $ indicates copying to the end of a line, and P indicates pasting. In addition, when selecting a specified string, you need to enter the visual mode to select the string.

There are also search and replace operations, which are rarely used and not detailed.

========================================================== ========================================================== ======================

Configure the C/C ++ development environment in the vim Editor

Step 1: Find the vimrc file under the/etc/Vim/directory;

Step 2: Switch the terminal to the root user permission and switch the working path to the directory in step 1;

Step 3: Use the vim editor to open the vimrc file (Vim vimrc );

Step 4: switch to the insert mode and add the following to the vimrc file:Code:

Set tabstop = 4
Set shiftwidth = 4
Set cindent
Set cinoptions = {s, T0, N-2, P2s, (03 S, =. 5 S,> 1 s, = 1 s,: 1 s
Set number

Step 5: Save and exit. After the C/C ++ environment is set, a line feed and indentation are automatically generated, which is similar to that in the VC environment.

For details, see Vim configuration details.

 

You need to configure Vim to edit Python code.

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.