Fork me on GitHub

Basic (neo)vim question about creating files / directories I have a several files open from a clojure project and I want to create a new namespace in a directory and file that doesn’t yet exist. I can browse files and buffers in the projeect after installing & configuring telescope (very nice) It seems I can create a file with :edit so long as I type in the correct path right, or check the current path with :pwd and change with :cd or :lcd or ;tcd so I can use a relative path. I can use :!mkdir to create a directory that doesnt exist, again ensuring I type in the right path (autocomplete is giving me the existing directories on the path if I get the starting point right) Is there an easier way to create files and directories from (neo)vim? Or is this just the way… Perhaps there is some telescope like package for this? Thank you.


Couple of handy tricks for this: • :e %<tab> will expand the current file path in your command, making it easy to edit • :e src/**/some-dir/<tab> will expand the glob and will show you all matching entries, so you can select and edit from there I think you need to set these for that:

set wildmenu                  " Menu completion in command mode on <Tab>
set wildmode=full             " <Tab> cycles between all matching choices.
I usually just use :e, and if the directory doesn't exist, use for its :Mkdir command. You could also use something like

👍 1
🤯 1

to create sibling file or directory I use :Explore from netrw build in plugin. It opens a buffer with files of current folder. Then % creates new file in the folder of the buffer or d to create new directory. Also use to make netwr more usable, the plugin adds - binding to all buffers that just calls :Explore

👍 1

To create a test namespace for source namespace I use it has a binding to navigate to test file from source and can create one if it does not exits, it creates all missing folders.

👍 1

projectionist is great


I use it to swap between main and test namespaces all the time

👍 1

:!mkdir -p %:h

👍 1

That will create the directory to the current file


what experience would be ideal for you? I usually create new directories with /kyazdani42/nvim-tree.lua

👍 1

Ideally I’d like to be able to create files and directories from telescope, or something like it. I could do something similar in that other editor I used 🤫 :Explore sounds easier and perfectionist sounds very useful too, thanks. The challenge I had with using command line style was either typing / autocompleting through 7-8 levels of directories each time. To reduce that I realise I should open nvim in the root of the project. I also found it hard to track of :lcd and :cd changes, which then affected what I could see in telescope 😞 It seems an awful lot to remember on top of everything else I’m trying to remember :rolling_on_the_floor_laughing:

practicalli-johnny15:06:38 looks very nice, I will try it instead of Nerdtree


> The challenge I had with using command line style was either typing / autocompleting through 7-8 levels of directories each time. The src/**/something<tab> glob expansion will match the pattern down to any number of subdirectories and the wildmenu will give you a list of the options.

👍 1

I could seem to do create files or directory with Nerdtree, maybe I wasn't doing something correctly...


@U05254DQM %:h is what you're after if it's the completion that's bothering you


Yes, using the head is quite useful. It's wasn't so much completion. It was having to keep track of the path, which is not something new to me. Maybe path something I can add on the status line (another Todo item). I can see changing the path can be useful, but I just made a mess of it, so wanted to avoid that (I have quite a few things to get used to already 😁) In that other editor, I would open a file (using completion relative to the current file) and any missing paths would be created. I think I mostly ran out of brain power...


both nerdtree and nvim-tree allow to create directories/files if you wanted to do it via telescope it seems that this plugin helps:

👍 1

It sounds like you want this @U05254DQM. It's a telescope extension. Though I typically use CHADtree (which unfortunately as a python dependency) as I find it easier to navigate when I need to create a file in a sibling directory.


Also you can find telescooe extensions for most needs here:

❤️ 1

I could spend all week going through all these telescope extensions. Lots of useful looking ones, thank you.

Abhinav03:07:34 is a file explorer and it makes creating new files or directories very easy. you go to the folder you want to create a new file in. press ma and type the new file name. It is super convenient


I've decided to use telescope file browser for the majority of the file management. I find it very fast and convenient to use. Telescope has lots of great extensions that help provide a consistent experience For a visual file system explorer I'm using which as it's Lua fits into my configuration more consistently than nerdtree Thanks everyone, I have a much more complete configuration now for


I have never tried telescope, I’ll definitely look into that. I like your config, and had a suggestion, for the git plugin. I use and it has a nice neovim and it makes a lot of complex git commands simpler. Have a look if you have time


I’ve been using neogit, which has a Emacs magit feel I am accustom too. However, Lazygit does seem to have a nice telescope style interface, so could fit better. Which ever lets me stage individually highlighted lines in a hunk will probably be the overall winner for my needs.


Fugitive let's you do all sorts of things with hunks 🙂 But no Telescope-like interface.