mirror of
				https://github.com/mhinz/vim-galore.git
				synced 2025-11-04 11:55:35 +08:00 
			
		
		
		
	Usage: block insert
This commit is contained in:
		
							
								
								
									
										32
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										32
									
								
								README.md
									
									
									
									
									
								
							@@ -13,6 +13,7 @@
 | 
			
		||||
- [Getting help offline](#getting-help-offline)
 | 
			
		||||
- [Getting help online](#getting-help-online)
 | 
			
		||||
- [Managing plugins](#managing-plugins)
 | 
			
		||||
- [Block insert](#block-insert)
 | 
			
		||||
 | 
			
		||||
#### [Debugging](#debugging-1)
 | 
			
		||||
- [General tips](#general-tips)
 | 
			
		||||
@@ -258,6 +259,37 @@ in alphabetic sequence:
 | 
			
		||||
 | 
			
		||||
Plug is my favorite, but your mileage may vary.
 | 
			
		||||
 | 
			
		||||
#### Block insert
 | 
			
		||||
 | 
			
		||||
This is a technique to insert the same text on multiple consecutive lines at the
 | 
			
		||||
same time. See this
 | 
			
		||||
[demo](https://raw.githubusercontent.com/mhinz/vim-galore/master/pics/block_insert.gif).
 | 
			
		||||
 | 
			
		||||
Switch to visual block mode with `<c-v>`. Afterwards go down for a few lines.
 | 
			
		||||
Hit `I` or `A` and start entering your text.
 | 
			
		||||
 | 
			
		||||
It might be a bit confusing at first, but text is always entered for the current
 | 
			
		||||
line and only after finishing the current insertion, the same text will be
 | 
			
		||||
applied to all other lines of the prior visual selection.
 | 
			
		||||
 | 
			
		||||
So a simple example is `<c-v>3jItext<esc>`.
 | 
			
		||||
 | 
			
		||||
If you have lines of different length and want to append the same text right
 | 
			
		||||
after the end of each line, do this: `<c-v>3j$Atext<esc>`.
 | 
			
		||||
 | 
			
		||||
Sometime you need to place the cursor somewhere after the end of the current
 | 
			
		||||
line. You can't do that by default, but you can set the `virtualedit` option:
 | 
			
		||||
```viml
 | 
			
		||||
set virtualedit=all
 | 
			
		||||
```
 | 
			
		||||
Afterwards `$10l` or `90|` work even after the end of the line.
 | 
			
		||||
 | 
			
		||||
See `:h blockwise-examples` for more info. It might seem complicated at first,
 | 
			
		||||
but quickly becomes second nature.
 | 
			
		||||
 | 
			
		||||
If you want to get real fancy, have a look at
 | 
			
		||||
[multiple-cursors](https://github.com/terryma/vim-multiple-cursors).
 | 
			
		||||
 | 
			
		||||
## Debugging
 | 
			
		||||
 | 
			
		||||
#### General tips
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										
											BIN
										
									
								
								pics/block_insert.gif
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								pics/block_insert.gif
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| 
		 After Width: | Height: | Size: 34 KiB  | 
		Reference in New Issue
	
	Block a user