Ubuntu under the terminal Vim Programming C language Program

Source: Internet
Author: User
Tags linux text editor

I am open virtual machine under Ubuntu, installed dual system and unloading, Ubuntu default is not included editor vim and compiler GCC. If you are a newly installed Ubuntu computer, we will implement our first program in the future.

1. Preparatory work

First enter the root user mode, or you cannot save the. c file

1.1 Open Terminal: Use shortcut key CTRL + ALT + T;

1.2 Install VIM: input sudo apt-get install vim, (not installed as if insert mode up and down and other things do not work)

1.3 Installing GCC: Enter the sudo apt-get install g++.

2. Write, compile, run

2.1: Open the terminal, go to a folder to store the program you write

#vi hello.c

Then you will see the VI editor, press I to start the input (I do not need to enter after the return), and then directly enter your code, (if you do not use VIM can go to the first to understand a ha, and now I do not really understand the detailed operation of VIM)

Press ESC when you are finished, and then enter ": Wq" (in quotation marks) to save the exit,

2.2: Use GCC to compile your program

In the terminal input

#sudo Gcc-wall Hello.c-o Hello

When the compilation is complete, a hello run file appears in your file.

2.3: Run compile well to Hello (note case) file, in terminal input

#./hello

Running a. cpp file requires the installation of g++

Installing g++

sudo apt-get install g++

VI hello.cpp

g++-O Hello hello.cpp

./hello

Introduction to VIM Basics http://www.linuxidc.com/Linux/2017-02/140903.htm

Introduction to VIM Basic Tutorial http://www.linuxidc.com/Linux/2017-02/140279.htm

Make Vim a good C + + IDE http://www.linuxidc.com/Linux/2016-06/132262.htm

Ubuntu 14.04 upgrade Vim7.4 to 8.0 http://www.linuxidc.com/Linux/2016-11/136816.htm

VIM Installation Youcompleteme Auto-complete plug-in http://www.linuxidc.com/Linux/2016-11/137665.htm

The Linux Vim Editor uses a simple explanation http://www.linuxidc.com/Linux/2016-12/138930.htm

Vim Text editor http://www.linuxidc.com/Linux/2017-03/142275.htm

Vim installation and configuration Advanced version http://www.linuxidc.com/Linux/2017-03/141724.htm

Vim Editor Using tutorial http://www.linuxidc.com/Linux/2017-07/145885.htm

Ubuntu 16.04 Vim youcompleteme Auto-Complete installation configuration and use Http://www.linuxidc.com/Linux/2017-02/141088.htm

Linux Text Editor vim basic tutorial http://www.linuxidc.com/Linux/2017-09/146930.htm

This article permanently updates the link address : http://www.linuxidc.com/Linux/2017-10/147473.htm

How to use Vim to write C language under Linux

Step through Reading

Linux operating system and its vim, I believe many small partners will be interested to try. Small make-up this brings the little friends to see how Linux uses Vim to write C language.

Tools/Materials
    • Linux

Method/Step
    1. Enter the Linux system and create the C file "Vim test.c" while entering the Vim editing interface

      You can also use the command "Touch test.c" after creation, and then "Vim test.c" into the Vim editing interface

    2. Vim editing interface, by "ESC" built to switch three modes,

      General mode: Enter the "Vim file name" in the Linux terminal to enter the general mode, but cannot enter the text. Edit mode: Press I in general mode will enter the editing mode, you can write the program, press ESC to return to the general mode.

      Command mode: Press in normal mode: will enter command mode, there will be a colon in the lower left corner, at this point, you can type the command and execute.

      Keyboard "A" key can be directly into the editing mode

    3. Display the number of rows by entering the bottom instruction ": Set Nu"

    4. After entering C code, remember "ESC" key switch, enter ": Wq" Save exit

    5. The instruction "LS" shows the file in the current directory, we can see the existing C file

      Compiling "Gcc-o test test.c"

      After the compilation is successful, run the "./test"

      END

Precautions
    • Like the small partners remember to vote for small, small series Thank you very much!!

Http://www.linuxidc.com/Linux/2017-10/147473.htm https://www.cnblogs.com/emanlee/archive/2011/11/10/2243930. Htmlhttps://www.cnblogs.com/youcan/archive/2013/01/27/2879163.html

Ubuntu under the terminal Vim Programming C language Program

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.