Questions tagged [filesystem]
For questions regarding searching and navigating the filesystem.
89
questions
0
votes
1
answer
31
views
Saving Vim files to certain pathways
My question is regarding how to save files to certain folders, or locations
For example I want to save a file called c++ learning to a folder on my desktop called c++
So after typing :w what do I ...
1
vote
1
answer
203
views
Vim file explorer - jump to file by letter
In windows file explorer, if you hit a letter like R, you get to a file/folder beginning with R.
Especially in directories with many files this is super convenient.
Does one of the Vim file explorers ...
2
votes
0
answers
934
views
What is the file structure of Neovim?
It seems like Neovim has files in many places.
The binary is in /usr/bin/nvim.
Inside ~/.config/nvim is init.vim, for declaring plugins, and also directories in ~/.config for storing Neovim plugins, ...
0
votes
1
answer
54
views
mkview file code meaning
I use :mkview %.vimview to create a view file under current directory, and in the file created there is a line of code like this:
if bufexists(fnamemodify("~/PycharmProjects/rl/report/...
1
vote
3
answers
833
views
Netrw-R Renaming multiple Files with vim
After going through the renaming guides from the doc folder in vim I found a way to replace text with the input :%s/frompattern/topattern/g.
Reaching the renaming files with the file browser tutorial/...
1
vote
1
answer
98
views
How to expand <cfile> if it has an @ in the path?
I'm using arch linux and nvim. Everything is up to date.
I have a dir path /home/user/name@web_address.com/144_p/data-dir-2/data_structure_here
gf does not open the dir structure becasue @ is present.
...
-1
votes
1
answer
99
views
vimrc, like exec but replaces current process (fork?)
Such as in the following code:
let cpath = getcwd()
let cfile = expand('%')
function Run_file_hopper(cpath, cfile)
silent exec "! . ~/path/somescript.sh" a:cpath a:cfile ...
3
votes
0
answers
155
views
While copying a file in netrw, why should I be in the directory where the file is located?
In netrw, I want to copy a file /dir/subdir1/file.txt to /dir/subdir2. For that, I do the following:
I mark the file /dir/subdir1/file.txt
I navigate up directory and mark /dir/subdir2/ as target
...
7
votes
2
answers
859
views
Convert absolute path to one relative to another absolute one
Context
I’m working on an 'omnifunc' function for Markdown editing. It’s supposed to help me link to other Markdown files while I’m typing a link – based on file content though, not file name.
Suppose ...
0
votes
1
answer
63
views
Is there a way to prevent nvim from editing another file?
When I'm using nvim with firenvim, I use it to only edit the 1 text box in the browser. I typically have to need to open another file. Even with strict security policies, I'd like to disable nvim's ...
2
votes
3
answers
1k
views
How to `cd` / explore the directory containing the current file?
Sometimes I gf to a file in a totally different directory and want to check out that new directory. Is there a way to quickly exit vim and cd into the directory containing the current buffer?
1
vote
2
answers
161
views
Allowing file bookmarks
I work with vim netranger for file management. The version I use doesn't have a bookmark feature for files.
That means to be able to quickly navigate to a common files by a defined keyboard shortcut.
...
4
votes
0
answers
448
views
vimscript - copy a file from one path to another
How do I rewrite this line of code
call system("cp /tmp/foo.txt /tmp/bar.txt")
into a vim command which is more portable and OS-independent?
I've been looking around but checking for "...
2
votes
0
answers
54
views
Closing the file handle while keeping buffer open
I have a workflow where I edit a .org file using jceb/vim-orgmode which is located in my iCloud directory. I then have an app on my phone which also syncs and uses the same .org file. The problem is ...
0
votes
1
answer
2k
views
how to use variables in vimscript shell commands
I have this code intended to:
read current line
extract variable from end of line, looking for text like #ad04e482
search for filename that begins with the string ad04e482
open that file to edit in ...
1
vote
0
answers
537
views
Vim undofile does not work when file is too long
I use a vim persistent undo setup as follows, which have worked all that way here.
set undofile
set undodir=~/.vim/undodir
However now I'm facing a problem when the undofile became too long, notice ...
0
votes
1
answer
71
views
Put a tab autocompleted path into current buffer
I use autocompletion a lot, especially for long path names:
e.g.
$ /home/au/Doc<tab> <tab>uments/A<tab> <tab>\ file\ with\ a\ very\ long\ name
This can be performed within ...
0
votes
1
answer
31
views
How can I modify OpenMultipleTabs so that I can open buffers for new files?
When searching for a command to enable me to open multiple tabs in normal mode, I found a custom command to do this:
" Open multiple tabs at once
fun! OpenMultipleTabs(pattern_list)
for p in a:...
3
votes
0
answers
298
views
Netrw problem - 'mt' open new tab instead of marking as target folder
I was playing with netrw and was amazed by the possibility.
I'd like to mark some files with 'mf' and move it to a folder using 'mt'. However, when I press 't', vim seems to interprets it as "open a ...
2
votes
2
answers
3k
views
Creating and destroying temporary files by vim
I integrated luacheck in vim with the following simple function:
function! LuaCheck()
let errors=system("luacheck " . expand("%"))
cexpr errors
cwindow 5
endfunction
autocmd FileType lua ...
3
votes
3
answers
857
views
Easily add/open a file in the same folder as the current file/buffer
I feel my current VIM setup is pretty sweet, but there is one thing that annoys me time and time again: how can I open a file or add a file to the same directory as the current file I am editing?
If ...
4
votes
1
answer
9k
views
How to do :Sex but with a vertical split?
When viewing a file /tmp/vim_split_demo/test.txt, the parent directory can be opened in a horizontal split screen using the command :Sex, as shown in these screenshots:
What command gives same ...
1
vote
1
answer
255
views
How to show only a specific file format in ctrlp results?
I am fairly new to Vim. I keep my notes in .md files and would like to access them with CtrlP from several different directories. I would like to set a specific filter on them, because now loading all ...
4
votes
1
answer
3k
views
Find project root relative to the active buffer
I can use the finddir function to find a parent folder that contains a .git folder (project root), like this:
let dir = finddir('.git/..', ';')
However, this only finds project roots that are parent ...
2
votes
1
answer
391
views
How to find a executable file inside a folder?
I have the path of a folder in a variable, and for a custom debugging script I am making, i need to find an executable file inside that folder (the executable find is guaranteed to exist, but not to ...
1
vote
0
answers
26
views
Different versions of vimrc being read [duplicate]
I have an absurd problem. Honestly, I have a hard time figuring out whether this belongs here or a Windows forum.
Using Vim on Win10, I've changed my C:\Program Files (x86)\Vim\_vimrc from the awful ...
3
votes
1
answer
65
views
Ask if file extension is missing when opening new file
I use auto completion in my shell (zsh) and I'm often a bit sloppy.
Scenario:
Imagine I have the files sourcecode.c and sourcecode.h in the current directory.
I type vim sour<TAB><ENTER> ...
3
votes
0
answers
595
views
How to escape paths for findfile() and finddir()?
I have run into an escaping problem with the path argument to findfile({name}, {path}) / finddir({name}, {path}).
In my code path is a directory, obtained via fnamemodify(<file>, ':h').
Until ...
2
votes
0
answers
67
views
How long can a file be non-existent when I'm saving it in vim
When I'm using vim to edit files in a django application that is running in developer mode I sometimes encounter this crash coming from the auto-reload utility:
File "/home/zefciu/.virtualenvs/15five/...
1
vote
1
answer
269
views
Saving .swp/.un~ files to subdirectories
Is there any way to save these files to automatically created subdirs? Google gave me no answers.
The reason is simple- I work on several computers which I keep synced via git, so having these files ...
1
vote
1
answer
1k
views
How can I pass extra flags to FZF/ripgrep commands with the leader key?
Current functionality
When I use <C-P> and <C-Å> I can respectively search file names and contents. Everything works great.
Target functionality
When prepending either with <leader>, ...
5
votes
1
answer
2k
views
How to write a value or variable into a file using only vimscript?
This question is very basic, but somehow absurdly difficult to find an answer for, because everything you find explains how to save the buffer, and I'm not interested in making new buffers or saving ...
3
votes
2
answers
1k
views
How to setup vim for working in a very large directory?
I am trying to setup my development environment using vim and some plugins.
My workspace root is a directory with very large number of sub-directories and files. I am going to be working on files ...
1
vote
2
answers
99
views
How to print the filename with parent directory in insert mode?
I know that I can print whole path by Ctrlr = expand('%:p') in insert mode. I can also print head/tail with expand('%:h'), expand('%:t').
I want to print the filename with it's parent directory. ...
1
vote
2
answers
364
views
How to enable disabled movement keys in netrw?
Recently I started using and learning Vim. I turned off movement keys in my .vimrc file like this:
noremap <Up> <NOP>
noremap <Down> <NOP>
noremap <Left> <NOP>
...
3
votes
1
answer
8k
views
What is the correct way to escape UNC paths?
Let's say there is a file \\server-42\tmp\dir\test.txt. When my plugin tries to execute this command via system() it triggers an error:
cd "\\server-42\tmp\dir" && git ls-files --error-...
2
votes
0
answers
76
views
Alter how oldfiles are displayed
Is it possible to "preprocess" the oldfiles list so that it's easier to navigate visually?
As far as I can tell, the contents of the oldfiles list are presented as ordinary absolute paths, but with ...
3
votes
1
answer
624
views
How to refresh the oldfiles list without restarting vim?
:browse oldfiles<cr> is useful for quickly navigating to a file I've worked on recently.
Sometimes though, I want to suspend vim and do some grep or ack search and find a new file that I'm ...
2
votes
2
answers
210
views
Is there a quick way to open a file anywhere within a directory hierarchy?
I am working with a new old code base where virtually all the interesting source files are three levels deep in the directory hierarchy. It's about 1.3M lines of code in more than 2000 .cpp files. The ...
1
vote
1
answer
615
views
Checking if Makefile exists before executing autocmd
I want Vim to execute build the project automatically after I write the buffer to a *.c or *.cpp file. Here is what I've done:
autocmd BufWritePost *.c,*.cpp make
This one works as expected (but the ...
1
vote
0
answers
600
views
Opening recent files issue
TLDR: How can I open a file from the list of recent files without going to the end of the list to get to the prompt for file number?
In order to open recent files, I do :bro ol and then when I see ...
7
votes
4
answers
1k
views
What workflow to use when editing large multifile projects
Lately I've been shifting more nad more of my work from IntelliJ to vim. With a handful of plugins and setting tweaks, I don't miss the IDE much.
One thing I do miss is the ease of navigating a large ...
2
votes
1
answer
284
views
Multiple buffers of the same file
I ran into a problem when using the quickfix feature of vim. When I open up my source file in vim, a buffer of that file is created, and its name is shown on the status bar, let's say main.cpp.
Then ...
3
votes
1
answer
134
views
How do I open the last n files I was working on in vim?
I know that the :oldfiles command will show you a history of the files you last had open; but how do I open the last n files in one command...for instance, say I want to open files 0-n in the :...
3
votes
1
answer
310
views
gf: can I get next file that matches?
I use gf to open "filename.h" from line like:
#include "filename.h"
in some C\C++ file.
Sometimes there is more than one "filename.h" that gf command can find in path. But gf gets me to the first ...
2
votes
1
answer
633
views
Is it possible to clone a directory with netrw?
When I mark a directory with mf, then use mc to copy into the target directory, it copies the contents only rather than the directory itself. I know I could make a new directory with d, then copy the ...
14
votes
2
answers
887
views
Can I search through 'oldfiles' with a specific name or extension?
I use the oldfiles and browse oldfiles commands all the time. I find them extremely useful, because it's easier to hit my leader mapping, scan through the files really quickly, and hit
q<number>...
4
votes
1
answer
4k
views
Is there an elegant way to determine if a file exists in/under runtimepath?
I wonder if there is an elegant way to determine if a specific file exists in/under one of the entries of &rtp.
Currently, I use the following construct:
let s:found_ = 0
for s:dir_ in split(&...
2
votes
1
answer
287
views
Can I iterate through files with a certain extension from the vim command line?
Pretty frequently while I'm using vim, I'll run into something like this. I want to edit a specific .txt file, that is under ~/Documents/myProj, but I don't remember the name of the file. So I will do ...
3
votes
1
answer
1k
views
How can I get vim to include suffixes in <cfile>?
In part of a plugin I'm slowly building, I use <cfile> to get the file pointed by the word under the cursor and then do something if it points to a directory, or open the file pointed to ...