5% OFF Over $19, Code: Elephant5; 10% OFF Over $59, Code: Elephant10



Raspberry pi 4WD Robot Tutorial 2.5 linux commands and vim editor

Posted by Fiona Su on

1. Some basic common

1) View the version of operating system

cat /proc/version 

2) View the version of mainboard

cat /proc/cpuinfo 

3) View the remaining space of the SD card.

df -h 

4) View IP address

ifconfig 

5)Condense:tar –zcvf  filename.tar.gz dirname

Decompress:tar –zxvf filename.tar.gz

6) apt(Advanced Package Tool)is used to install software.

     sudo apt-get install xxx     install xxx software.
     sudo apt-get update        update software.
     sudo apt-get upgrade       Update the installed software.
     sudo apt-get remove xxx    remove xxx software. 

Some tutorial for linux commands:http://www.runoob.com/linux/linux-command-manual.html 

2. Introduction and configuration of the vim editor

Linux comes with editors nano and vi. Vim editor is an upgraded version of the vi editor,which has a better experience.

The following steps will teach you how to install and configure vim editor in the Raspberry Pi system

1)You need to input: sudo apt-get update

2)You need to input: sudo apt-get install vim 

You will see the following interface:

image.png 

3)You need to input: su and input the password for the your root account.

image.png 

4)You need to input: sudo tar xvf vimconfig.tar.gz

image.png 

5)You need to input: cd vimconfig  

You need to input:./config.sh

image.png 

You may see the interface shown below.

image.png 

6)You need to input: touch /root/.vim  /root/.vimrc

image.png 

7)You need to input: apt-get install ctags

image.png 

After the above steps is completed, the vim editor becomes will become as shown below.

image.png 

The editor possess 3 modes:Enter mode, Command mode, Low line mode.

Enter mode:In this mode, you can enter characters, and pressing ESC will return to command mode.

Command mode: You can move the cursor, delete characters, and so on.

Low line mode: You can save files, exit editor, set editor, find,etc.(low line mode be regarded as in command mode)

①These instructions are used in Command mode:

vi filename/vim filename  //Open the filename file

:w                          //Save file

:q                                         //Exit editor(The file has not been modified)

:q!                         //Exit editor without save

:wq                        //Exit editor and save

②These instructions are used in Command mode.After these commands are executed, you can enter the Enter mode. (pressing ESC will return to command mode)

a              //Add text to the right of the current cursor position

i              //Add text to the left of the current cursor position

A           //Add text at the end of the current line

I         //Add text at the beginning of the current line (the beginning of a line that is not a null character)

O          //Create a new line above the current line

o          //Create a new line below the current line

R         //Replace (overwrite) the current cursor position and several texts that follow

③These instructions are used in Command mode:

x            //Delete current character

nx         //Delete n characters from the cursor

dd         //Delete current line

u           //Undo the previous step

U          //Undo all operations on the current line

④These instructions are used in Command mode:

yy        //Copy the current line to the buffer

yw       //Copy the characters from the cursor to the end of the word

y^        //Copy the content from the cursor to the beginning of the line

y$        //Copy the content from the cursor to the end of the line

p         //Paste the contents of the clipboard behind the cursor

P         //Paste the contents of the clipboard in front of the cursor

⑤These instructions are used in Command mode:

:set  nu      //Display the number of line

:set nonu   //Undisplay the number of line

0 comments

Leave a comment

Please note, comments must be approved before they are published