From 9901e63949a3a02c266f32c11933a98b64b61734 Mon Sep 17 00:00:00 2001 From: Marco Hinz Date: Sat, 9 Jan 2016 03:45:13 +0100 Subject: [PATCH] Tips: Saner command-line history --- CHANGELOG.md | 1 + README.md | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f74d91e..47b28b9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/README.md b/README.md index 26186bf..34e89b8 100644 --- a/README.md +++ b/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 n 'Nn'[v:searchforward] nnoremap 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 +`` and `` 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 `` and `` are even smarter! They recall the +command-line whose beginning matches the current command-line. E.g. `:echo ` +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 +cnoremap +``` + +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: