Mercurial > vim
comparison runtime/doc/eval.txt @ 20629:7b8ac5e49451 v8.2.0868
patch 8.2.0868: trim() always trims both ends
Commit: https://github.com/vim/vim/commit/2245ae18e3480057f98fc0e5d9f18091f32a5de0
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun May 31 22:20:36 2020 +0200
patch 8.2.0868: trim() always trims both ends
Problem: trim() always trims both ends.
Solution: Add an argument to only trim the beginning or end. (Yegappan
Lakshmanan, closes #6126)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 31 May 2020 22:30:04 +0200 |
parents | 8bce783af0cb |
children | d6827bd31d1d |
comparison
equal
deleted
inserted
replaced
20628:8131c8d8fbf0 | 20629:7b8ac5e49451 |
---|---|
2896 timer_stopall() none stop all timers | 2896 timer_stopall() none stop all timers |
2897 tolower({expr}) String the String {expr} switched to lowercase | 2897 tolower({expr}) String the String {expr} switched to lowercase |
2898 toupper({expr}) String the String {expr} switched to uppercase | 2898 toupper({expr}) String the String {expr} switched to uppercase |
2899 tr({src}, {fromstr}, {tostr}) String translate chars of {src} in {fromstr} | 2899 tr({src}, {fromstr}, {tostr}) String translate chars of {src} in {fromstr} |
2900 to chars in {tostr} | 2900 to chars in {tostr} |
2901 trim({text} [, {mask}]) String trim characters in {mask} from {text} | 2901 trim({text} [, {mask} [, {dir}]]) |
2902 String trim characters in {mask} from {text} | |
2902 trunc({expr}) Float truncate Float {expr} | 2903 trunc({expr}) Float truncate Float {expr} |
2903 type({name}) Number type of variable {name} | 2904 type({name}) Number type of variable {name} |
2904 undofile({name}) String undo file name for {name} | 2905 undofile({name}) String undo file name for {name} |
2905 undotree() List undo file tree | 2906 undotree() List undo file tree |
2906 uniq({list} [, {func} [, {dict}]]) | 2907 uniq({list} [, {func} [, {dict}]]) |
10243 < returns "{blob}" | 10244 < returns "{blob}" |
10244 | 10245 |
10245 Can also be used as a |method|: > | 10246 Can also be used as a |method|: > |
10246 GetText()->tr(from, to) | 10247 GetText()->tr(from, to) |
10247 | 10248 |
10248 trim({text} [, {mask}]) *trim()* | 10249 trim({text} [, {mask} [, {dir}]]) *trim()* |
10249 Return {text} as a String where any character in {mask} is | 10250 Return {text} as a String where any character in {mask} is |
10250 removed from the beginning and end of {text}. | 10251 removed from the beginning and/or end of {text}. |
10252 | |
10251 If {mask} is not given, {mask} is all characters up to 0x20, | 10253 If {mask} is not given, {mask} is all characters up to 0x20, |
10252 which includes Tab, space, NL and CR, plus the non-breaking | 10254 which includes Tab, space, NL and CR, plus the non-breaking |
10253 space character 0xa0. | 10255 space character 0xa0. |
10254 This code deals with multibyte characters properly. | 10256 |
10257 The optional {dir} argument specifies where to remove the | |
10258 characters: | |
10259 0 remove from the beginning and end of {text} | |
10260 1 remove only at the beginning of {text} | |
10261 2 remove only at the end of {text} | |
10262 When omitted both ends are trimmed. | |
10263 | |
10264 This function deals with multibyte characters properly. | |
10255 | 10265 |
10256 Examples: > | 10266 Examples: > |
10257 echo trim(" some text ") | 10267 echo trim(" some text ") |
10258 < returns "some text" > | 10268 < returns "some text" > |
10259 echo trim(" \r\t\t\r RESERVE \t\n\x0B\xA0") . "_TAIL" | 10269 echo trim(" \r\t\t\r RESERVE \t\n\x0B\xA0") . "_TAIL" |
10260 < returns "RESERVE_TAIL" > | 10270 < returns "RESERVE_TAIL" > |
10261 echo trim("rm<Xrm<>X>rrm", "rm<>") | 10271 echo trim("rm<Xrm<>X>rrm", "rm<>") |
10262 < returns "Xrm<>X" (characters in the middle are not removed) | 10272 < returns "Xrm<>X" (characters in the middle are not removed) > |
10273 echo trim(" vim ", " ", 2) | |
10274 < returns " vim" | |
10263 | 10275 |
10264 Can also be used as a |method|: > | 10276 Can also be used as a |method|: > |
10265 GetText()->trim() | 10277 GetText()->trim() |
10266 | 10278 |
10267 trunc({expr}) *trunc()* | 10279 trunc({expr}) *trunc()* |