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

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).

Related

Scrolling window without using Control key in Vim

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.

VS 2013 - Can't get rid off some formatting option

How can I can rid off those formatting option that draws dots every line?
CTRL + R, CTRL + W
Is the shortcut command to enable and disable "View White Space". Input them one after the other.

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.

Mac OS X Terminal: Map option+delete to "backward delete word"

Tried to map it from Preferences -> Settings -> Keyboard, but the "key" combo box has only "forward delete" but no "delete". My keyboard on the other hand has only "delete" and no "forward delete"!
Is there some other way to do it except from the preferences?
Enable option key as meta key
Go to Terminal > Preferences > Profiles > Keyboard
Check Use option key as meta key.
Image
On macOS High Sierra 10.13.6, captured on October 23, 2018.
Notes
Many applications (including bash and tcsh) treat Meta-Delete as "backward delete word."
OS X's terminal runs bash, which includes readline support. Follow Glomek's advice and tell terminal to use option as meta key (or else use Esc) and then you've got a bunch of handy options: Ctrl+w deletes prev word (as does Meta+delete as mentioned), but you can also use Meta+f and Meta+b to walk forward and backwards thru words, Ctrl+a and Ctrl+e to beginning and end of line, Ctrl+k delete (kill) from cursor to end of line, and a bunch more.
See http://www.bigsmoke.us/readline/shortcuts for a nice little reference table.
Delete a word going back:
Ctr-w.
Command Editing Shortcuts
Ctrl + a – go to the start of the command line
Ctrl + e – go to the end of the command line
Ctrl + k – delete from cursor to the end of the command line
Ctrl + u – delete from cursor to the start of the command line
Ctrl + w – delete from cursor to start of word (i.e. delete backwards one word)
Ctrl + y – paste word or text that was cut using one of the deletion shortcuts (such as the one above) after the cursor
Ctrl + xx – move between start of command line and current cursor position (and back again)
Alt + b – move backward one word (or go to start of word the cursor is currently on)
Alt + f – move forward one word (or go to end of word the cursor is currently on)
Alt + d – delete to end of word starting at cursor (whole word if cursor is at the beginning of word)
Alt + c – capitalize to end of word starting at cursor (whole word if cursor is at the beginning of word)
Alt + u – make uppercase from cursor to end of word
Alt + l – make lowercase from cursor to end of word
Alt + t – swap current word with previous
Ctrl + f – move forward one character
Ctrl + b – move backward one character
Ctrl + d – delete character under the cursor
Ctrl + h – delete character before the cursor
Ctrl + t – swap character under cursor with the previous one
Command Recall Shortcuts
Ctrl + r – search the history backwards
Ctrl + g – escape from history searching mode
Ctrl + p – previous command in history (i.e. walk back through the command history)
Ctrl + n – next command in history (i.e. walk forward through the command history)
Alt + . – use the last word of the previous command
Command Control Shortcuts
Ctrl + l – clear the screen
Ctrl + s – stops the output to the screen (for long running verbose command)
Ctrl + q – allow output to the screen (if previously stopped using command above)
Ctrl + c – terminate the command
Ctrl + z – suspend/stop the command
Bash Bang (!) Commands
Bash also has some handy features that use the ! (bang) to allow you to do some funky stuff with bash commands.
!! – run last command
!blah – run the most recent command that starts with ‘blah’ (e.g. !ls)
!blah:p – print out the command that !blah would run (also adds it as the latest
command in the command history)
!$ – the last word of the previous command (same as Alt + .)
!$:p – print out the word that !$ would substitute
!* – the previous command except for the last word (e.g. if you type _find somefile.txt /, then !* would give you _find somefile.txt)
!*:p – print out what !* would substitute
⌃W (control+W) is not the same thing than meta + delete (ESC+delete if you don't have checked use option as meta key)
meta+delete will treat / _ as word delimiter where ^W will consider space as delimiter.
e.g.
using ESC+Bakcspace on (cursor at the end)
rm /dira/dirb/file1
gives
rm /dira/dirb/
while ^W on the same will give
rm
So it is better to use \033\177 rather than ^W when defining the modifying the terminal profile.
That way you are really mapping ⌥⌫ to what esc⌫ is doing and you keep having ^W to erase word based on space delimiter.
I would love to be able to post an image on how do this but as a newbies I can't.
refer to bouke comment to see how to modify terminal profile.
By default meta backspace does a backwards word yank in most shells. If you press escape and then press backspace, that pretty much works everywhere.
In your Terminal's profile, you can bind ⌥⌫ (option+delete) to ⌃W (control+W), so it works similar to other apps.
If you are using Iterm2 (which is like the regular terminal of OSX just better :)
you can use this like to change this behavior:
You need to set your left ⌥ key to act as an escape character. This can be done going to iTerm2 > Preferences > Profiles > Keys.
With Natural Text Editing preset enabled in Profile -> Keys.
You can simply remove the word
Backward with alt + delete
Forward with fn + alt + delete

Resources