summaryrefslogtreecommitdiff
path: root/runtime/macros
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2008-07-13 17:41:49 +0000
committerBram Moolenaar <Bram@vim.org>2008-07-13 17:41:49 +0000
commitc236c16d0884c7d6cdc4dbaddb8cb3992085f83e (patch)
tree7d87344cdf07b6b9234abe26ccef39fbbee54f63 /runtime/macros
parentb316376b4893ac3ae62f7f33c483b28b7fc147c0 (diff)
downloadvim-git-c236c16d0884c7d6cdc4dbaddb8cb3992085f83e.tar.gz
updated for version 7.2b-000v7.2b.000
Diffstat (limited to 'runtime/macros')
-rw-r--r--runtime/macros/justify.vim7
1 files changed, 4 insertions, 3 deletions
diff --git a/runtime/macros/justify.vim b/runtime/macros/justify.vim
index 41d0591fe..aa4a9ca58 100644
--- a/runtime/macros/justify.vim
+++ b/runtime/macros/justify.vim
@@ -256,17 +256,18 @@ function! Justify(...) range
let str = substitute(str, '\s\+$', '', '')
let str = substitute(str, '^\s\+', '', '')
let str = substitute(str, '\s\+', ' ', 'g')
- let str_n = strlen(str)
+ " Use substitute() hack to get strlen in characters instead of bytes
+ let str_n = strlen(substitute(str, '.', 'x', 'g'))
" Possible addition of space after punctuation
if exists("join_str")
let str = substitute(str, join_str, '\1 ', 'g')
endif
- let join_n = strlen(str) - str_n
+ let join_n = strlen(substitute(str, '.', 'x', 'g')) - str_n
" Can extraspaces be added?
" Note that str_n may be less than strlen(str) [joinspaces above]
- if strlen(str) < tw - indent_n && str_n > 0
+ if strlen(substitute(str, '.', 'x', 'g')) < tw - indent_n && str_n > 0
" How many spaces should be added
let s_add = tw - str_n - indent_n - join_n
let s_nr = strlen(substitute(str, '\S', '', 'g') ) - join_n