Vim: find text in a specific column

When searching for text in Vim (specifically gVim, but that doesn't matter), how do you determine which column to search? I am looking for values ​​in only one column.

+6
vim find
source share
3 answers

Even if I tend to use the same solution as caviar, you can also use \% c β†’ :h /\%c

EDIT: For those who don't find the documentation very explicit.

Say my buffer contains

 dog 1dog 12dog 123dog 1324dog 12345dog 132465dog 

Then :echo search('\%5cdog') will give me: 5 (line 5).

You can also set 'hlsearch' to β†’ :set hlsearch and see what text matches the buttons /\%5cdog , /\%<5cdog and \%>5cdog

+17
source share

If you are talking about character columns, you might get lucky with /^.\{33\}mytext/ , which will look for your file for "mytext", starting from column 34. Note that the number in the search is less than the desired column ( this matches 33 characters of anything at the beginning of the line, and then your text).

+4
source share

You can use some sort of visual selection and then :/(searchterm) to find what you are looking for. For example, CTRL + V allows you to select columns, and then do with all the selected :/(term) <enter> .

+2
source share

All Articles