Mercurial > vim
comparison runtime/doc/map.txt @ 24142:34acfef7f60c v8.2.2612
patch 8.2.2612: col('.') may get outdated column value
Commit: https://github.com/vim/vim/commit/18b7d86d7fa997bbb02a069dafacb32a0f73ca1e
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Mar 17 13:28:05 2021 +0100
patch 8.2.2612: col('.') may get outdated column value
Problem: col('.') may get outdated column value.
Solution: Add a note to the help how to make this work and add a test for
it. (closes #7971)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 17 Mar 2021 13:30:03 +0100 |
parents | 99ef85ff1af4 |
children | 4ab4ef0c48b1 |
comparison
equal
deleted
inserted
replaced
24141:6e9204b17dca | 24142:34acfef7f60c |
---|---|
260 func s:OpenPopup() | 260 func s:OpenPopup() |
261 call popup_create(... arguments ...) | 261 call popup_create(... arguments ...) |
262 return "\<Ignore>" | 262 return "\<Ignore>" |
263 endfunc | 263 endfunc |
264 nnoremap <expr> <F3> <Sid>OpenPopup() | 264 nnoremap <expr> <F3> <Sid>OpenPopup() |
265 | |
266 Also, keep in mind that the expression may be evaluated when looking for | |
267 typeahead, before the previous command has been executed. For example: > | |
268 func StoreColumn() | |
269 let g:column = col('.') | |
270 return 'x' | |
271 endfunc | |
272 nnoremap <expr> x StoreColumn() | |
273 nmap ! f!x | |
274 You will notice that g:column has the value from before executing "fx", | |
275 because "z" is evaluated before "fx" is executed. | |
276 This can be solved by inserting <Ignore> before the character that is | |
277 expression-mapped: > | |
278 nmap ! f!<Ignore>x | |
265 | 279 |
266 Be very careful about side effects! The expression is evaluated while | 280 Be very careful about side effects! The expression is evaluated while |
267 obtaining characters, you may very well make the command dysfunctional. | 281 obtaining characters, you may very well make the command dysfunctional. |
268 For this reason the following is blocked: | 282 For this reason the following is blocked: |
269 - Changing the buffer text |textlock|. | 283 - Changing the buffer text |textlock|. |