From 9b5b1e775242a0816e632bfcd511db90a7943322 Mon Sep 17 00:00:00 2001 From: Nathan Steel Date: Thu, 12 Aug 2021 11:21:11 +0100 Subject: [PATCH] Add more to file management - Tabs, Buffers, Windows --- vim.md | 40 ++++++++++++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/vim.md b/vim.md index d01dc34..28121f0 100644 --- a/vim.md +++ b/vim.md @@ -159,29 +159,51 @@ This is the "change and replace" of vim. It makes use of regex. `.` - Repeats the last command. Eg. ci( will occur again -# Buffers Splits Multitasking +# Tabs, Buffers, Splits Multitasking Vim can open numerous files/buffers at the same time. -These can be in tab like buffers, or in a splitscreen view. +These can be in tabs, buffers, or in a splitscreen view. + +## Tabs + +Tabs are used like workspaces. To keep tasks associated, from there you have multiple buffers. + +`:tabedit ` - Open a file in a new tab +`:tabe new` - Open a blank tab +`gt` - Switch to next tab +`gT` - Switch to previous tab +`gt` - Switch to tab x + +`CTRL+W T` - Breakout current window/split into a new tab +`CTRL+w gf` - Open new tab to file under cursor ## Buffers +Buffers are used as file proxies. These are to keep the files accessable. + `:r` `:e filenam` `:bn` `:bp` `:bd` `:ls` - Shows the buffers +`:b1..9` - Switch to buffer number `Ctrl+6` - Switches between the buffers `#Ctrl+6` - Switches to the buffer number -## Splits +`bd` - Delete current buffer, fails if there are any changes +`bd!` - Delete current buffer, discarding changes + +## Splits/Windows -:split -:vs +Windows are used to compare files, or work on one file while referencing another. -Ctrl + ww -Ctrl + wr Switch the splits around +`:split ` - Horizontally split the window +`:vs` - Vertically split the window + +`Ctrl + ww` - Cycle between active splits +`Ctrl+W hjkl` - Cycle between active splits with vimkeys +`Ctrl + wr` - Switch the splits around # Setting variables in Vim @@ -191,5 +213,7 @@ Vim has extra features disabled by default, that can be very useful! `:syntax on` - Turns syntax highlighting on -These variables can be added into a file called ~/.vimrc to automatically run +`:set hidden` - Allows you to switch between buffers without writing. + +These variables can be added into a file called ~/.vimrc to automatically run every time vim opens.