TransWikia.com

Cursor in middle of the screen at start and end of file

Vi and Vim Asked by Phantom on August 31, 2021

I’d like to keep the cursor at the middle of the screen wherever I am in the file, without scrolling. This mean to have blank space above the file when I’m at the start of the file, and have blank space under the file when I’m at the end of the file.

I now there is this answer who give a hack (only to have blank space after the file), but we have to remap all keys, which is not really convenient, and it does not work in insert or visual modes.

One Answer

I have part of a solution.

I am not sure for the top of the file, but for the bottom of the file, if you use CTRL_e to scroll down, you can scroll as far as having the last line of the file at the top of your screen. You can also use CTRL_y to scroll up, but at the top of the file it will not scroll higher.

These two commands allow to scroll the view without moving your cursor (unlike using k and j to scroll up or down when the cursor is at the top or bottom). It is similar to scrolling with the mouse.

And it works in visual mode, however not in insert mode.

If anyone has suggestions for the uncovered cases (top of the file and insert mode, if it is possible), a completion of this answer would be welcome.

Answered by padawin on August 31, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP