Questions tagged [find]
The find tag has no usage guidance.
43
questions
1
vote
1
answer
35
views
How to jump to location of completion from another file?
In Vim, oftens I happen to be using some completion that vim provides for me in the Ctrl n/Ctrl p menu. If the completion happens to be from some other file, I know that Vim knows where it comes from ...
0
votes
1
answer
77
views
Match/find and replace all series of tab characters with one tab
I have a tsv file that has the header separated by tabs but each row is separated by one or more tabs. The parser/viewer I'd like to use doesn't understand that the values are separated by a series of ...
2
votes
2
answers
252
views
Use *-like command in normal mode to execute a find/replace
Background
It's nice to be able to type * in normal mode and automatically have Vim search for the word under the cursor.
Question
Is there an analogous command for executing a find/replace?
E.g. the ...
1
vote
1
answer
113
views
Automate find and replace
When having selected something in visual mode where I want to perform a find-and-replace I always have to run :'<,'>s/foo/bar/g manually. Is there some way so that I can bind it to some key ...
2
votes
3
answers
558
views
Capitalize a match in search and replace
I am using the following regex to find the first letter of the last word on each line in a file:
%s/.* .\zs/
I want to now lower case this match on every line in a file. How do I do it?
For eg.
Before:...
0
votes
1
answer
111
views
how to make vim looks for and display only files with .c or .h extension when displaying results of :find command
How can I make vim :find only files with .c or .h extensions?
For example, I am interested in finding .c files starting with tsv so I would run :find tsv*. This gives too many results; how do I make ...
3
votes
1
answer
682
views
Fastest way to find last occurence of a character in line?
Say we have the following:
echo 'This is a test'.$test1.$test2.$test3.$test4.$test5.'and this is another test';
^
With the cursor being on the first dollar sign, and I want to ...
2
votes
1
answer
150
views
Check if vim is in a comment section
How can I check if the cursor is inside a comment section like this in C:
/*
* Comment section
*/
Or in python:
"""
Doc string
"""
# Comment line
My idea for C is, ...
0
votes
2
answers
316
views
vim command line option to quit buffer if empty?
I have a few shell scripts where I find files and open them in vim, with the filenames being stored in shell variables that are passed to vim. Since I don't want to start a vim session unless at least ...
0
votes
2
answers
380
views
Find the specific line with character in specific position
Finding the line with a specific character before the last character. Suppose, I have the following string
1. addar_ctrl1,1,2,0,0,1
2. addar_ctrl2,3,2,0,1,0
3. addar_ctrl3,4,8,0,0,0
4. addar_ctrl4,2,6,...
1
vote
1
answer
123
views
How to switch the order in which objects appear
I have a custom command in a TeX file which takes two inputs A and B, let's call it \operation{A}{B}.
I want to
find all of the instances of \operation where the first entry A starts with the string ...
1
vote
2
answers
457
views
Open the file from :find in a :tabnew
I have my fuzzy file finder in Vim and it does a pretty good job. But it always opens the file in the current tab. I want my :find to open the resulting file in a new tab.
I know I can :tabnew <...
1
vote
0
answers
806
views
:find cannot find file in 'path' which command-line can see
Suppose the directory tree looks like this:
rootdir
├── data
│ └── file.txt
└── data2
└── file2.txt
When Vim is launched at rootdir and configured with :set path=data*, it is unable to :find ...
12
votes
10
answers
1k
views
Simultaneous find and replace
Is there a way to perform a simultaneous find and replace?
e.g.: I want to replace all 1 for 0 and simultaneously all 0 to 1
[
[1, 1, 1, 1, 1, 0],
[1, 1, 1, 1, 0, 1],
[1, 1, 1, 0, 1, 1],
...
1
vote
2
answers
301
views
:find multiple file names
I apologise if this was asked before, but I couldn't find anything similar.
I am trying to write a simple command to jump to a test file, using the current file name. I have managed to achieve this ...
0
votes
1
answer
1k
views
I would like to find and count number of entries bigger than a certain number in front of a certain string
I would like to use vim to do the following operation in vim:
I would like to determine the number of entries with avg_deg greater then "'avg_deg': 5.50" from a simple .log file as well as the average ...
3
votes
2
answers
4k
views
Advance to next (multi)characters on a line
To advance to the next/previous character match on a line I can do:
f <char>
However, I find myself wanting to match against two characters on that line, for example, something like:
f ='
Is ...
3
votes
1
answer
268
views
What is the difference between :find and :edit
:find and :edit both edit files and appear to need the relative or absolute path provided if the file isn't in the current directory. What is the extra part that :find brings? What is 'path'?
Help ...
3
votes
0
answers
96
views
gf with search pattern instead of line number
vim file +80
will open file in vim, with cursor at line 80
vim file +/if/
will open file in vim, with cursor at first line containing if.
For vim file +80, inside vim, there is gF.
The question:
...
1
vote
1
answer
311
views
Replace Only First Occurence after Pattern
Suppose I have a file which contains:
TEMP=100
TEMP=100
and I want to change all of the string beyond 'TEMP=' to 200, so it would read:
TEMP=200
TEMP=200
I could use the command :%s/TEMP=\zs.*/200/...
6
votes
2
answers
4k
views
Replace after a specific pattern
Suppose I have a string as follows:
RESULT=100
How would I replace everything following 'RESULT=' so that the string reads:
RESULT=200
The closest I've gotten so far is to use:
:%s/\(RESULT=.*\)\@...
4
votes
1
answer
3k
views
Named capture groups in vim regex?
Does vim allow us to assign names to capture groups for search/replace that can be used in place of \1, \2 etc... for back-references and substitution?
Like in in Python:
>>> import re
>...
0
votes
2
answers
72
views
Find and replace only between searched patterns
Editing large HTML file. Would like to do something like:
:/<blockquote>/,/<\/blockquote>/s/^\(\s\s\+\)\(<[^>].\{-}>\)/\1 \2/g
So basically just trying to indent all between ...
4
votes
1
answer
244
views
Pipe native command to vsplit
I have opened vim in a directory of code which contains long_name_module.py. My path variable is path+=** so the python file is visible to find.
I type
:find lo<tab>
and the filename is ...
2
votes
1
answer
407
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 ...
8
votes
1
answer
30k
views
How to search for any repeating character, X number of times
Let's say a buffer has a certain characters I know will be repeated seven (7) times. How can I search for any character repeated seven times?
I know I can search for .., but those to characters won'...
1
vote
1
answer
663
views
Find and replace in XML file in vi
I have an .xml file which contains many times the following web beacon
<span lang="EN" class="multilang">ANY TEXT TOTO</span>
I would like to make a "Find&Replace": each web beacon ...
0
votes
1
answer
169
views
regex find and replace all with capture groups throws E488: Trailing characters
My text file looks like this
Lastname, Firstname
Doe, John
I'm trying to get it to end like this using find replace regex
Firstname Lastname
John Doe
This regex throws the error, although using ...
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>, ...
3
votes
2
answers
2k
views
How to do a find with a regex and jump to a specific position within the match
For example:
I have several lines starting with :q:, which I want to jump to:
:q: regex syntax
(...)
:q: regex examples
(...)
Now I want to jump to the start of regex syntax or regex example with a ...
0
votes
2
answers
784
views
How to make f{char} case insensitive?
Regarding this command:
f{char} To [count]'th occurrence of {char} to the right. The
cursor is placed on {char} |inclusive|.
{char} ...
2
votes
2
answers
87
views
How to change f{char} to search left if no char was found searching right?
Regarding this command:
f{char} To [count]'th occurrence of {char} to the right. The
cursor is placed on {char} |inclusive|.
{char} ...
0
votes
1
answer
6k
views
E488: Trailing characters error in VI with find and replace command
I am trying a simple find and replace function in VI Editor to change a profile path but the / is getting in my way and I need a simple and clever solution.
I tried using:
%s/profile: "/fldr0/local/...
3
votes
1
answer
1k
views
Fuzzy find within buffer
Can I change / command to execute a fuzzy search instead of a regex based one?
It would be useful to still be able to access the classic / functionality at certain times.
1
vote
2
answers
4k
views
Find and replace string with slash in it and retain the slash in the new string
I am having a tough time finding and replacing a string using vi.
Source String:
&DB2_PORT;/&DB2_DATA;
New String after replace:
&DB2_PORT;/&DB2_DATA;:tcp=true
I can find &...
3
votes
1
answer
56
views
How to check if a pattern is contained in a register's content?
I'm writing a new plugin and as part of a function, I need to check that a register contains a particular pattern.
I checked the official documentation but couldn't manage to use any of the search() ...
1
vote
2
answers
527
views
User command with modified 'path' completion?
I'm trying to write a wrapper command around :edit or :find specifically to open either my vimrc or a subpath of ~/.vim/ (e.g. ~.vim/autoloads/foo.vim).
If I run the command with no arguments, it ...
2
votes
1
answer
283
views
Exclude some paths from :find path
I'm working on a large scale project with a lot of files, and :find is extremely (several seconds) slow, much slower than :lgrep backed by ag, which skips directories mentioned in .gitignore, e.g. tmp,...
1
vote
0
answers
123
views
Why is filetype not set after :find from autocmd?
Objective
I want vi file to act like :find file if file doesn't exist.
That is, I want to be able to edit a file by name, without giving a path to the file, from the command line:
mkdir -p a/b/c
...
3
votes
1
answer
319
views
How to jump to a next or previous specific character ignoring linebreaks and not destroying highlight or overwriting my registry?
I have not found much use for ()[]{}, and so I want to map them so it does a find command, jumping to the previous instance of that particular character.
Thus, ) will jump forward to the next ), ...
3
votes
3
answers
117
views
How to "find" or "till" a bigram?
I have to do a lot of hopping in lines.
Often times I want to hop to a t in a line, and promptly press ft, only to discover that I have to do it 7 times before I can actually make it to my ...
5
votes
2
answers
315
views
Keystroke to move cursor to the last character of a highlight?
In Visual Mode, you can do this using the o keystroke.
However with search highlighting, ie ? or / -- I have a whole selection, but I want to move specifically to the last character of the highlight....
16
votes
1
answer
5k
views
Ignore folders when performing :find command
I'm using the :find command as my "fuzzy file searcher" in Vim. My setup:
set path=,,**
nnoremap <leader>f :find *
However, I'm having trouble ignoring folders. Huge folders that contain ...