/usr/share/vile/shifts.rc is in vile-common 9.8q-1build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 | ; $Id: shifts.rc,v 1.4 2000/05/19 09:54:12 tom Exp $
; These macros are reimplementations for vile of scripts which I wrote for
; xedit in 1981-1983. Editing with xedit or ispf on IBM 3270 terminals has the
; odd quirk that when you put the terminal into insert-mode, it is possible
; (easy) to shift characters off the end of the line and lose them. So I wrote
; macros to make it simple to shift text left or right.
;
; The IBM terminals did not use tabs; these macros detab/entab the line.
; Shifts the current line left or right so the first nonblank character aligns
; with the cursor. Unlike ShiftRite and ShiftLeft, does not squeeze out blanks.
store-procedure AlignToCol int="Column"
~local $curcol $curline
~local %col %row %original %detabbed %entabbed %replacer %n %n1
setv %col=$1
~if &greater $cmd-count 1
setv %n &subtract $cmd-count 1
~hidden %n next-line
~endif
setv %row $curline
; read the original line contents, for reference
setv $curcol 1
setv %original $line
; convert the tabs in the line to spaces
setv $curline=%row $curcol=%col
detab-lines-til
; ...and read its contents
setv $curcol 1
setv %detabbed $line
; restore the contents of the line
~if ¬ &seq %detabbed %original
undo-changes-backward
~endif
; See if there are nonblanks to the left or right of the cursor
~if &sequal &trim %detabbed ''
write-message "Line is empty"
~else
setv %n 1
setv %n1 $1
~while ¬ &greater %n &length %detabbed
~if ¬ &sequal &middle %detabbed %n 1 ' '
setv %n1 %n
~break
~endif
setv %n &add %n 1
~endwhile
~if &equal %n1 $1
write-message "No change"
~else
~if &greater %n1 $1
setv %n1 &add %n1 1
setv %replacer &right %detabbed &subtract %n1 $1
~else
setv %replacer %detabbed
~while ¬ &equal %n1 $1
setv %replacer &cat ' ' %replacer
setv %n1 &add %n1 1
~endwhile
~endif
setv $line %replacer
; if the original line had tabs, entab the line.
; juggle a little to make this a single-undo
~if ¬ &seq %detabbed %original
entab-lines-til
setv $curcol 1
setv %entabbed $line
~if ¬ &seq %entabbed %replacer
undo-changes-backward
undo-changes-backward
setv $line %entabbed
~endif
~endif
~endif
~endif
~endm
; Shifts the current line left or right so the first nonblank character aligns
; with the cursor. Unlike ShiftRite and ShiftLeft, does not squeeze out blanks.
store-procedure AlignToCursor
AlignToCol $curcol
~endm
bind-key AlignToCursor #0
; Drags the word beginning to the left of the cursor to the cursor's column.
; Compresses extra blanks between that word and the following ones on the
; current line.
;
; FIXME: If the line is then longer than the fillcolumn, split the line
; accordingly.
store-procedure ShiftRite
~local $curcol $curline
~local %row %col
~local %detabbed %diff %entabbed %n %n1 %n2
~local %original %pad %replacer %s1 %s2
setv %col $curcol
setv %row $curline
; read the original line contents, for reference
setv $curcol 1
setv %original $line
; convert the tabs in the line to spaces
setv $curline=%row $curcol=%col
detab-lines-til
; ...and read its contents
setv $curcol 1
setv %detabbed $line
; restore the contents of the line
~if ¬ &seq %detabbed %original
undo-changes-backward
~endif
setv %n %col
; if we are on a nonblank, check if the previous character is a
; blank. if so, we'll skip over _those_ blanks.
~if ¬ &seq ' ' &middle %detabbed %n 1
setv %n1 &subtract %n 1
~if &and &greater %n1 0 &seq ' ' &middle %detabbed %n1 1
setv %n %n1
~endif
~endif
; if not on a non-blank, find one
~while &seq ' ' &middle %detabbed %n 1
setv %n &subtract %n 1
~if &less %n 1
write-message "No change"
~return
~endif
~endwhile
; find the last blank immediately to the left of the non-blanks
~while &greater %n 0
setv %n &subtract %n 1
~if &seq ' ' &middle %detabbed %n 1
~break
~endif
~endwhile
~if &or &equal %n 0 &seq ' ' &middle %detabbed %n 1
setv %diff &subtract %col %n
~if &greater %diff 1
setv %pad ''
~if &greater %n 0
setv %n1 &subtract %n 1
~else
setv %n1 %n
setv %n &add %n 1
~endif
setv %s1 &left %detabbed %n1
setv %s2 &right %detabbed %n
~while &greater %diff 1
setv %diff &subtract %diff 1
setv %pad &cat %pad ' '
setv %n2 &sindex %s2 ' '
~if &greater %n2 0
setv %s2 &cat \
&left %s2 %n2 \
&right %s2 &add %n2 2
~endif
~endwhile
setv $curline %row
setv %replacer &cat %s1 &cat %pad %s2
setv $line %replacer
; if the original line had tabs, entab the line.
; juggle a little to make this a single-undo
~if ¬ &seq %detabbed %original
entab-lines-til
setv $curcol 1
setv %entabbed $line
~if ¬ &seq %entabbed %replacer
undo-changes-backward
undo-changes-backward
setv $line %entabbed
~endif
~endif
~return
~endif
~endif
write-message "No change"
~endm
bind-key ShiftRite #!
; Drags the word beginning to the right of the cursor to the cursor's column.
; If needed, compresses extra blanks on the left, but does not split the line.
store-procedure ShiftLeft
~local $curcol $curline
~local %col %row
~local %detabbed %diff %entabbed %len %n %n1 %n2 %original %replacer
setv %col $curcol
setv %row $curline
; read the original line contents, for reference
setv $curcol 1
setv %original $line
; convert the tabs in the line to spaces
setv $curline=%row $curcol=%col
detab-lines-til
; ...and read its contents
setv $curcol 1
setv %detabbed $line
; restore the contents of the line
~if ¬ &seq %detabbed %original
undo-changes-backward
~endif
setv %len &length %detabbed
setv %n %col
; if we're on a nonblank, skip to the end of that.
~while ¬ &seq ' ' &middle %detabbed %n 1
setv %n &add %n 1
~if &greater %n %len
write-message "No change"
~return
~endif
~endwhile
; skip blanks to the first nonblank
~while &seq ' ' &middle %detabbed %n 1
setv %n &add %n 1
~if &greater %n %len
write-message "No change"
~return
~endif
~endwhile
setv %diff &subtract %n %col
~if &greater %diff 1
; trim blanks to move the word left to the cursor position.
; we prefer to take blanks from the right, between the cursor
; and the word, but will trim blanks from the right end of the
; segment to the left of the cursor.
setv %replacer %detabbed
~while ¬ &equal %n %col
setv %n1 %n
setv %n2 0
~while ¬ &greater %n1 %n
~if &seq ' ' &middle %replacer %n1 2
setv %n2 %n1
~break
~endif
setv %n1 &add %n1 1
~endwhile
~if &equal %n2 0
setv %n1 %n
~while &greater %n1 1
~if &seq ' ' &middle %replacer %n1 2
setv %n2 %n1
~break
~endif
setv %n1 &subtract %n1 1
~endwhile
~endif
~if &equal %n2 0
~if &and \
&equal %n1 1 \
&seq ' ' &middle %replacer %n1 1
setv %n2 1
~else
~break
~endif
~endif
setv %replacer &cat \
&left %replacer &subtract %n2 1 \
&right %replacer &add %n2 1
setv %n &subtract %n 1
~endwhile
~if ¬ &seq %replacer %detabbed
setv $line %replacer
; if the original line had tabs, entab the line.
; juggle a little to make this a single-undo
~if ¬ &seq %detabbed %original
entab-lines-til
setv $curcol 1
setv %entabbed $line
~if ¬ &seq %entabbed %replacer
undo-changes-backward
undo-changes-backward
setv $line %entabbed
~endif
~endif
~return
~endif
~endif
write-message "No change"
~endm
bind-key ShiftLeft #@
|