Scrolling window without using Control key in Vim - windows

Is it possible to scroll window screen without using control + U or control + D, (or control + F,B,E etc). I am aware that I can use 'j' or 'k', but that is a line by line scroll. I am looking to scroll through a larger chunk of text without using control key. I find it little inconvenient to move from home row. (May be I am thinking too much.)
I am aware that I can use /search or nG to move to a particular line. But sometimes, it is helpful to scroll through the code, without a specific line.
I am using GVim (windows). Thank you.

<C-U> / <C-D> scroll by 'scroll' number of lines. You can emulate that via
:execute 'normal!' &scroll . 'j'
This is too long to type, so you need a mapping, but that probably again would involve a modifier key. For ad-hoc scrolling, just estimate the amount of lines and type 30j.
That said, modifier keys are important in Vim (even if less than in Emacs). Maybe you should consider remapping Ctrl, for example to Caps Lock?

As I wise friend once showed me, you can use L to move cursor to the
bottom of the current window frame. Similarly, you can use H to go to
the top, or M to go to the middle, and also you can then scroll to
center the frame on the cursor location with zz.
With that, you can scroll down with L zt, and up with H zb. Half
scroll with L zz, H zz.
Better yet, if you're using spacemacs, you can use SPC N f or SPC N b to scroll forward and back. Either of which will put you in transient
state, meaning after you enter SPC N f subsequent commands are without
the prefix: f, b, u, d, until you exit the state.

Related

How to switch between horizontal and vertical split in vimdiff on Mac?

I first do a vimdiff on two files, but they are vertically split, which makes it hard to read. I want to switch to horizontal split. I tried:
control + w then J or h, which doesn't effect at all
I also tried:
command + w, which asked 'Do you want to terminate processes in this tab?'
I got stuck here. What's wrong with me?
This is a regular diff, $ vim -d foo bar, with the foo window active:
Here is how it looks after pressing <C-w>J, that is Control+w then Shift+j:
Notice the active window is now at the bottom.
From the same starting point, here is how it looks after pressing <C-w>K, that is Control+w then Shift+k:
Notice the active window is now at the top.
See :help window-moving.
To split the screen horizontally:
a.) Hit CTRL + w
b.) and then s.
If you want to navigate between the screen:
a.) Hit CTRL + w
b.) and then w.
To exit out of one of the screen:
a.) Go into command mode (i.e. hit ESC)
b.) and quit as usual: :q.
To split the screen vertically, much like splitting horizontally:
a.) Start by hitting CTRL + w.
b.) but then hit v (instead of s).
Navigating between the split screens is the same (CTRL + w + w).

How to scroll horizontally in emacs?

I can't get emacs to scroll horizontally!
To replicate the problem:
Open the *scratch* buffer.
Write a long line.
Make the long line exceed the window width with M-xtoggle-truncate-lines. The left hand text (column 0) will now be off the left of the window.
Try M-xscroll-left or its shortcut C-x < to scroll left.
Type y to enable the disabled commands.
NOTHING HAPPENS!
I also tried C-a to go to the beginning of the line.
I also tried M-xtoggle-horizontal-scroll-bar but got the error message "Horizontal scroll bars aren't implemented yet".
There seems to be no way to scroll horizontally!
I need this because I have many wide CSV files to read.
I'm using the latest prelude on emacs 24.5 on Windows 10.
I filed an issue on the prelude project in case it is a genuine bug and could be fixed there.
You seem not to understand how horizontal scrolling works. It's not intuitive, that's why the command is disabled by default.
When I press C-x< at the end of the long line, the line disappears to the left. When I press C-x> there, nothing happens.
Pressing C-x< at the beginning of the long line, though, shows the second part of the long line.
Consider using visual-line-mode or even the csv-mode instead.
There is new a feature in Emacs 26. You can customize mwheel-tilt-scroll-p and use mouse to scroll.
M-x customize group RET mouse
Then set mwheel-tilt-scroll-p to t
No need to handroll it yourself. This is provided out of the box in emacs 27, and it probably was available for longer:
This feature is off by default; the variable mouse-wheel-tilt-scroll turns it on, if you customize it to a non-nil value.
(setq mouse-wheel-tilt-scroll t)
Sounds like xemacs have horizontal scroll in a 'natural' way.
As far as I can see it there is a [Options] button in the menubar, when clicking on it there is a [Frame Appearance] sub menu and there, there are 2 button []scrollbars, [] Truncate Lines
When these 2 buttons are checked in, long line are truncated and scrolling is smooth.
May be xemacs is non standard though.
I use it, I find it easy to cut/paste even rectangular areas, selection is faster and more precise to me that what I could achieve with keyboard meta-ctrl-shift stroke alone.
Cheers
Phi
I

