Convert leading spaces to tabs for each line in selected region.
(self, event=None)
| 317 | return "break" |
| 318 | |
| 319 | def tabify_region_event(self, event=None): |
| 320 | "Convert leading spaces to tabs for each line in selected region." |
| 321 | head, tail, chars, lines = self.get_region() |
| 322 | tabwidth = self._asktabwidth() |
| 323 | if tabwidth is None: |
| 324 | return |
| 325 | for pos in range(len(lines)): |
| 326 | line = lines[pos] |
| 327 | if line: |
| 328 | raw, effective = get_line_indent(line, tabwidth) |
| 329 | ntabs, nspaces = divmod(effective, tabwidth) |
| 330 | lines[pos] = '\t' * ntabs + ' ' * nspaces + line[raw:] |
| 331 | self.set_region(head, tail, chars, lines) |
| 332 | return "break" |
| 333 | |
| 334 | def untabify_region_event(self, event=None): |
| 335 | "Expand tabs to spaces for each line in region." |