Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [filesystem]

questions regarding searching and navigating the filesystem

0
votes
0answers
18 views

Open new buffer in a separate window's buffer using :Explore?

I'm recording a macro attempting to re-create nerdtree by: From within the original open buffer, create and switch to a new window using :vsplit Use :Explore to open vim's file explorer, and select a ...
3
votes
1answer
25 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> ...
2
votes
0answers
44 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
0answers
44 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
1answer
40 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
votes
1answer
181 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&...
1
vote
1answer
183 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 ...
2
votes
2answers
109 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 ...
0
votes
2answers
33 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
2answers
74 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> ...
2
votes
1answer
206 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
0answers
61 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 ...
0
votes
0answers
106 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
2answers
73 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
1answer
146 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
0answers
204 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 ...
6
votes
4answers
268 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
1answer
93 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 ...
4
votes
1answer
86 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 :...
4
votes
1answer
87 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 ...
1
vote
1answer
153 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 ...
7
votes
1answer
291 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
1answer
1k 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
1answer
76 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
1answer
274 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 ...
1
vote
1answer
33 views

Reading external file data at the end of the buffer

If I am in the middle of the buffer and want to append external file data to the current buffer. So far I move to end of the file with G and reading the data :r file so it is doing the work ...... Is ...
1
vote
2answers
324 views

A side pane file explorer that can list files by modification dates?

I am looking for a way to be able to open a side pane listing the files in the current directories where the listing is sorted by modification dates. I want to be able to open the files from the ...
0
votes
0answers
46 views

View reletant CSS inline like Brackets

There's a really cool feature in Brackets I wish I had in vim: https://www.youtube.com/watch?v=Nhvj1NYC3Uc It allows you to pull up (inline in your text editor) the CSS that relates to a particular ...
5
votes
3answers
328 views

Is it possible to open a new file that starts with '+'?

I cannot figure out how to open a file that starts with +, e.g. +models/File.m. This is a naming convention for packages in Matlab. I've tried escaping \+models/File.m. This doesn't work because the ...
3
votes
1answer
189 views

How can I securely restrict vim access to a single file?

So first, I realize that this question is slightly out of the ordinary for this site. I will explain the backstory to avoid the XY problem. Over on Programming Puzzles and Code Golf, lots of users (...
8
votes
3answers
166 views

How to pass current file name with a different path to the command line

Is there any way to make the special symbol % work with path names on the command line? For instance, I'd like to do: :diffsplit Path\to\other\directory\% So that I can do a @: to quickly compare ...
4
votes
2answers
80 views

Creating a list of files contained in a buffer

Let's say I have the following buffer: foo.txt bar buzz.txt fizz/foo.txt fizz/fuzz/fozz.txt Representing an arborescence that I need to create. How can I easily create it from Vim? I.e. How can I ...
1
vote
1answer
149 views

explore, netrw: How to navigate to a file / folder starting with “abc”

Is there any way to jump to a file / folder starting with a given set of characters?
2
votes
2answers
245 views

Copying absolute filepath of selected file in Netrw

Is it possible to copy the absolute filepath of the file under the cursor in Netrw?
1
vote
0answers
538 views

Open files with “whitespace names” from within Vim with gx

I have a file, e.g. ~/abc def.mp3 that I want to open from within a Vim buffer that already contains these lines. If there were no whitespaces in the filename, I could simply open the file with the ...
0
votes
2answers
94 views

When editing a ruby file with includes/requires how can I open the file containing the method I am on?

I have a bunch of includes at the top of my file. Then I use methods from the helpers throughout my file. How can I have it so that when my cursor is on a method name my editor can (by some ...
3
votes
1answer
137 views

Choose file with browser to :read into buffer

I want to :r[ead] a file into current buffer, and the file should be picked with the browser (that opens automatically e.g. when trying to :e[dit] a directory. :e ~/.vim/ opens a file browser in the ~...
8
votes
1answer
135 views

How do I open a file using `gf` in case-insensitive manner?

I want to open Test.txt file when I put the cursor on the word test.txt and type gf. Is it possible?
10
votes
3answers
5k views

How do I copy a file in netrw?

The current working directory is ./A/B/. An empty document is opened when I type vim, and the netrw is opened with command :e. The window is split by vs., and I can navigate to the upper level ...
3
votes
1answer
73 views

How do I copy the directory structure into the text of a file?

This might be more of a bash question than vim, but I thought I should start here. Frequently when editing code, it would be "nice" to copy and paste the directory structure into a text editor. For ...
5
votes
1answer
745 views

How to insert a file path with tab- or autocompletion relative to the current file's dir?

I am in vim in the .gitignore file. I now want to add a file path that already exists on the current dir, e.g. ./app/poit/narf/auth.json I don't want to type it though, I want to navigate to that ...
5
votes
3answers
476 views

How do I open file under cursor, when the filename has a trailing dot?

There is a file with name ./folderA/folderB/file.. And there is text: ./folderA/folderB/file.:abcdefg When I move the cursor on letter B and type <c-w>f, it says E447: Can't find file "./...
2
votes
1answer
168 views

Make findfile() always return full path

While I was answering another question, I noticed an odd behaviour in the functions finddir() and findfile(). According to the help page, both of these functions will return the full path to the ...
31
votes
2answers
15k views

What are the differences between :wq<cr> :x<cr> and ZZ when exiting vim?

Vi and Vim, as all of you know, have many synonyms. There are three ways I know of to save the file and exit Vim and Vi. These are :wq <cr>, :x <cr> and ZZ. I have heard that these are ...
6
votes
3answers
2k views

Read file from vimscript variable

I can run this snippit of code within a vimscript block: 0read /home/user/.vim/bundle/vim-lorum/lorums/lorum.js As expected, it puts the contents of "lorum.js" into the current buffer But, I need ...
7
votes
1answer
353 views

Open a file at the given line using the colon notation

I'm often using grep to search for patterns and then opening the file with vim. For example I've the following result in my shell: interactions/BlockInteraction.js:38: .concat(...
15
votes
1answer
543 views

Filename Completion for Remote Files

My friend showed me a cool trick on Emacs some days ago where he could just open a file on a remote server and I instantly thought "there should be a way to do that in vim too" and it was true. I ...
-4
votes
4answers
1k views

How to change the directory to save a file

Currently all I have to do is type vim file_name and it will make that file in the current directory (usually user because that is where the command line start at if you don't use the cd command). It ...
5
votes
2answers
751 views

Gvim how to open several files in different buffers from MS Windows explorer

On MS Windows using gVim, is it possible to select several files from the explorer and open them in the same instance of gVim in different buffers? At the moment if I select 3 different files on ...
4
votes
1answer
91 views

How do I get filename completion to ignore a leading `=`?

Occasionally, when writing shell scripts and such, I have entries of the form: foo=/bar/baz To get filename completion (<C-x> <C-f>) to work, I have to put a space after the =, and then ...