From dfba17a9a8b97281136dc4307b74601034340455 Mon Sep 17 00:00:00 2001 From: John Practicalli <250870+practicalli-john@users.noreply.github.com> Date: Sun, 26 Nov 2023 13:41:12 +0000 Subject: [PATCH] basics: navigation page Navigating lines and buffers effectively --- docs/neovim-basics/navigation.md | 113 +++++++++++++++++++++++++++++++ mkdocs.yml | 1 + 2 files changed, 114 insertions(+) create mode 100644 docs/neovim-basics/navigation.md diff --git a/docs/neovim-basics/navigation.md b/docs/neovim-basics/navigation.md new file mode 100644 index 00000000..30ff6e48 --- /dev/null +++ b/docs/neovim-basics/navigation.md @@ -0,0 +1,113 @@ +# Navigation + +Move the cursor one space at a time + +- ++"h"++ move left +- ++"j"++ move down +- ++"k"++ move up +- ++"l"++ move right + + +## Jump along line + +Move to specific points within a line + +- ++"w"++ jump to start of next word +- ++"b"++ jump to start of word +- ++"e"++ jump to end of next word +- ++"$"++ jumps to end of line +- ++"0"++ jumps to start of line +- ++"^"++ jumps to first character of line + +!!! HINT "Uppercase w b e consider word delimited by blank characters" + Jump joined-word using ++"W"++ ++"B"++ ++"E"++ + +Use w b e movement with a number to move the cursor larger distances + +```vim title="jump 3 words forward" +3w +``` + +++"f"++ jumps forward in the current line to the given character + +```vim title="jump to next q character" +fq +``` + +++"F"++ jumps backward in the current line to the given character + +```vim title="jump to previous [ character" +F[ +``` + +++"t"++ jumps forward in the current line to before the given character + +```vim title="jump before q character" +tq +``` + +++"T"++ jumps backward in the current line to after the given character + +```vim title="jump after [ character" +T[ +``` + + +## Jump around buffer + +- ++"H"++ jump to top of window +- ++"M"++ jump to middle of window +- ++"L"++ jump to bottom of window +- ++"{"++ jump to previous paragraph +- ++"}"++ jump to next paragraph +- ++"gg"++ jump to first character of line +- ++"G"++ jump to first character of line + +Use cursor movement with a number to move the cursor larger distances + +```vim title="jump down 12 lines" +12j +``` + +??? HINT "Relative line numbers for line navigation" + Enable relative line numbers to show how far away from the current line each other line is. + + ```vim + set relativenumber + set number + ``` + + [Practicalli AstroNvim-Config](/neovim/configuration/astronvim/) enables relative line numbers + + +Jump to a specific line using the number as a command + +```vim title="jump to line number" +:127 +``` + +## Jumplist + +`:jumps` shows the Neovim jumplist containing all points from any buffer recently jumped to using neovim commands + +- ++ctrl++ ++"o"++ jump back +- ++ctrl++ ++"i"++ jump forward + +## Changes + +`:changes` shows the Neovim changelist containing all points in the current buffer which have changed + +- ++"g"++ ++semi-colon++ jump back (previous edit) +- ++"g"++ ++full-stop++ jump forward + + +## Search in buffer + +++forward-slash++ searches buffer for the following pattern + +- ++"n"++ jumps to next match +- ++"N"++ jumps to previous match + +> AstroNvim user config enables `incsearch` incremental search and `hlsearch` to highlight every search match + + diff --git a/mkdocs.yml b/mkdocs.yml index e8dd426e..2b46ed7f 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -157,6 +157,7 @@ nav: - File Buffer Window Tab: neovim-basics/file-buffer-window-tab.md - Notifications: neovim-basics/notifications.md - Multi-modal Editing: neovim-basics/multi-modal-editing.md + - Navigation: neovim-basics/navigation.md - Search Replace: - neovim-basics/search-replace/index.md - Substitute: neovim-basics/search-replace/substitute.md