Mercurial > vim
comparison runtime/doc/eval.txt @ 6991:814f1f569e4a v7.4.813
patch 7.4.813
Problem: It is not possible to save and restore character search state.
Solution: Add getcharsearch() and setcharsearch(). (James McCoy)
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Tue, 11 Aug 2015 14:26:19 +0200 |
parents | b2673982c625 |
children | 349e6c01f35d |
comparison
equal
deleted
inserted
replaced
6990:9c248be4e7d2 | 6991:814f1f569e4a |
---|---|
1969 List search for {pattern} | 1969 List search for {pattern} |
1970 server2client( {clientid}, {string}) | 1970 server2client( {clientid}, {string}) |
1971 Number send reply string | 1971 Number send reply string |
1972 serverlist() String get a list of available servers | 1972 serverlist() String get a list of available servers |
1973 setbufvar( {expr}, {varname}, {val}) set {varname} in buffer {expr} to {val} | 1973 setbufvar( {expr}, {varname}, {val}) set {varname} in buffer {expr} to {val} |
1974 setcharsearch( {dict}) Dict set character search from {dict} | |
1974 setcmdpos( {pos}) Number set cursor position in command-line | 1975 setcmdpos( {pos}) Number set cursor position in command-line |
1975 setline( {lnum}, {line}) Number set line {lnum} to {line} | 1976 setline( {lnum}, {line}) Number set line {lnum} to {line} |
1976 setloclist( {nr}, {list}[, {action}]) | 1977 setloclist( {nr}, {list}[, {action}]) |
1977 Number modify location list using {list} | 1978 Number modify location list using {list} |
1978 setmatches( {list}) Number restore a list of matches | 1979 setmatches( {list}) Number restore a list of matches |
3359 128 command (Macintosh only) | 3360 128 command (Macintosh only) |
3360 Only the modifiers that have not been included in the | 3361 Only the modifiers that have not been included in the |
3361 character itself are obtained. Thus Shift-a results in "A" | 3362 character itself are obtained. Thus Shift-a results in "A" |
3362 without a modifier. | 3363 without a modifier. |
3363 | 3364 |
3365 getcharsearch() *getcharsearch()* | |
3366 Return the current character search information as a {dict} | |
3367 with the following entries: | |
3368 | |
3369 char character previously used for a character | |
3370 search (|t|, |f|, |T|, or |F|); empty string | |
3371 if no character search has been performed | |
3372 forward direction of character search; 1 for forward, | |
3373 0 for backward | |
3374 until type of character search; 1 for a |t| or |T| | |
3375 character search, 0 for an |f| or |F| | |
3376 character search | |
3377 | |
3378 This can be useful to always have |;| and |,| search | |
3379 forward/backward regardless of the direction of the previous | |
3380 character search: > | |
3381 :nnoremap <expr> ; getcharsearch().forward ? ';' : ',' | |
3382 :nnoremap <expr> , getcharsearch().forward ? ',' : ';' | |
3383 < Also see |setcharsearch()|. | |
3384 | |
3364 getcmdline() *getcmdline()* | 3385 getcmdline() *getcmdline()* |
3365 Return the current command-line. Only works when the command | 3386 Return the current command-line. Only works when the command |
3366 line is being edited, thus requires use of |c_CTRL-\_e| or | 3387 line is being edited, thus requires use of |c_CTRL-\_e| or |
3367 |c_CTRL-R_=|. | 3388 |c_CTRL-R_=|. |
3368 Example: > | 3389 Example: > |
5394 Note that the variable name without "b:" must be used. | 5415 Note that the variable name without "b:" must be used. |
5395 Examples: > | 5416 Examples: > |
5396 :call setbufvar(1, "&mod", 1) | 5417 :call setbufvar(1, "&mod", 1) |
5397 :call setbufvar("todo", "myvar", "foobar") | 5418 :call setbufvar("todo", "myvar", "foobar") |
5398 < This function is not available in the |sandbox|. | 5419 < This function is not available in the |sandbox|. |
5420 | |
5421 setcharsearch() *setcharsearch()* | |
5422 Set the current character search information to {dict}, | |
5423 which contains one or more of the following entries: | |
5424 | |
5425 char character which will be used for a subsequent | |
5426 |,| or |;| command; an empty string clears the | |
5427 character search | |
5428 forward direction of character search; 1 for forward, | |
5429 0 for backward | |
5430 until type of character search; 1 for a |t| or |T| | |
5431 character search, 0 for an |f| or |F| | |
5432 character search | |
5433 | |
5434 This can be useful to save/restore a user's character search | |
5435 from a script: > | |
5436 :let prevsearch = getcharsearch() | |
5437 :" Perform a command which clobbers user's search | |
5438 :call setcharsearch(prevsearch) | |
5439 < Also see |getcharsearch()|. | |
5399 | 5440 |
5400 setcmdpos({pos}) *setcmdpos()* | 5441 setcmdpos({pos}) *setcmdpos()* |
5401 Set the cursor position in the command line to byte position | 5442 Set the cursor position in the command line to byte position |
5402 {pos}. The first position is 1. | 5443 {pos}. The first position is 1. |
5403 Use |getcmdpos()| to obtain the current position. | 5444 Use |getcmdpos()| to obtain the current position. |