Mercurial > vim
annotate runtime/pack/dist/opt/justify/plugin/justify.vim @ 31301:eeb4d72e523d v9.0.0984
patch 9.0.0984: GUI: remote_foreground() does not always work
Commit: https://github.com/vim/vim/commit/023930d62e898652e68c938c6d7ac232556cb7a9
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Dec 1 19:40:55 2022 +0000
patch 9.0.0984: GUI: remote_foreground() does not always work
Problem: GUI: remote_foreground() does not always work. (Ron Aaron)
Solution: For GTK use gtk_window_set_keep_above(). (issue https://github.com/vim/vim/issues/11641)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 01 Dec 2022 20:45:04 +0100 |
parents | 7ac9d9e98892 |
children | 20ab46fe8a16 |
rev | line source |
---|---|
8769
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
1 " Function to left and right align text. |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
2 " |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
3 " Written by: Preben "Peppe" Guldberg <c928400@student.dtu.dk> |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4 " Created: 980806 14:13 (or around that time anyway) |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
5 " Revised: 001103 00:36 (See "Revisions" below) |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
6 |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
7 |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
8 " function Justify( [ textwidth [, maxspaces [, indent] ] ] ) |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
9 " |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
10 " Justify() will left and right align a line by filling in an |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
11 " appropriate amount of spaces. Extra spaces are added to existing |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
12 " spaces starting from the right side of the line. As an example, the |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
13 " following documentation has been justified. |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
14 " |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
15 " The function takes the following arguments: |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
16 |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
17 " textwidth argument |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
18 " ------------------ |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
19 " If not specified, the value of the 'textwidth' option is used. If |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
20 " 'textwidth' is zero a value of 80 is used. |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
21 " |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
22 " Additionally the arguments 'tw' and '' are accepted. The value of |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
23 " 'textwidth' will be used. These are handy, if you just want to specify |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
24 " the maxspaces argument. |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
25 |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
26 " maxspaces argument |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
27 " ------------------ |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
28 " If specified, alignment will only be done, if the longest space run |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
29 " after alignment is no longer than maxspaces. |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
30 " |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
31 " An argument of '' is accepted, should the user like to specify all |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
32 " arguments. |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
33 " |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
34 " To aid user defined commands, negative values are accepted aswell. |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
35 " Using a negative value specifies the default behaviour: any length of |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
36 " space runs will be used to justify the text. |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
37 |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
38 " indent argument |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
39 " --------------- |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
40 " This argument specifies how a line should be indented. The default is |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
41 " to keep the current indentation. |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
42 " |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
43 " Negative values: Keep current amount of leading whitespace. |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
44 " Positive values: Indent all lines with leading whitespace using this |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
45 " amount of whitespace. |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
46 " |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
47 " Note that the value 0, needs to be quoted as a string. This value |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
48 " leads to a left flushed text. |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
49 " |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
50 " Additionally units of 'shiftwidth'/'sw' and 'tabstop'/'ts' may be |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
51 " added. In this case, if the value of indent is positive, the amount of |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
52 " whitespace to be added will be multiplied by the value of the |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
53 " 'shiftwidth' and 'tabstop' settings. If these units are used, the |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
54 " argument must be given as a string, eg. Justify('','','2sw'). |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
55 " |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
56 " If the values of 'sw' or 'tw' are negative, they are treated as if |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
57 " they were 0, which means that the text is flushed left. There is no |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
58 " check if a negative number prefix is used to change the sign of a |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
59 " negative 'sw' or 'ts' value. |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
60 " |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
61 " As with the other arguments, '' may be used to get the default |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
62 " behaviour. |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
63 |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
64 |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
65 " Notes: |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
66 " |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
67 " If the line, adjusted for space runs and leading/trailing whitespace, |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
68 " is wider than the used textwidth, the line will be left untouched (no |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
69 " whitespace removed). This should be equivalent to the behaviour of |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
70 " :left, :right and :center. |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
71 " |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
72 " If the resulting line is shorter than the used textwidth it is left |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
73 " untouched. |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
74 " |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
75 " All space runs in the line are truncated before the alignment is |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
76 " carried out. |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
77 " |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
78 " If you have set 'noexpandtab', :retab! is used to replace space runs |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
79 " with whitespace using the value of 'tabstop'. This should be |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
80 " conformant with :left, :right and :center. |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
81 " |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
82 " If joinspaces is set, an extra space is added after '.', '?' and '!'. |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
83 " If 'cpooptions' include 'j', extra space is only added after '.'. |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
84 " (This may on occasion conflict with maxspaces.) |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
85 |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
86 |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
87 " Related mappings: |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
88 " |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
89 " Mappings that will align text using the current text width, using at |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
90 " most four spaces in a space run and keeping current indentation. |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
91 nmap _j :%call Justify('tw',4)<CR> |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
92 vmap _j :call Justify('tw',4)<CR> |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
93 " |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
94 " Mappings that will remove space runs and format lines (might be useful |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
95 " prior to aligning the text). |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
96 nmap ,gq :%s/\s\+/ /g<CR>gq1G |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
97 vmap ,gq :s/\s\+/ /g<CR>gvgq |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
98 |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
99 |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
100 " User defined command: |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
101 " |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
102 " The following is an ex command that works as a shortcut to the Justify |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
103 " function. Arguments to Justify() can be added after the command. |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
104 com! -range -nargs=* Justify <line1>,<line2>call Justify(<f-args>) |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
105 " |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
106 " The following commands are all equivalent: |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
107 " |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
108 " 1. Simplest use of Justify(): |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
109 " :call Justify() |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
110 " :Justify |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
111 " |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
112 " 2. The _j mapping above via the ex command: |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
113 " :%Justify tw 4 |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
114 " |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
115 " 3. Justify visualised text at 72nd column while indenting all |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
116 " previously indented text two shiftwidths |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
117 " :'<,'>call Justify(72,'','2sw') |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
118 " :'<,'>Justify 72 -1 2sw |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
119 " |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
120 " This documentation has been justified using the following command: |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
121 ":se et|kz|1;/^" function Justify(/+,'z-g/^" /s/^" //|call Justify(70,3)|s/^/" / |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
122 |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
123 " Revisions: |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
124 " 001103: If 'joinspaces' was set, calculations could be wrong. |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
125 " Tabs at start of line could also lead to errors. |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
126 " Use setline() instead of "exec 's/foo/bar/' - safer. |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
127 " Cleaned up the code a bit. |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
128 " |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
129 " Todo: Convert maps to the new script specific form |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
130 |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
131 " Error function |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
132 function! Justify_error(message) |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
133 echohl Error |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
134 echo "Justify([tw, [maxspaces [, indent]]]): " . a:message |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
135 echohl None |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
136 endfunction |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
137 |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
138 |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
139 " Now for the real thing |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
140 function! Justify(...) range |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
141 |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
142 if a:0 > 3 |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
143 call Justify_error("Too many arguments (max 3)") |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
144 return 1 |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
145 endif |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
146 |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
147 " Set textwidth (accept 'tw' and '' as arguments) |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
148 if a:0 >= 1 |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
149 if a:1 =~ '^\(tw\)\=$' |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
150 let tw = &tw |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
151 elseif a:1 =~ '^\d\+$' |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
152 let tw = a:1 |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
153 else |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
154 call Justify_error("tw must be a number (>0), '' or 'tw'") |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
155 return 2 |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
156 endif |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
157 else |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
158 let tw = &tw |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
159 endif |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
160 if tw == 0 |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
161 let tw = 80 |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
162 endif |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
163 |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
164 " Set maximum number of spaces between WORDs |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
165 if a:0 >= 2 |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
166 if a:2 == '' |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
167 let maxspaces = tw |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
168 elseif a:2 =~ '^-\d\+$' |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
169 let maxspaces = tw |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
170 elseif a:2 =~ '^\d\+$' |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
171 let maxspaces = a:2 |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
172 else |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
173 call Justify_error("maxspaces must be a number or ''") |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
174 return 3 |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
175 endif |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
176 else |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
177 let maxspaces = tw |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
178 endif |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
179 if maxspaces <= 1 |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
180 call Justify_error("maxspaces should be larger than 1") |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
181 return 4 |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
182 endif |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
183 |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
184 " Set the indentation style (accept sw and ts units) |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
185 let indent_fix = '' |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
186 if a:0 >= 3 |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
187 if (a:3 == '') || a:3 =~ '^-[1-9]\d*\(shiftwidth\|sw\|tabstop\|ts\)\=$' |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
188 let indent = -1 |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
189 elseif a:3 =~ '^-\=0\(shiftwidth\|sw\|tabstop\|ts\)\=$' |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
190 let indent = 0 |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
191 elseif a:3 =~ '^\d\+\(shiftwidth\|sw\|tabstop\|ts\)\=$' |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
192 let indent = substitute(a:3, '\D', '', 'g') |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
193 elseif a:3 =~ '^\(shiftwidth\|sw\|tabstop\|ts\)$' |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
194 let indent = 1 |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
195 else |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
196 call Justify_error("indent: a number with 'sw'/'ts' unit") |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
197 return 5 |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
198 endif |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
199 if indent >= 0 |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
200 while indent > 0 |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
201 let indent_fix = indent_fix . ' ' |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
202 let indent = indent - 1 |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
203 endwhile |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
204 let indent_sw = 0 |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
205 if a:3 =~ '\(shiftwidth\|sw\)' |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
206 let indent_sw = &sw |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
207 elseif a:3 =~ '\(tabstop\|ts\)' |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
208 let indent_sw = &ts |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
209 endif |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
210 let indent_fix2 = '' |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
211 while indent_sw > 0 |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
212 let indent_fix2 = indent_fix2 . indent_fix |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
213 let indent_sw = indent_sw - 1 |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
214 endwhile |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
215 let indent_fix = indent_fix2 |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
216 endif |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
217 else |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
218 let indent = -1 |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
219 endif |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
220 |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
221 " Avoid substitution reports |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
222 let save_report = &report |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
223 set report=1000000 |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
224 |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
225 " Check 'joinspaces' and 'cpo' |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
226 if &js == 1 |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
227 if &cpo =~ 'j' |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
228 let join_str = '\(\. \)' |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
229 else |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
230 let join_str = '\([.!?!] \)' |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
231 endif |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
232 endif |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
233 |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
234 let cur = a:firstline |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
235 while cur <= a:lastline |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
236 |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
237 let str_orig = getline(cur) |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
238 let save_et = &et |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
239 set et |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
240 exec cur . "retab" |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
241 let &et = save_et |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
242 let str = getline(cur) |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
243 |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
244 let indent_str = indent_fix |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
245 let indent_n = strlen(indent_str) |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
246 " Shall we remember the current indentation |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
247 if indent < 0 |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
248 let indent_orig = matchstr(str_orig, '^\s*') |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
249 if strlen(indent_orig) > 0 |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
250 let indent_str = indent_orig |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
251 let indent_n = strlen(matchstr(str, '^\s*')) |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
252 endif |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
253 endif |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
254 |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
255 " Trim trailing, leading and running whitespace |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
256 let str = substitute(str, '\s\+$', '', '') |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
257 let str = substitute(str, '^\s\+', '', '') |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
258 let str = substitute(str, '\s\+', ' ', 'g') |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
259 let str_n = strdisplaywidth(str) |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
260 |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
261 " Possible addition of space after punctuation |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
262 if exists("join_str") |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
263 let str = substitute(str, join_str, '\1 ', 'g') |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
264 endif |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
265 let join_n = strdisplaywidth(str) - str_n |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
266 |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
267 " Can extraspaces be added? |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
268 " Note that str_n may be less than strlen(str) [joinspaces above] |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
269 if strdisplaywidth(str) <= tw - indent_n && str_n > 0 |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
270 " How many spaces should be added |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
271 let s_add = tw - str_n - indent_n - join_n |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
272 let s_nr = strlen(substitute(str, '\S', '', 'g') ) - join_n |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
273 let s_dup = s_add / s_nr |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
274 let s_mod = s_add % s_nr |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
275 |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
276 " Test if the changed line fits with tw |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
277 if 0 <= (str_n + (maxspaces - 1)*s_nr + indent_n) - tw |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
278 |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
279 " Duplicate spaces |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
280 while s_dup > 0 |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
281 let str = substitute(str, '\( \+\)', ' \1', 'g') |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
282 let s_dup = s_dup - 1 |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
283 endwhile |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
284 |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
285 " Add extra spaces from the end |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
286 while s_mod > 0 |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
287 let str = substitute(str, '\(\(\s\+\S\+\)\{' . s_mod . '}\)$', ' \1', '') |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
288 let s_mod = s_mod - 1 |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
289 endwhile |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
290 |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
291 " Indent the line |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
292 if indent_n > 0 |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
293 let str = substitute(str, '^', indent_str, '' ) |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
294 endif |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
295 |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
296 " Replace the line |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
297 call setline(cur, str) |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
298 |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
299 " Convert to whitespace |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
300 if &et == 0 |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
301 exec cur . 'retab!' |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
302 endif |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
303 |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
304 endif " Change of line |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
305 endif " Possible change |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
306 |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
307 let cur = cur + 1 |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
308 endwhile |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
309 |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
310 norm ^ |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
311 |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
312 let &report = save_report |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
313 |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
314 endfunction |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
315 |
7ac9d9e98892
commit https://github.com/vim/vim/commit/2946d0236dc9e23ec0050feacdb959b9ae5672a8
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
316 " EOF vim: tw=78 ts=8 sw=4 sts=4 noet ai |