(articles are extracted from other places and summarized, if there is infringement, please contact the Administrator)
- Vim Editor---Bulk comments and anti-annotations
When writing code using VIM, it is often necessary to use bulk annotations and counter-comments for a piece of code. The following is a brief description of its operation.
Method Piece Selection Mode
Insert Comment:
Enter virtual mode with V
Use the up and down keys to select the number of lines you want to comment
Press Ctl+v (win below ctrl+q) to enter the column mode
Press the larger "I" into insert mode, enter the comment "#" or "//" and press ESC immediately (two)
Uncomment:
Ctrl + V Enter block selection mode, select the comment symbol for the beginning of the line you want to delete, note//To select two, then press D to delete the comment
Method Two replace command
Bulk Comment:Use the following command to add a comment at the beginning of the specified line:: Start row number, end line number s/^/comment/g
Uncomment:: Starting line number, ending line number s/^ comment//g
:%s/source_pattern/target_pattern/g can be completed if you want to change all the username to login_name, then:%s/username/login _name/g can do it. connecting to 192.168.127.130:23...connection established. Escape character is ' ^@] '. Ubuntu 16.04.2 Ltsubuntu64-casa login:casapassword: login incorrectubuntu64-casa login:casaPassword:Last Login: Tue Mar 09:29:56 CST from 192.168.127.1 on Pts/1welcome to Ubuntu 16.04.2 LTS (gnu/linux 4.4.0-62-generic x86_64) & nbsp;* documentation:https://help.ubuntu.com* management:https://landscape.canonical.com* support:https:// UBUNTU.COM/ADVANTAGE 26 packages can be updated.25 updates is security updates. signature not found in US Er keyringperhaps try the interactive ' ecryptfs-mount-private ' [Oh My Zsh] would do like to check for updates? [y/n]: yupdating Oh My Zsherror:cannot pull with rebase:you has unstaged changes. There is an error updating. Try again later??. ~ git: (master)?.?. ~ git: (Master)?. Lspython?. ~ Git: (Master) ?. cd python?. Python git: (Master)?. Ls03062.pcap 1_0310.py 1.py ftp1.py ftp2.py ftp.py master.zip paramiko.log pydiction ssh.py startup.py?. Python git: (Master)?. Vim startup.py?. Python git: (Master)?. Vim startup.py 1 #startup. py2 #!/usr/bin/python3 # python startup file45 import sys6 import readline7 import rlcomple Ter8 Import atexit9 Import os10 # tab COMPLETION11 readline.parse_and_bind (' Tab:complete ') # History File13 Histfile = Os.path.join (os.environ[' HOME '], '. Pythonhistory ') try:15 readline.read_history_file (histfile) + except IOError : Pass18 atexit.register (Readline.write_history_file, histfile) 1920x1080 OS, Histfile, ReadLine, rlcompleter~~~~~~~~~ ~~~~~~~:%s/import/immport/g connecting to 192.168.127.130:23...connection established. Escape character is ' ^@] '. Ubuntu 16.04.2 Ltsubuntu64-casa login:casapassword: login incorrectubuntu64-casa login:casaPassword:Last Login: Tue Mar 09:29:56 CST from 192.168.127.1 on Pts/1welcome to Ubuntu 16.04.2 LTS (gnu/linux 4.4.0-62-generic x86_64) * documentation:https://help.ubuntu.com* management:https:// landscape.canonical.com* support:https://ubuntu.com/advantage 26 packages can be updated.25 updates is security Updates. signature not found in user Keyringperhaps try the interactive ' ecryptfs-mount-private ' [Oh My Zsh] Wou LD What do I check for updates? [y/n]: yupdating Oh My Zsherror:cannot pull with rebase:you has unstaged changes. There is an error updating. Try again later??. ~ git: (master)?.?. ~ git: (Master)?. Lspython?. ~ git: (Master)?. cd python?. Python git: (Master)?. Ls03062.pcap 1_0310.py 1.py ftp1.py ftp2.py ftp.py master.zip paramiko.log pydiction ssh.py startup.py?. Python git: (Master)?. Vim startup.py?. Python git: (Master)?. Vim startup.py 1 #startup. py2 #!/usr/bin/python3 # python startup file45 immport sys6 immport readline7 immport rlcom Pleter8 immport atexit9 immport os10 # tab COMPLETION11 readline.parse_and_bind (' Tab:complete ')# History File13 Histfile = Os.path.join (os.environ[' HOME '), '. Pythonhistory ') try:15 readline.read_history_file ( histfile) except Ioerror:17 pass18 atexit.register (readline.write_history_file, histfile) 1920x1080 OS, Histfile, ReadLine, rlcompleter~~~~~~~~~~~~~~~~--VISUAL--5,1 All
- VI Delete and copy multiple lines
One, multi-line dd Delete Row NDD delete the N-line DW starting at the current line deletes a character starting with the current character NDW delete the n characters starting with the current character d$, D deletes a line of characters starting with the current character D) Delete to the beginning of the next sentence D} Delete to the beginning of the next paragraph to remove 2 rows two, Copy multi-line task: Copy rows 9th through 15th to line 16th Method 1: (Highly recommended): 9,15 copy 16 or: 9,15 Co 16 can be: 9,15 move 16 or: 9,15 m 16 The text content of the 9th line to the 15th line to the back of the 16th line Method 2: The cursor moves to the end line, the MA cursor moves to the start line, the input y ' a cursor moves to the line that needs to be copied, the input p, the line before the copy is input uppercase P Method 3: Move the cursor to line 9th SHIFT + V then move the cursor to line 15th CTRL + C and then the cursor to the 16th line Method 4: Move the cursor to the starting line, enter the MA cursor to the end line, enter the MB cursor to the paste line, enter the MC and enter: ' A, ' B, CO ' C change the Co to M is cut to delete multiple rows, enter: ' A, ' B de vi set auto indent: Set Smartindentvi setting Displays line numbers: Set number or set Nu
Vim Batch Replacement