Vim Program Editor
basically VI It is divided into three modes, namely General instruction mode, edit mode and instruction column command mode.
General instruction Mode : Open a file to go in, he can delete, copy, paste and other operations, but can not be edited. The cursor to the last line is saved by pressing Wq .
Vim File name (can be opened regardless of whether the file does not exist)
Edit Mode : Press any key to enter edit mode, press ESC to normal mode
Command line mode : Press:/ ? Any one can go to the last line. You can then enter the command.
Press the Crte+z can exit Vim Program Editor
Kill-9% 1 This command is capable of simulating short-term stop vim the order of the work.
Vim can be written by more than one person.
if Vim You can press R if it doesn't end properly. to protect your unsaved work, but when you're done, you'll have to delete the job you didn't normally end up with.
[O]pen read-only : Open this file to become read-only.
(R) Ecover : The content that is loaded into the temporary archive is used for work that you have not saved until you save it.
(D) elete it : Deleting a document
(Q) uit : Press the Q just leave . Vim
(A) bort : Ignore this edit behavior, and quit almost
Remember the key instructions:
Block selection:
v character selection, the cursor will pass through the local anti-white selection!
V column selection, the column that the cursor passes through is white-selected!
[Ctrl]+v block Selection, you can select the data in a rectangular way
y Copy the anti-white place .
D Remove the anti-white place
P Paste the chunk you just copied, and place it where the cursor is located.
Multi-file editing
: N Edit Next file
: N Edit Previous file
: Files List the current vim all the files that were opened
1 through Vim hosts/etc/hosts command to use a Vim open two files;
2 in the Vim in the first use : Files file data.
3 in the Vim environment, enter : N will come to the second editor's file, i.e. /etc/hosts inside;
4 in the /etc/hosts Press the G to the last column, and then enter " P "put on;
5 press the number of times u to restore the original file data;
6 finally press the : Q to leave Vim !
Multi-Window function
in the instruction column mode input : SP file name can be
ctrl+w+↑ and ctrl+w+↓ You can switch between the two windows.
Bash
BASH It's a shell . , Shell is a command language interpreter, each command entered at the prompt is Shell first explain and then pass it to Linux .
if the command line is too long you can (\ ) to indicate that the global variable = environment variables, custom variables = Local Variables
Echo command to print the value of the shell variable in the shell, or to output the specified string directly, is the variable's display command line echo $ variable name
Command alias: alias {"Alias" = ' command argument '} for example Ls–al | More aliases changed to LM
Alias lm= ' Ls–al | More '. Remove the alias is: Unalias lm
Type:
He was used to display the type of the specified command, to determine whether the given instruction is an internal or external instruction.
- P : If the given instruction is an external instruction, its absolute path is displayed;
How to set the contents of a variable
Echo ${myname}
Blank Line
myname= the contents of the variable name
Echo ${myname}
The result is that the variable name you entered is displayed
in the shell , if a variable name is not set, the default content is null .
1 variable and variable contents with an equal sign = to link, as follows:
Myname=vbird
2 The equal sign cannot be directly connected to white space, as shown below as an error:
myname = Vbird or Myname=vbird Tsai
3 The variable name can only be an English letter and a number, but it cannot begin with a number, as in the following error:
2myname=vbird
4 variable contents can use double quotes if blank or single quote ' Combine variable content come, but
special characters within double quotation marks, such as $ and so on, you can retain the original characteristics, as follows:
var= "Lang is $LANG" the Echo $var can get Lang is zh_tw. UTF-8
Special characters within single quotes are only plain text, as follows:
var= ' lang is $LANG ' the Echo $var can get LANG is $LANG
5 can be used/ instead of special symbols.
6 If the change Volume for amplification and change Volume content is available, the "$ variable Volume name "or ${variable } accumulate the content as follows:
Path= "$PATH":/home/bin or Path=${path}:/home/bin
such as letting name the content of the more out Yes can:
Name=${name}yes
7 if the variable needs to be executed in another subroutine, the need to export to make Custom variable into environment variable :
Export PATH
For example: I want to Name=tian in the next Shell run in the program.
Name=tian
Bash
Echo $tian
Exit
Export Tian
Bash
Echo $name
Exit
8 the way to cancel a variable is to use unset : unset Variable name , such as canceling myname Settings for:
Unset myname
function of environment variables
Env can list environment variables and common environment variable descriptions
random: Variable ($RANDOM), in bash environment, the random between 0~32767, Echo $RANDOM, the system will take the initiative randomly out of a value between 0~32767.
Declare–i number= $RANDOM *10/32767;echo $number
Set can see all the variables.
PS1 (number 1 ): Is the command prompt , after the execution of a command, the last to appear again when prompted, will be actively read the variable value. The default directive for PS1 is [\[email protected]\h \w]\$
$ : ( about the PID of this shell ) , is a variable. to know the PID of our shell, we can use: Echo $$, the number that appears is your PID number.
? : The question mark is a special variable that is the value returned by the last instruction executed . When the command is executed, the instruction will return a code. If the command is executed successfully, a value of 0 is returned, and the error code is returned if an error occurs during execution. But (? ) is only relevant to the previous command
Export : custom variables into environment variables
Export is a command that converts a custom variable into an environment variable.
Command line: Export variable name
Variable keyboard reads, arrays and declarations: Read,array,declare.
Read directly after the name of the variable, there will be a blank line to let you enter, input on the conversion of the variable content. Plus-T to set the time the blank line exists, not set the default 30s. Plus-T, there will be hints
Read [-pt] variable name
P: Can be followed by a prompt
T: Number of seconds to wait after
Declare/typeset is the type of the declared variable, followed by the direct variable will be all the variable name is displayed in the content.
Declare [-AIXR] Variable name
-A: Define the following named variable as array type
-I: Define the latter variable as an integer number (int) type
-X: As with export, the variable is changed into an environment variable;
-r: Sets the variable to be the ReadOnly type, cannot be changed, and cannot be reset.
For example:
sum=100+500
echo $sum (x)
Declare–i sum=100+500
echo $sum (√)
Array is a variable type and is recommended to be read directly in the $ array.
Ulimit is a restrictive relationship between file systems and programs
Ulimit [-shacdfltu] Value
-H: Strict setting, must not exceed the value of this setting;
-s:soft limit, the warning setting can exceed this setting, but there is a warning message if it is exceeded. is greater than-s but less than-H warns
-A: The following does not take any options and parameters, you can list all the limit amount;
C: When some program error occurs, the system may write the program's information in memory (except for the wrong use).
This file is called the core file. This is to limit the maximum capacity per core archive.
-F: Maximum file size that can be established by this shell (typically set to 2GB) in kilobytes
-D: Maximum broken Memory (segment) capacity that can be used by the program;
-L: Amount of memory that can be used to lock (lock)
-T: Maximum CPU time that can be used (in seconds)
-U: The maximum number of processes (process) that a single consumer can use.
Deletion and substitution of variable contents in substitution
Delete command: ${variable name #/* the part you want to delete}
$ is a keyword, used in delete mode
#是代表从变量的最前面开始想右删除, cut delete the shortest (first/second/between data).
However, in the path variable, the directory is separated by: (/) and (:) in the middle of the data. (If two # is the word, it is the one that deletes the longest (the first/last data between the two).
% is the delegate from the last side of the variable to the left to delete. Use the same as #
Alternate command: Echo ${variable name/variable content to be substituted/variable}-----Only the first one will be replaced
If it is two//is the content of the match will be replaced: Echo ${variable name//the variable content/substitution variable that you want to replace}. ---------------------all will be replaced.
For example, you want to replace the sbin of the path variable with the uppercase Sbin.
(1) (/)
Echo ${path/sbin/sbin}
/usr/local/ SBIN :/usr/sbin:/home/dmtsai/.local/bin:/home/dmtsai/bin
(2) (//)
Echo ${path//sbin/sbin}
/usr/local/bin:/usr/bin:/usr/local/ SBIN:/usr/ SBIN :/home/dmtsai/.local/bin:/home/dmtsai/bin
Test whether a variable exists: The new variable =${the variable-the contents of the variable}
For example, to determine if the test variable exists, and if it does not exist, give the content of test root
Echo${test}
(A blank line appears, so test may not exist, or it may be an empty string)
Test=${test-root}
Echo${test}
Root
Command alias: Alias,unalias
Alias ' aliases = ' command parameters
For example, LM as Ls–l | More command aliases
Alias "lm" = ' la–l |more '
Unalias is to cancel the command alias, directly behind the command alias can be
For example, cancel the above command alias
Unalias LM
Historical Order (history)
-----(Histfiles is the file that holds the history command)
N: number, which lists the most recent n command list meaning!
-C: Delete history command
-A: Add the current New History command into Histfiles
-r: Read the contents of the Histfiles to the current memory of the shell;
-W: Writes the current history memory content to Histfiles!
Bash Login and welcome information:/ETC/ISSUE/ETC/MOTD
/etc/issue is where you record a few lines of hint string on the login screen.
Cat/etc/issue can view the prompt string.
Want to let the user login to get some information, direct vim into the/ETC/MOTD, and then enter the message you want to send.
Bash Environment configuration file
Vim and bash