160 likes | 392 Views
VIM. This is the text editor you will use on the workstation. You can also edit the text files under windows environment and upload it to the workstation using FTP. It will be a very efficient tool is you are familiar with it. VIM. Basic usage : vim <filename>
E N D
VIM • This is the text editor you will use on the workstation. • You can also edit the text files under windows environment and upload it to the workstation using FTP. • It will be a very efficient tool is you are familiar with it.
VIM • Basic usage: vim <filename> • It will create a new file for you if no such file exists. • You can just type vim a.c to start editing a c source file.
VIM • The first thing you have to know about Vim is how to exit it. <press ESC if you are in the editing mode> • :q – leave vim • :q! – leave without saving • :wq – save and leave • You can use :w to save without leave and :w <filename> to save in a new name.
VIM • Now you can understand that Vim is a monster filled with hotkeys and commands. • Don’t be frightened by that, you only needs “i”, “:q!”, “:wq” and “ESC” in order to use Vim. • You can press any of the following keys to enter the editing mode: a, i, o, r, A, I, O, R, each has a different function.
VIM • Basic operations in Normal mode: • 0 / $– go to the beginning/end of the line. • G / gg– go to the beginning/end of the file. • x / dd– delete a world / a line. • yy /p– copy / paste • u / <ctrl>+r– undo / redo • / / n– search / search next • <ctrl>+v– block choose
VIM • You can also use number + command to execute multiple commands. • For example, 2dd deletes 2 lines, 2yy copies 2 lines. • Learn Vim by experience, do not try to recite all of the commands. • You can also download a windows version of Vim
Shell Script • Shell script is just like a .bat file in windows, can be used to execute batch works. • Furthermore, you can use if-then, for-loop etc., in your shell script so you can set up some automatic works. • Use sh <filename> to execute it. Or You can just use chmod command to make the file executable.
Shell Script • All shell script starts with #!/bin bash to specify the shell name. • Other #s beside this line are considered as comment lines. • Spaces and new lines are ignored. • <Enter> is considered as “execute”
Shell Script • I won’t talk too much about Shell Script here because it will become Unix course. • Let’s try a small example. #!/bin/bash #This is the demo bash script echo "We are going to use Vim to open a file." read -p "Please insert the file name: " filename echo "the file name is" $filename", are you sure?(y/n)" read yn if [ $yn == "y" ]; then vim temp/$filename else echo "command failed" fi