3 ms·
Probably my most useful (neo)vim productivity tip is: vim.keymap.set('n', '\\.', ':tabedit %:p:h<CR>') My leader is \, so when I press \. it will open net
by commandersaki 2y ago
Probably my most useful (neo)vim productivity tip is:
vim.keymap.set('n', '\\.', ':tabedit %:p:h<CR>')
My leader is \, so when I press \. it will open netrw in a new tab in the directory containing the file whose buffer I was just editing. I use this all the time when I need to navigate source trees as I don't care much for fuzzy file finders. Credit to -romainl- who taught me about %:p:h.
- kzrdude 2y agoI've got a lot of shortcuts set up for telescope (fuzzy finder ui in neovim). One of them is leader fa for "find around" which limits the file list to current directory and the next level down (only). It's quite useful in the same scenario. The regular fuzzy finder is unfortunately useless in the home directory (too many files), with this limit, it's useful.
- haidousm 2y agooh that's great -- i think i got it working with the following config: local builtin = require("telescope.builtin") local utils = require("telescope.utils") vim.keymap.set("n", "<leader>fa", function() builtin.find_files({ cwd = utils.buffer_dir() }) end, { desc = "[F]ind [A]round currently open buffer" })
- kzrdude 2y agoThis is what I do to include the depth restriction require("telescope.builtin").find_files({ cwd = buffer_directory(), prompt_title = "Find Around", find_command = vim.list_extend(vim.list_slice(default_find_command), {"-d2"}), })
- JoshTriplett 2y agoThis is really handy, thank you! There's a shorthand :Texplore which does the same thing as your :tabedit invocation. Also, if you change it to ':Texplore */%:t' , it'll open the directory of the current file and put the cursor on the current file. I've added this to my .vimrc: noremap <C-b> <Cmd>Explore */%:t<CR> This binds Ctrl-b to browse in the directory of the current file.
- commandersaki 2y agoI just got around to trying :Texplore -- had no idea this existed, cool find. Tossing up the idea whether to switch to Texplore, but you know if it aint broke... Edit: Switched to :Texplore and also have \v bound to :Vexplore -- very handy.
- pawelduda 2y agoI have the same, except via ranger.vim, which integrates it with said program - it's an excellent pairing
- Zizizizz 2y agoI imagine you aren't going to install a plugin for this but oil.nvim is really great for this as you can also use it to edit your directory listing like a buffer to easily create/rename and delete files and directories. https://github.com/stevearc/oil.nvim https://github.com/stevearc/oil.nvim
- petepete 2y agoI've used oil/vinegar for a decade or more, I'd be entirely lost without -