IPython/Jupyter notebook shortcut not working on Mac

I had a hard time figuring the keyboard shortcut.
Is that true that I should press Ctrl-m together and press the other key such as d to delete one cell? I tried it but it did not work for me I also tried without - but it still does not work for me :(
I am using a Mac.
You have to first toggle the right cell state.
The newer version of IPython revamped the command structure, so that cells have two states: input mode, when the cell has a green outline, and command mode, when the cell has a grey outline.
When its green you can edit the content and run it. When its grey you can use the delete insert cell or copy commands.
Hitting Enter or Return activates the green state, while using Esc activates the grey state.
For example:
To delete a cell, use Esc to go in command mode, like the grey outlined cell below, and simply press the d key twice.
On my mac, I use fn key, instead of ctrl, to make shortcuts work in iPython notebook (in Safari). For example,
fn + d + d deletes a cell (d + d works too)
fn + x cuts a cell
fn + c copies a cell
fn + z undoes an action,
and so on. As already noted above, you must press Esc before applying any of these shortcuts; that is, you first hit Esc to make a cell "grey", then you press fn + x to cut a cell.
You first press Ctrl and m (don't press the minus key), that will put the interface in command mode. For deletion you then have to press d twice.

Is there something like ctrl + m + o for Xaml?

I often miss CTL + M + O, that collapses all properties and methods in the code editor, when working with Xaml.
I installed Xaml Regions and it is nice but I still miss CTL + M + O
I have played around with:
CTL + M + M
CTL + M + L
CTL + M + P
CTL + M + U
But none of them does what I want.
Is there an extension or even a built-in command that does what I want?
To clearify, I want all children of a resource file collapsed to one row for easier navigation like this:
I recently discovered you can use Ctrl+M, L even though it doesn't work directly. It just takes a little algorithm.
Press Ctrl+M, L.
If everything is expanded, press it again.
???
Profit.
Pressing Ctrl+M, L expands everything if anything is collapsed, otherwise it collapses everything. So when you first open a file, pressing it once should be sufficient. If you've been collapsing and expanding some regions, pressing it once to expand and once to collapse works fine.
This may be too off-topic, however using the VSVim add-on will emulate Vim, unifying a lot of keyboard shortcuts for editing files:
The command zc will close a fold (if the cursor is in an open fold), and zo will open a fold (if the cursor is in a closed fold). It's easier to just use za which will toggle the current fold (close it if it was open, or open it if it was closed).
The commands zc (close), zo (open), and za (toggle) operate on one level of folding, at the cursor. The commands zC, zO and zA are similar, but operate on all folding levels (for example, the cursor line may be in an open fold, which is inside another open fold; typing zC would close all folds at the cursor).
The command zr reduces folding by opening one more level of folds throughout the whole buffer (the cursor position is not relevant). Use zR to open all folds.
The command zm gives more folding by closing one more level of folds throughout the whole buffer. Use zM to close all folds.
Edit: Command sequence in this case would be zM then zo.

Vi Move Cursor by bytes

I have a file with only one single line of content inside, but this line is very very long.
When I open it up in Vi, it fills up the whole screen.
How could I move the cursor by number of words or bytes so I can see the content of the next 'page'.
If your goal is to navigate down a single wrapped line, you should consider using g before motions. For example:
gj: go down one line visually
g8j: go down 8 visual lines
You could also move to a specific index in the line with |, e.g. 10| to go to character 10 (one-indexed).
w will move you over words (delimiting with certain punctuation), while W will move you over whole words, not counting certain punctuation. Combine with number prefixes to "scan" around.
If you'd prefer not to see your text wrapped and filling the screen, you can call :set nowrap and move with standard motions (e.g. w and W for moving words). Moving the whole window, with zl, zh, zj, and zk are options too.
Pressing l takes you to the next character.
Pressing w takes you to the next word.
If you prefix those with a number, you can specify how many words or characters you want to move, e.g. 1000w.
Maybe for such a thing you shouldn't use vi (but I don't want to start a religious war here).

Resources