From 198e40fc01d42ffd9fd049647ce2df1369eb5d12 Mon Sep 17 00:00:00 2001 From: jbranchaud Date: Fri, 3 Feb 2023 13:57:11 -0600 Subject: [PATCH] Add Swap The Position Of Two Split Windows as a Vim TIL --- README.md | 3 ++- vim/swap-the-position-of-two-split-windows.md | 20 +++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 vim/swap-the-position-of-two-split-windows.md diff --git a/README.md b/README.md index 001c5e0..dec9a71 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ pairing with smart people at Hashrocket. For a steady stream of TILs, [sign up for my newsletter](https://crafty-builder-6996.ck.page/e169c61186). -_1282 TILs and counting..._ +_1283 TILs and counting..._ --- @@ -1451,6 +1451,7 @@ _1282 TILs and counting..._ - [Source Original vimrc When Using Neovim](vim/source-original-vimrc-when-using-neovim.md) - [Swap Occurrences Of Two Words](vim/swap-occurrences-of-two-words.md) - [Swapping Split Windows](vim/swapping-split-windows.md) +- [Swap The Position Of Two Split Windows](vim/swap-the-position-of-two-split-windows.md) - [Tabs To Spaces](vim/tabs-to-spaces.md) - [The Vim Info File](vim/the-vim-info-file.md) - [Toggle Absolute And Relative Paths In BufExplorer](vim/toggle-absolute-and-relative-paths-in-bufexplorer.md) diff --git a/vim/swap-the-position-of-two-split-windows.md b/vim/swap-the-position-of-two-split-windows.md new file mode 100644 index 0000000..54b2fbd --- /dev/null +++ b/vim/swap-the-position-of-two-split-windows.md @@ -0,0 +1,20 @@ +# Swap The Position Of Two Split Windows + +A Vim workflow that I often end up in is one where I have two windows split +either vertically or horizontally. I'm usually editing in one side of the split +and referencing something from the other side of the split. + +I typically like to have the split them I'm editing in on the top or to the +left. If the split that I want to edit from ends up in the bottom or to the +right, I can swap its position with the other window using one of Vim's window +commands. These are typically prefixed with `Ctrl-w`. + +Swapping the position of two windows is the same as rotating them, either to +the left or to the right. In that case, I can use either of these commands: + +``` +Ctrl-w Ctrl-r # rotates windows downwards/rightwards +Ctrl-w r # rotates windows upwards/leftwards +``` + +See `Ctrl-W_Ctrl-R` for more details.