mirror of
				https://github.com/mhinz/vim-galore.git
				synced 2025-11-04 11:55:35 +08:00 
			
		
		
		
	Tips: Saner command-line history
This commit is contained in:
		@@ -7,6 +7,7 @@ All notable changes to this project will be documented in this file.
 | 
			
		||||
### Added
 | 
			
		||||
 | 
			
		||||
- Basics: [Marks?](README.md#marks)
 | 
			
		||||
- Tips: [Saner command-line history](README.md#saner-command-line-history)
 | 
			
		||||
- Debugging: [Verbosity](README.md#verbosity)
 | 
			
		||||
- Debugging: [Debugging Vim scripts](README.md#debugging-vim-scripts)
 | 
			
		||||
- Miscellaneous: [Easter eggs](README.md#easter-eggs)
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										20
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										20
									
								
								README.md
									
									
									
									
									
								
							@@ -36,6 +36,7 @@ added every day. Things about to be added can be found here:
 | 
			
		||||
#### [Tips](#tips-1)
 | 
			
		||||
 | 
			
		||||
- [Saner behavior of n and N](#saner-behavior-of-n-and-n)
 | 
			
		||||
- [Saner command-line history](#saner-command-line-history)
 | 
			
		||||
- [Quickly move current line](#quickly-move-current-line)
 | 
			
		||||
- [Quickly add empty lines](#quickly-add-empty-lines)
 | 
			
		||||
- [Quickly edit your macros](#quickly-edit-your-macros)
 | 
			
		||||
@@ -697,6 +698,25 @@ nnoremap <expr> n  'Nn'[v:searchforward]
 | 
			
		||||
nnoremap <expr> N  'nN'[v:searchforward]
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
#### Saner command-line history
 | 
			
		||||
 | 
			
		||||
If you're anything like me, you're used to going to next and previous items via
 | 
			
		||||
`<c-n>` and `<c-p>` respectively. By default, this also works in the
 | 
			
		||||
command-line and recalls older or more recent command-lines from history.
 | 
			
		||||
 | 
			
		||||
So far, so good. But `<up>` and `<down>` are even smarter! They recall the
 | 
			
		||||
command-line whose beginning matches the current command-line. E.g. `:echo <up>`
 | 
			
		||||
may change to `:echo "Vim rocks!"`.
 | 
			
		||||
 | 
			
		||||
Of course I don't want you to reach to the arrow keys, just map it instead:
 | 
			
		||||
 | 
			
		||||
```viml
 | 
			
		||||
cnoremap <c-n>  <down>
 | 
			
		||||
cnoremap <c-p>  <up>
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
I depend on this behaviour several times a day.
 | 
			
		||||
 | 
			
		||||
#### Quickly move current line
 | 
			
		||||
 | 
			
		||||
Sometimes I need a quick way to move the current line above or below:
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user