Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to bring the marker to middle of the screen?

Tags:

vim

In vim, when I go to a marker, is there a way to tell vim to scroll it to the middle automatically instead of me doing z. or zz again?

or is there an event from vim when I go to marker like vim buffer events?

Commands to run pre and post inbuilt commands seems like a powerful thing. So there might be a plugin to do this. Couldn't find a query for google for this.

like image 394
Adithya Sama Avatar asked Dec 19 '19 11:12

Adithya Sama


People also ask

How to scroll to the middle of the screen in JavaScript?

To scroll to the middle of the screen, we have to first identify the element upto which we want to scroll on the page. Then pass scrollIntoView and the web element as parameters to the executeScript method. JavaScript command scrollIntoView can have multiple optional parameters.

How to scroll to the middle of the screen with selenium?

We can scroll to the middle of the screen with Selenium webdriver using the JavaScript Executor. Selenium can execute JavaScript commands with the help of the executeScript method.

How do I get mid-positioned taskbar icons?

TaskDock is a free app, and you can use it to customize the taskbar. It does not have the bells and whistles that TaskbarX offers, but it gets the job done. Hopefully, one of these methods will help you get mid-positioned taskbar icons.


1 Answers

If this is just for moving to a marker with ' and friends (or just a few more select motions), you can override the original commands with custom mappings like this:

:nnoremap <expr> ' "'" . nr2char(getchar()) . 'zz'
:nnoremap <expr> ` "`" . nr2char(getchar()) . 'zz'

These basically turn (typed) 'a into (executed) 'azz; the complication here is that the ' command waits for the typed mark; the mapping does this via getchar() before assembling and returning the full command. The <expr> makes Vim execute the right-hand side as an expression and use the result, instead of directly executing it.


To keep the cursor in the middle of the window at all times, set the 'scrolloff' option to a high value (like 999) instead.


Speaking of events, there's CursorMoved that is triggered after each move; unfortunately, there's no indication which command caused the move.

like image 137
Ingo Karkat Avatar answered Oct 19 '22 21:10

Ingo Karkat