I often use gVim and Vim to view data tables in which the top row is the header. Is there any way to display this top row while browsing through the rest of the table? Ditto columns for the case in which the first column is a row heading.
EDIT: I accepted a good answer (and there were others) for showing the top column.
The horizontal (first row) equivalent to the answer I accepted is
:vert split
ctrl+w 5 |
or
ctrl+w v
ctrl+w 10 |
It would be nice to be able to do both, but apparently that is not straightforward.
This will simply do Ctrl + e 10 times. You can change the number to the number of lines you want it to scroll at once. It's important to note that the mapping is of the noremap type. Otherwise VIm will enter an infinite loop once you press the combination.
If you want to select the entire line in a file, press V. Now when you press k or j to go up and down, vim will select the entire line above and below your cursor. Finally, you can select text in columns by pressing ctrl+v and moving up or down the block.
Buffers in vim are the in-memory text of files. Your window is a viewport on a buffer. You can switch between open buffers, this is similar to tabs in other editors. Vim does have a concept of tabs too, but they are slightly different, read more about tabs in the Windows section.
You could open the file in two windows (command line: vim -o file file
, or ctrl+w n :o file
) and then one is fixed and you can scroll in the other window.
If you want to see the first 5 rows press ctrl+w 5 _
.
If you're working with datatables alot, you might want to take a look at the csv plugin. it has the :HeaderToggle
command that does exactly what you want, and many more commands that you might find useful.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With