OLD | NEW |
1 # This file is a minimal clang-format sublime-integration. To install: | 1 # This file is a minimal clang-format sublime-integration. To install: |
2 # - Change 'binary' if clang-format is not on the path (see below). | 2 # - Change 'binary' if clang-format is not on the path (see below). |
3 # - Put this file into your sublime Packages directory, e.g. on Linux: | 3 # - Put this file into your sublime Packages directory, e.g. on Linux: |
4 # ~/.config/sublime-text-2/Packages/User/clang-format-sublime.py | 4 # ~/.config/sublime-text-2/Packages/User/clang-format-sublime.py |
5 # - Add a key binding: | 5 # - Add a key binding: |
6 # { "keys": ["ctrl+shift+c"], "command": "clang_format" }, | 6 # { "keys": ["ctrl+shift+c"], "command": "clang_format" }, |
7 # | 7 # |
8 # With this integration you can press the bound key and clang-format will | 8 # With this integration you can press the bound key and clang-format will |
9 # format the current lines and selections for all cursor positions. The lines | 9 # format the current lines and selections for all cursor positions. The lines |
10 # or regions are extended to the next bigger syntactic entities. | 10 # or regions are extended to the next bigger syntactic entities. |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 print(error) | 49 print(error) |
50 self.view.replace( | 50 self.view.replace( |
51 edit, sublime.Region(0, self.view.size()), | 51 edit, sublime.Region(0, self.view.size()), |
52 output.decode(encoding)) | 52 output.decode(encoding)) |
53 self.view.sel().clear() | 53 self.view.sel().clear() |
54 for region in regions: | 54 for region in regions: |
55 self.view.sel().add(region) | 55 self.view.sel().add(region) |
56 # FIXME: Without the 10ms delay, the viewport sometimes jumps. | 56 # FIXME: Without the 10ms delay, the viewport sometimes jumps. |
57 sublime.set_timeout(lambda: self.view.set_viewport_position( | 57 sublime.set_timeout(lambda: self.view.set_viewport_position( |
58 old_viewport_position, False), 10) | 58 old_viewport_position, False), 10) |
OLD | NEW |