How do I shift a set of lines one space to the right within a text editor? - visual-studio

How do I shift a set of lines one space to the right within a text editor?
If I wanted to shift a set of lines several spaces to the right, I would perform:
selected text + Tab
However, I just want to shift the text one space to the right without tabbing.
Any suggestions?

Hold down the alt key, left-click and hold the mouse button down on the first line where you wish to insert your space. Then, while still holding down the left mouse button, drag the mouse vertically to extend this edit point to all the lines you want to move. Dragging it horizontally will create a box selection, which you want to avoid, as the selected text will end up being replaced, rather than a space be added.
Also, you cannot select individual, disjoint lines to move. You can only use alt-drag over a contiguous block of lines.
Once you have your multiline edit point created, hit the spacebar once.
Tada.
Here's a blog post by Scott Guthrie with more details and a vidya demo
If you don't want to use the mouse, you can use shift+alt+(up, down, left, or right) to create a box selection, or a multiline edit point.

Related

Is there a way to move entire row in MS Word tables?

In many source code editors, you can easily rearrange lines by holding hotkey sequence while pressing arrow keys up and down, which moves lines up or down. Is there a way to do that in tables in MS Word? If yes, will it move color formatting along the row, also?
Right now, I have to cut rows and paste them where I need, using paste special>source formatting option, which glitches and requires 3 additional clicks.
Although this is not a question for SO (no programming etc.) this is the answer:
Alt + Shift + arrow up/down
This works for any paragraph or table row.

How to move from Title box to Content box without mouse?

I create a new slide (Ctrl+m).
The layout by default is Title + Content.
I edit the title slide and now want to move to the content textbox.
How can I do this without my mouse?
Nutshell answer:
Hit ESC, then TAB key.
Short answer:
After typing your text into the Title placeholder, hit ESC to exit editing.
Then hit the TAB key to move to the next object. (If that is not the Content placeholder, continue hitting TAB until the desired object is selected.)
Start typing to enter your text.
Extended answer:
Hit Ctrl+m to create a new slide that uses the same Layout as the current one.
Hit the TAB key to go to the first object on the slide. (This is the back-most object on your slide; the one on the bottom in the Selection Pane list. If the designer of the Layout did a good job, this is the Title placeholder. If not, keep hitting TAB until the desired object is selected.)
Start typing your text. (If you edit an existing slide and there is already text contained in the shape, simply starting to type will append text at the end. If you want to replace the existing text, hit the return/enter key before starting to type. That will select all contained text, so it will be overwritten when you start typing.)
When finished entering your text, hit the ESC button (to exit edit mode and have the actual shape selected), and hit the TAB key to go to the next object – i.e. the second-lowest one. (Again, if the designer did a good job, this will be your Content placeholder. If not, continue hitting TAB.)
Go to step 3 to continue with the next object.
After typing the title text, press CTRL + M to put the cursor in the content placeholder.

Normal Mac option-drag block selection in VS Code?

There are already many questions about VS Code's block selection and multi-cursor selection, and I'm not asking how to use it, but rather, how to make it behave in the standard way on a Mac (without the shift ⇧ key pressed).
The way it currently behaves is this: your current cursor location defines one corner of the block selection, and when you press ⇧⌥ and click somewhere else, you define the opposite corner of the block. You can drag as you're clicking, but dragging really only changes the definition of that opposite corner. Your (text) cursor's position always defines one of the block's corners.
Considering that the VS Code default keybinding is ⇧⌥, the behavior is proper for having the shift ⇧ key pressed. But I'm trying to find a way to get the normal behavior that you'd expect on a Mac when the shift ⇧ key is not pressed.
In normal Mac behavior (without shift), the entire block is defined by:
where you first click, before you start dragging, and
where you release, after dragging.
This behavior is exactly the same as for plain-vanilla text selection, except that you get a block, instead of a line-oriented selection.
I would like to find a way to have VS Code allow me to define the block selection solely based on where I click and drag, and not based on the current text cursor location.
How can I do this?
Note that you don't have to drag the mouse. You can single click (with no modifier keys) in one corner, press and hold Shift and Option, and click in the opposite corner, then release the Shift and Option keys. So, your attempt to start the selection is actually extending it (relative to the previous selection).
What's working for me in 1.53.1 (January 2021 release) is to click and hold the mouse button (with no keys pressed; this starts a normal, non-column selection), then press and hold Shift and Option, then continue dragging the mouse. I find this method cumbersome and prefer selecting opposite corners as above.
I don't see an obvious way to change to Option-only to start a column selection.

