Word – How to find the line with the maximum number of columns/characters in Vim/gVim

gvimregexvimword count

I'm currently using gVim on Windows XP, and I have 2 follow-ups to my core question:

What is the best method of finding the line with the most characters?

My current method: I use the regex search :/^\(\p\)\{#number#,}$), and I keep increasing the integer #number# until I get just one match. In the case of my file, it is a line of only 81K characters – not 916,657 as I previously thought. I know this because when the cursor is on that line I press g + Ctrl+g and get the column count of 81K.

Followup 1) Is the question "What is the best method of finding the line with the most columns?" the same as #2 above?

Followup 2) What does the second number mean when I open a file and see the following line at the bottom of the screen:

enter image description here

I interpret this to mean that the file has 14,871 lines, and at least one row has 916,657 columns. I checked that the file does have 14,871 lines, but I have not been able to understand the purpose of the second (916K).

Best Answer

The second number is the total character count in the whole file. If you do:

$ wc -l -c filename

you should see the same two numbers (lines and total characters). In fact, you can do:

:!wc -l -c %

Here's a plugin called textfilter (download) that includes a function to find the longest line.

Or you can use this to find the length of the longest line:

:echo max(map(range(1, line('$')), "col([v:val, '$'])")) - 1

then you can use that number like this: