practicalli / neovim

Neovim, Conjure and LSP for Clojure development using Fennel configuration
https://practical.li/neovim/
Creative Commons Attribution Share Alike 4.0 International
20 stars 4 forks source link

[neovim] create a new file in a directory that does not exist #11

Closed practicalli-johnny closed 8 months ago

practicalli-johnny commented 2 years ago

Neo-tree

a to add a file relative to the the currently highlighted directory in neo-tree

A to create a directory with respect to the currently highlighted directory in neo-tree

practicalli/Astronvim-config

SPC W to write the current buffer to a file, prompting for a file name (and optionally a path

Edit a file

:edit or :e and a path/filename will open a buffer with a given file. If the file does not exist, then an empty buffer will open.

:write or :w to write changes to the file, creating the file first if it did not already exist.

TAB will help traverse the directory path from the current path :lcd, showing directory completions.

The write will fail if the full directory path does not exist

Creating a new directory

Use the mkdir shell command to create a new directory, which is created relative to the current path, which can be checked with :lcd

:!mkdir full/path/to/new/directory

If a file is already opened, i.e. with :edit, there is some short-hand syntax to simplify the typing

:!mkdir -p %:h

mkdir -p - the UNIX command to create a folder, the -p option creating any parts of the path required to make the full path

% - name of the current file

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

! - the NeoVim terminal shell command

Telescope

SPC f b opens telescope file_browser, use arrow and RTN keys to navigate to the desired directory in which to create a file (or parent of the directory to be created as a child)

ESC to switch from insert to normal mode

C adds current path to the command line, adding a file name or directory path (or both) creates them

RTN to select the newly created file that now shows in the file browser view