Use the vi editor in linux for programming (instance description) and vi instance description
For beginners of linux, if you want to program in linux, You can first use the vi editor on the terminal for programming. The following describes how to use the vi editor for Java programming and python programming to get started with programming in linux.
The first step is that the vi editor in linux of redHat is relatively complete under normal circumstances and there will be no problems in use. The examples in this article are all carried out under ubuntu, while the vi editor under ubuntu is not complete, you can install a vim editor first ~ $ Sudo apt-get install vim. You can continue with the following operations.
1. Java programming using the vi Editor
1. Enter ~ in the terminal ~ $ Vim Hello. java and press enter, as shown in,
2. Press the "I" character to enter the editing mode. There are two characters inserted in the lower left corner, that is, you can write programs.
3. Perform Java programming. The Code is as follows.
4. after programming, press the ESC key in the upper left corner of the keyboard to enter the command mode (the two words inserted in the lower left corner do not exist), as shown in the first figure below, shift + ":", enter the baseline mode. Type wq, as shown in the second figure. Press enter to save the file and return to the Command window, as shown in the third figure below.
5. Compile the java file ,~ $ Javac Hello. java (if you are prompted about what to install, just install it as prompted ). If the program has no errors, no prompt will be displayed. If an error occurs, an error will be reported ~ $ Vim Hello. java: Enter the file for modification and save it. The saving process is the same as that in programming. If no error occurs, enter the command ~ $ Ls press enter and the file name shown in appears. Hello. java and Hello. class are found. The former is the program we wrote earlier, and the latter is the file of the compilation result of this step.
6. Run the program and enter the command ~ $ Java Hello note that the Java program compilation and running process is to first compile the. java file to get the. class file, and then run the. class file to get the result.
2. Use the vi editor for python Programming
1 .~ $ Vim helloworld. py press enter to enter the interface shown in.
2. type the 'I' character to enter the editing mode and edit the following program:
3. After writing the program, Press ESC to enter the command mode.
4. Press shift + ":" to enter the baseline mode. Then enter wq and press enter to save the file.
5 .~ $ Ls command to get the file structure, which contains a helloworld. py file
6. Run the program ~ $ Python helloworld. py
3. Comparison between the two
1. The steps for programming in both languages are roughly the same.
2. the Java language has a compilation process. Compile the. java file into a. class (bytecode) file and run the class file (note that the. class suffix is not included in the command)
3. Run the. py file directly in python.
4. Both are interpreted object-oriented languages.