Skip to content

Commit

Permalink
basics: rename file buffer window tab & refactor content
Browse files Browse the repository at this point in the history
- rename file to match new title
- update mkdocs.yml navigation
- reorganise page sections
- enhance clarity of each section, remove duplication
  • Loading branch information
practicalli-johnny committed Oct 5, 2023
1 parent 3905344 commit c2baee4
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 52 deletions.
Original file line number Diff line number Diff line change
@@ -1,48 +1,84 @@
# Files Buffers Windows and Tabs

Buffers hold the contents of files and any other information from processes, e.g. the REPL evaluation log
[Files](#files) are text written to perminant storage, e.g. disk or usb drive and are names with an extension that represents the file type, e.g. `.clj` for clojure, `.md` for markdown, etc.

Windows are a container for a buffer and windows can swap which buffer they show. Multiple windows, also known as splits, can be present in a Neovim frame. By default, neovim starts with only one window.
A [Buffer](#buffers) hold the contents of a file or any other information from processes, e.g. the REPL evaluation log.

A tab can hold one or more windows and tabs can be shown on a tab-line. ++"g"++ ++"T"++ toggles between tabs, e.g. Clojure source code and Clojure Log
[Windows](#windows) are a view on a buffer and windows can swap which buffer they show. Multiple windows, also known as splits, can be present in a Neovim frame.

A [tab page](#tab-pages) (or tab) can hold one or more windows and multiple tab pages can be shown on a tab-line.

## File explorer

Visually manage files with a tree view of the current project, using [:fontawesome-brands-github: Neo-tree.nvim](https://github.com/nvim-neo-tree/neo-tree.nvim){target=_blank}
## Files

Use [Neo-tree.nvim](#using-neo-tree) to visually navigate and manage files using a tree view of the current project. Files and directories can be added, renamed, moved and deleted.

Use [Telescope](#telescope) to select files, typing a name narrows the file list.


### Using Neo-tree

=== "Astronvim"
++spc++ ++"e"++ toggles neo-tree file browser

++spc++ ++"o"++ toggles between buffer and neo-tree

Neotree icons

=== "Practicalli Neovim Config Redux"

++spc++ ++"f"++ ++"t"++ ++"t"++ to open file explorer

Within Neo-tree:

++"h"++ ++"j"++ ++"k"++ ++"l"++ to navigate the file tree hierachy

++less-than++ and ++greater-than++ to navigate between File, Bufs and Git sources tabs

++question-mark++ shows neotree help, listing key bindings

++"a"++ adds a file, prompting for a name relative to the directory where ++"a"++ was pressed. The name can include new directories to be created. A name ending with ++forward-slash++ will create a directory rather than a file.

++"d"++ deletes the current file or directory (including sub-directories), a conformation prompt is shown

++"r"++ to rename a file or directory (use move to change the path)

++"m"++ to move a file or directory, optionally renaming too

!!! INFO "Neotree icons"
- yellow dot - unsaved changes
- pencil - git added changes
- cross - git deleted changes
- Warning triangle - lsp diagnostics issues

++"h"++ ++"j"++ ++"k"++ ++"l"++ to navigate the file tree hierachy

`<` and `>` to navigate between File, Bufs and Git sources tabs
### Telescope

++question-mark++ shows neotree help, listing key bindings
Telescope provides a selector which will narrow the list of matches as a pattern is typed, providing a fast way to find an item in a list.

Telescope provides a preview of the selected file (only if there is sufficient space in the Neovim frame)

File lists are relative to the directory Neovim was opened from (or Path subsequently set in Neovim).

=== "AstroNvim"

`SPC f f` selector for files within the scope of the current directory path. `SPC f F` to also show hidden files from the current directory path.

`SPC f a` selector for AstroNvim user configuration files

`SPC f p` selector for previously opened files (oldfiles)

=== "Practicalli Neovim Config Redux"
`SPC f f` to list files within the scope of the current directory path.

`SPC f b` provides a file browser to open files, navigate the file space and create new files and directories

++spc++ ++"f"++ ++"t"++ ++"t"++ to open file explorer


## New File
### Save File

Files and directories are created in the path given, relative to the directory in which Neovim was opened.

> `:lcd` to set the current local directory
>
> `:!` for a shell command, e.g. `:!mkdir -p path/to/new/directory` create a new directory and any intermediate path
A file must exist for Neovim to write to it. Neo-tree and Telescope can be used to create files and directories, as can a terminal and the command line integration (++exclamation++)


=== "Astronvim"
Expand All @@ -52,16 +88,6 @@ Files and directories are created in the path given, relative to the directory i

`:write path/to/filename` will write the current buffer to a new file.

Use Neotree as a convienient way to create, rename, move and delete files and directories

++"a"++ to add a file using the given name, or directory if the name ends in a `/`

++"m"++ to move a file or directory

++"r"++ to rename a file or directory

++"d"++ to delete a file or directory, showing a confirmation prompt first


=== "Practicalli Neovim Config Redux"

Expand All @@ -74,6 +100,8 @@ Files and directories are created in the path given, relative to the directory i

=== "Neovim"

`:lcd` to set the current local directory

`:write path/to/filename` will write the current buffer to a new file

`:!mkdir path/to/directory` will create a new directory
Expand All @@ -88,29 +116,8 @@ Files and directories are created in the path given, relative to the directory i

`:h` for the current directory (the “head” of the path).

`!` is the NeoVim terminal shell command


## Select files and directories

Telescope provides a selector which will narrow the list of matches as a pattern is typed, providing a fast way to find an item in a list.

Telescope provides a preview of the selected file (only if there is sufficient space in the Neovim frame)

File lists are relative to the directory Neovim was opened from (or Path subsequently set in Neovim).

=== "AstroNvim"

`SPC f f` selector for files within the scope of the current directory path. `SPC f F` to also show hidden files from the current directory path.

`SPC f a` selector for AstroNvim user configuration files

`SPC f p` selector for previously opened files (oldfiles)
`!` is the NeoVim terminal shell command, e.g. `:!mkdir -p path/to/new/directory` creates a new directory and any intermediate path

=== "Practicalli Neovim Config Redux"
`SPC f f` to list files within the scope of the current directory path.

`SPC f b` provides a file browser to open files, navigate the file space and create new files and directories


### Swap file
Expand All @@ -137,7 +144,7 @@ Opening a file checks if there is an associated swap file and prompts the user
> `:edit` after the file is open also prompts if there is a swap file. Selecting (D)elete will delete the swap file without changing the current buffer

## Buffer management
## Buffers

=== "AstroNvim"

Expand Down Expand Up @@ -173,7 +180,7 @@ Opening a file checks if there is an associated swap file and prompts the user
nvim README.md deps.edn src/practicalli/playground.clj test/practicalli/playground.clj
```

## Buffer text wrapping
### Buffer text wrapping

The test in a buffer is not wrapped by default. Set and unset soft text wrapping in a buffer

Expand All @@ -193,7 +200,7 @@ The test in a buffer is not wrapped by default. Set and unset soft text wrapping
`:set nowrap` to show lines in full (scroll sideways to see lines longer than the window)


## Window management
## Windows

Windows can be active (contains the cursor), hidden (open but not shown) or inactive.

Expand Down Expand Up @@ -254,7 +261,7 @@ A Tab page holds one or more windows, each window is a view on a buffer, a buffe

A tab page can provide a logical grouping of windows, e.g. Clojure source code in one tab, tests in a second tab and REPL log in a third.

Neovim commands may be constrained within the bounds of a tab page (without using the :tab modifier)
Neovim window commands may be constrained within the bounds of a tab page (without using the :tab modifier)

Tab pages are often referred to as tabs.

Expand Down
2 changes: 1 addition & 1 deletion docs/neovim-basics/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ The fundamental controls of Neovim which apply across all editing tasks.

## Fundamentals

[:fontawesome-solid-book-open: Files, buffers and windows](files-buffers-windows.md){.md-button}
[:fontawesome-solid-book-open: File Buffer Window and Tab page](file-buffer-window-tab.md){.md-button}
[:fontawesome-solid-book-open: Multi-modal Editing](multi-modal-editing.md){.md-button}

## Editing Tools
Expand Down
2 changes: 1 addition & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ nav:
- Treesitter: configuration/practicalli/packages/nvim-treesitter.md
- Neovim Basics:
- neovim-basics/index.md
- File Buffer Window: neovim-basics/files-buffers-windows.md
- File Buffer Window Tab: neovim-basics/file-buffer-window-tab.md
- Multi-modal Editing: neovim-basics/multi-modal-editing.md
- Search Replace: neovim-basics/search-replace.md
- Comments: neovim-basics/comments.md
Expand Down

0 comments on commit c2baee4

Please sign in to comment.