Xcode Editor text selection issue

If I want to delete few lines of text in most of text editors, not touching some words on the bottom line and the whole upper line, I put cursor on the bottom row leaving all unnecessary words to the left of the cursor. Then I select few lines vertically by holding Shift + ↑. I stop on upper row and get some selection: part below + right part of the upper row:
In this example I want to get rid of if word and an empty space between the function header and the code, not touching the function header (even hough let will stick to the opening bracket {).
Normally (not in Xcode) I would still hold Shift and will press cmd + ➝ to deselect the right (selected) part or the top row.
Result will be like this:
I can simply press Delete and job is done.
However, in Xcode such shortcut usage makes bottom row fully selected (till the right) and not changes upper row selection:
Same thing happens if you select from top to bottom and you need to remove extra selection from the bottom line.
I tried to rebind shortcuts in Preferences but didn't find a solution.
This example is very particular and maybe not the best, however I face such selection problems only in Xcode and have to use mouse which is not handy.
This is a rather old question, but what you want is fairly simple to achieve. If your cursor is between the if and the let, you would only need to press option-shift-left arrow twice. The first time, it would select the if and the leading tabs, and the second would select the empty line.

Cells & cellgroups in mma

This question and the comments and answers prompted this question. How do I effectively use Cells and CellGroups in mathematica? I've always only programmed systematically inside the input cells, entering the next line in a new cell after evaluating the previous. Looking around at the different options available, this seemed inefficient.
How do I use these more effectively? I tried organizing my code into sections using command-5 and into subsections, etc. But then when I try to get back to input cell with command-9, it doesn't evaluate it. I'm sure I'm doing something wrong, so help is appreciated.
Cell groups are just that, a way to group cells together. These groups can be easily selected, executed as one, and opened/closed (collapsed). By default these groups are indicated by a series of blue brackets to the right of the cells:
As seen above, output cells are automatically grouped with the input cell that created them. Also, the Section cell automatically groups the Text, Input, and Output cells below it. Finally the Title cell groups all cells below it, including the Section cell.
The different classes of cells that are available, such as Title, Section, etc., are determined by the active Stylesheet. The way they group is controlled by the option CellGroupingRules. This is a more advanced area, and details are probably better addressed in a different question.
Cell Grouping can be done either automatically, the default, or manually, or to a limited extent by a combination thereof. This is all handled by the menu commands in Cell > Grouping > ... or the keyboard shortcuts listed there.
If using Automatic Grouping, then styling a cell in a style that groups (as controlled by CellGroupingRules) will automatically group "lesser" cells and cell groups beneath it.
To style a cell, select the entire cell, not just the cell contents, by either:
clicking on the blue cell bracket (or the area where it would be if it is hidden)
clicking within the cell and using Alt+. until the entire cell is selected
clicking and dragging from above the cell, where the cursor is horizontal, to below the cell
Then, use menu Format > Style > ..., or the corresponding key combinations.
The same methods can be used to select cell groups, rather than individual cells.
To create a new cell of a particular style:
click outside of existing cells where the cursor is horizontal
this should create a horizontal rule as shown in earlier illustration
specify a style, again with Format > Style > ... or keyboard shortcuts
start typing (or paste) the contents of the new cell
To create a new Input cell, the default style, simply do step (1) and then type or paste the input.
It depends on your stylesheet. Input is not the nineth numbered style in every stylesheet. Also, you have to select the cell bracket to change a cell's style.
I use sections particularly to be able to use folding, i.e. the double clicking on the cell group bracket to hide the lower ranking cells. That makes for a clean document. It doesn't do anything with the Input cells (except for the context option).

Resources