layouts.rst 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  1. Arrange windows
  2. -------------------
  3. kitty has the ability to define its own windows that can be tiled next to each
  4. other in arbitrary arrangements, based on *Layouts*, see below for examples:
  5. .. figure:: screenshots/screenshot.png
  6. :alt: Screenshot, showing three programs in the 'Tall' layout
  7. :align: center
  8. :width: 100%
  9. Screenshot, showing :program:`vim`, :program:`tig` and :program:`git`
  10. running in |kitty| with the *Tall* layout
  11. .. figure:: screenshots/splits.png
  12. :alt: Screenshot, showing windows in the 'Splits' layout
  13. :align: center
  14. :width: 100%
  15. Screenshot, showing windows with arbitrary arrangement in the *Splits*
  16. layout
  17. There are many different layouts available. They are all enabled by default, you
  18. can switch layouts using :ac:`next_layout` (:sc:`next_layout` by default). To
  19. control which layouts are available use :opt:`enabled_layouts`, the first listed
  20. layout becomes the default. Individual layouts and how to use them are described
  21. below.
  22. The Stack Layout
  23. ------------------
  24. This is the simplest layout. It displays a single window using all available
  25. space, other windows are hidden behind it. This layout has no options::
  26. enabled_layouts stack
  27. The Tall Layout
  28. ------------------
  29. Displays one (or optionally more) full-height windows on the left half of the
  30. screen. Remaining windows are tiled vertically on the right half of the screen.
  31. There are options to control how the screen is split horizontally ``bias``
  32. (an integer between ``10`` and ``90``) and options to control how many
  33. full-height windows there are ``full_size`` (a positive integer). The
  34. ``mirrored`` option when set to ``true`` will cause the full-height windows to
  35. be on the right side of the screen instead of the left. The syntax
  36. for the options is::
  37. enabled_layouts tall:bias=50;full_size=1;mirrored=false
  38. ┌──────────────┬───────────────┐
  39. │ │ │
  40. │ │ │
  41. │ │ │
  42. │ ├───────────────┤
  43. │ │ │
  44. │ │ │
  45. │ │ │
  46. │ ├───────────────┤
  47. │ │ │
  48. │ │ │
  49. │ │ │
  50. └──────────────┴───────────────┘
  51. In addition, you can map keys to increase or decrease the number of full-height
  52. windows, or toggle the mirrored setting, for example::
  53. map ctrl+[ layout_action decrease_num_full_size_windows
  54. map ctrl+] layout_action increase_num_full_size_windows
  55. map ctrl+/ layout_action mirror toggle
  56. map ctrl+y layout_action mirror true
  57. map ctrl+n layout_action mirror false
  58. You can also map a key to change the bias by providing a list of percentages
  59. and it will rotate through the list as you press the key. If you only provide
  60. one number it'll toggle between that percentage and 50, for example::
  61. map ctrl+. layout_action bias 50 62 70
  62. map ctrl+, layout_action bias 62
  63. The Fat Layout
  64. ----------------
  65. Displays one (or optionally more) full-width windows on the top half of the
  66. screen. Remaining windows are tiled horizontally on the bottom half of the
  67. screen. There are options to control how the screen is split vertically ``bias``
  68. (an integer between ``10`` and ``90``) and options to control how many
  69. full-width windows there are ``full_size`` (a positive integer). The
  70. ``mirrored`` option when set to ``true`` will cause the full-width windows to be
  71. on the bottom of the screen instead of the top. The syntax for the options is::
  72. enabled_layouts fat:bias=50;full_size=1;mirrored=false
  73. ┌──────────────────────────────┐
  74. │ │
  75. │ │
  76. │ │
  77. │ │
  78. ├─────────┬──────────┬─────────┤
  79. │ │ │ │
  80. │ │ │ │
  81. │ │ │ │
  82. │ │ │ │
  83. │ │ │ │
  84. └─────────┴──────────┴─────────┘
  85. This layout also supports the same layout actions as the *Tall* layout, shown above.
  86. The Grid Layout
  87. --------------------
  88. Display windows in a balanced grid with all windows the same size except the
  89. last column if there are not enough windows to fill the grid. This layout has no
  90. options::
  91. enabled_layouts grid
  92. ┌─────────┬──────────┬─────────┐
  93. │ │ │ │
  94. │ │ │ │
  95. │ │ │ │
  96. │ │ │ │
  97. ├─────────┼──────────┼─────────┤
  98. │ │ │ │
  99. │ │ │ │
  100. │ │ │ │
  101. │ │ │ │
  102. └─────────┴──────────┴─────────┘
  103. .. _splits_layout:
  104. The Splits Layout
  105. --------------------
  106. This is the most flexible layout. You can create any arrangement of windows
  107. by splitting existing windows repeatedly. To best use this layout you should
  108. define a few extra key bindings in :file:`kitty.conf`::
  109. # Create a new window splitting the space used by the existing one so that
  110. # the two windows are placed one above the other
  111. map f5 launch --location=hsplit
  112. # Create a new window splitting the space used by the existing one so that
  113. # the two windows are placed side by side
  114. map f6 launch --location=vsplit
  115. # Create a new window splitting the space used by the existing one so that
  116. # the two windows are placed side by side if the existing window is wide or
  117. # one above the other if the existing window is tall.
  118. map f4 launch --location=split
  119. # Rotate the current split, changing its split axis from vertical to
  120. # horizontal or vice versa
  121. map f7 layout_action rotate
  122. # Move the active window in the indicated direction
  123. map shift+up move_window up
  124. map shift+left move_window left
  125. map shift+right move_window right
  126. map shift+down move_window down
  127. # Move the active window to the indicated screen edge
  128. map ctrl+shift+up layout_action move_to_screen_edge top
  129. map ctrl+shift+left layout_action move_to_screen_edge left
  130. map ctrl+shift+right layout_action move_to_screen_edge right
  131. map ctrl+shift+down layout_action move_to_screen_edge bottom
  132. # Switch focus to the neighboring window in the indicated direction
  133. map ctrl+left neighboring_window left
  134. map ctrl+right neighboring_window right
  135. map ctrl+up neighboring_window up
  136. map ctrl+down neighboring_window down
  137. Windows can be resized using :ref:`window_resizing`. You can swap the windows
  138. in a split using the ``rotate`` action with an argument of ``180`` and rotate
  139. and swap with an argument of ``270``.
  140. This layout takes one option, ``split_axis`` that controls whether new windows
  141. are placed into vertical or horizontal splits when a :option:`--location
  142. <launch --location>` is not specified. A value of ``horizontal`` (same as
  143. ``--location=vsplit``) means when a new split is created the two windows will
  144. be placed side by side and a value of ``vertical`` (same as
  145. ``--location=hsplit``) means the two windows will be placed one on top of the
  146. other. A value of ``auto`` means the axis of the split is chosen automatically
  147. (same as ``--location=split``). By default::
  148. enabled_layouts splits:split_axis=horizontal
  149. ┌──────────────┬───────────────┐
  150. │ │ │
  151. │ │ │
  152. │ │ │
  153. │ ├───────┬───────┤
  154. │ │ │ │
  155. │ │ │ │
  156. │ │ │ │
  157. │ ├───────┴───────┤
  158. │ │ │
  159. │ │ │
  160. │ │ │
  161. └──────────────┴───────────────┘
  162. .. versionadded:: 0.17.0
  163. The Splits layout
  164. The Horizontal Layout
  165. ------------------------
  166. All windows are shown side by side. This layout has no options::
  167. enabled_layouts horizontal
  168. ┌─────────┬──────────┬─────────┐
  169. │ │ │ │
  170. │ │ │ │
  171. │ │ │ │
  172. │ │ │ │
  173. │ │ │ │
  174. │ │ │ │
  175. │ │ │ │
  176. │ │ │ │
  177. │ │ │ │
  178. └─────────┴──────────┴─────────┘
  179. The Vertical Layout
  180. -----------------------
  181. All windows are shown one below the other. This layout has no options::
  182. enabled_layouts vertical
  183. ┌──────────────────────────────┐
  184. │ │
  185. │ │
  186. │ │
  187. ├──────────────────────────────┤
  188. │ │
  189. │ │
  190. │ │
  191. ├──────────────────────────────┤
  192. │ │
  193. │ │
  194. │ │
  195. └──────────────────────────────┘
  196. .. _window_resizing:
  197. Resizing windows
  198. ------------------
  199. You can resize windows inside layouts. Press :sc:`start_resizing_window` (also
  200. :kbd:`⌘+r` on macOS) to enter resizing mode and follow the on-screen
  201. instructions. In a given window layout only some operations may be possible for
  202. a particular window. For example, in the *Tall* layout you can make the first
  203. window wider/narrower, but not taller/shorter. Note that what you are resizing
  204. is actually not a window, but a row/column in the layout, all windows in that
  205. row/column will be resized.
  206. You can also define shortcuts in :file:`kitty.conf` to make the active window
  207. wider, narrower, taller, or shorter by mapping to the :ac:`resize_window`
  208. action, for example::
  209. map ctrl+left resize_window narrower
  210. map ctrl+right resize_window wider
  211. map ctrl+up resize_window taller
  212. map ctrl+down resize_window shorter 3
  213. # reset all windows in the tab to default sizes
  214. map ctrl+home resize_window reset
  215. The :ac:`resize_window` action has a second optional argument to control
  216. the resizing increment (a positive integer that defaults to 1).
  217. Some layouts take options to control their behavior. For example, the *Fat*
  218. and *Tall* layouts accept the ``bias`` and ``full_size`` options to control
  219. how the available space is split up. To specify the option, in :opt:`kitty.conf
  220. <enabled_layouts>` use::
  221. enabled_layouts tall:bias=70;full_size=2
  222. This will have ``2`` instead of a single tall window, that occupy ``70%``
  223. instead of ``50%`` of available width. ``bias`` can be any number between ``10``
  224. and ``90``.
  225. Writing a new layout only requires about two hundred lines of code, so if there
  226. is some layout you want, take a look at one of the existing layouts in the
  227. `layout <https://github.com/kovidgoyal/kitty/tree/master/kitty/layout>`__
  228. package and submit a pull request!