|
1 | | -*map.txt* For Vim version 8.2. Last change: 2022 May 16 |
| 1 | +*map.txt* For Vim version 8.2. Last change: 2022 Jun 02 |
2 | 2 |
|
3 | 3 |
|
4 | 4 | VIM REFERENCE MANUAL by Bram Moolenaar |
|
63 | 63 | allows for nested and recursive use of mappings. |
64 | 64 | Note: Trailing spaces are included in the {rhs}, |
65 | 65 | because space is a valid Normal mode command. |
| 66 | + See |map-trailing-white|. |
66 | 67 |
|
67 | 68 | *:nore* *:norem* |
68 | 69 | :no[remap] {lhs} {rhs} |mapmode-nvo| *:no* *:noremap* *:nor* |
@@ -100,10 +101,8 @@ modes. |
100 | 101 | for other modes where it applies. |
101 | 102 | It also works when {lhs} matches the {rhs} of a |
102 | 103 | mapping. This is for when an abbreviation applied. |
103 | | - Note: Trailing spaces are included in the {lhs}. This |
104 | | - unmap does NOT work: > |
105 | | - :map @@ foo |
106 | | - :unmap @@ | print |
| 104 | + Note: Trailing spaces are included in the {lhs}. |
| 105 | + See |map-trailing-white|. |
107 | 106 |
|
108 | 107 | :mapc[lear] |mapmode-nvo| *:mapc* *:mapclear* |
109 | 108 | :nmapc[lear] |mapmode-n| *:nmapc* *:nmapclear* |
@@ -168,6 +167,27 @@ that mapping won't get expanded yet, Vim is waiting for another character. |
168 | 167 | If you type a space, then "foo" will get inserted, plus the space. If you |
169 | 168 | type "a", then "bar" will get inserted. |
170 | 169 |
|
| 170 | +Trailing white space ~ |
| 171 | + *map-trailing-white* |
| 172 | +This unmap command does NOT work: > |
| 173 | + :map @@ foo |
| 174 | + :unmap @@ | print |
| 175 | +
|
| 176 | +Because it tries to unmap "@@ ", including the white space before the command |
| 177 | +separator "|". Other examples with trailing white space: > |
| 178 | + unmap @@ |
| 179 | + unmap @@ # Vim9 script comment |
| 180 | + unmap @@ " legacy comment |
| 181 | +
|
| 182 | +An error will be issued, which is very hard to identify, because the ending |
| 183 | +whitespace character in `unmap @@ ` is not visible. |
| 184 | + |
| 185 | +A generic solution is to put the command separator "|" right after the mapped |
| 186 | +keys. After that white space and a comment may follow: > |
| 187 | +
|
| 188 | + unmap @@| # Vim9 scriptcomment |
| 189 | + unmap @@| " legacy scriptcomment |
| 190 | +
|
171 | 191 |
|
172 | 192 | 1.2 SPECIAL ARGUMENTS *:map-arguments* |
173 | 193 |
|
|
0 commit comments