My web service log file has a line that's 34151 characters wide (lots of Soap XML). When wrapped it fills more than 1 screen. How can I scroll it smoothly in vim? Using navigation keys like $ and w isn't quite working, is there another key that jumps say 1000 characters at a time?
1 Answer
Vim as a line based editor. It's movement commands and it's ranges are all based on lines. This partly due to it's origins from Vi designed to edit most text documents that span multiple lines.
In your case there are a few options:
Optimize for the editor. Since Vim is line based use a lint program to pretty print the XML (SOAP) document into multiple lines instead of one long line. This has the advantage of organizing the chaos and increase in performance and ultimately productivity.
Create some mappings to help with the limited column based movements. This solution has the disadvantage that all the commands are rendered pretty useless (any command starting with
:
is effectively the same as:%
with one line). But it does have the advantage of not having to reformat the document.
The first solution is easy using Vim's filter command :%!xmllint
(with the xmllint program installed).
The second option you could use the gj/gk commands (10
gj/10
gk also). Then there are the word and sentence movements like: w/W, b/B, e/E, and (/). And finally if you happen to know the column number you can use it with the | movement as in 1024
| to jump to the 1024th character of the line.
Lastly I can't forget about the find movements. As you know you can type a / to search for a pattern or use f/F and t/T keys to search by characters. For example you can type f> to jump to the next >
character then press ; and , keys to move to the next or previous >
character.
10gj
from SO to jump down 10 lines at a time. Perhaps there's an easier way?10gj
? Seems pretty easy to me. You can of course rebind this (see linked question) to make it slightly easier.