I know there is always the old fashioned way of holding down the left mouse button and dragging down, but for instance is there a method similar to (and of course this doesn't actually do it but it should in my opinion) holding down left mouse button and pressing CTRL+]? What I'm trying to do is highlight many lines of code with the press of a button or 1 click.
If you put the cursor on on the left or right had side of a curly brace you can use CTRL+SHIFT+] to select all code in the block. It will also select the curly braces.
This work using the opening or closing curly brace.
I have tested this and it works with MSVS 2013 and MSVS 2015
As an added bonus if you use CTRL+SHIFT+] on an opening or closing parentheses it will select all code between and including the parentheses.
Click at the top of the lines and shift click at the bottom. Its not one click but it is better then holding down the mouse and scrolling.
Related
I use visual studio with C++. When typing a word, visual studio makes suggestions, as expected, but does not always highlight them. Here is what I mean:
I type "stri", and "string" gets highlighted, and this allows me to press enter and complete the word.
Then, if I erase only part of the statement, it no longer highlights string,
And finally, most importantly, if I want to use that string elsewhere, it does not highlight the name.
In the example you can see that pressing enter goes to a new line instead of completing the word. Pressing tab would work, however it still doesn't highlight the word, which I don't like, and also I am used to pressing enter, so I would prefer not to press tab.
Working solution:
Go to Tools > Options > Text Editor > C/C++ > Advanced. Then find Member List Commit Aggressive. Set this to true.
Then optionally find Member List Commit Characters and remove all the characters except the colon character.
This solution is almost perfect and it will work for anyone who wants to do the same thing as me.
I am creating a basic text editor using ncurses. It can display text fine, but navigating with arrow keys causes a problem when tabs are encountered. Calling move(y, x) will freely move the cursor onto a tab space, where most text editors will jump to the next character. Is there functionality within ncurses to jump over tab spaces or do I need to find a way to do it myself?
You have to do it yourself: wmove moves to the given coordinates, ignoring the way characters are displayed on the screen.
If a destructive (filling with spaces) tab works for your application, then you could use waddch:
If ch is a tab, newline, carriage return or backspace, the
cursor is moved appropriately within the window:
Tabs are considered to be at every eighth column. The
tab interval may be altered by setting the TABSIZE
variable.
For an editor, you probably do not want that behavior (though it probably would be helpful to use the TABSIZE feature when displaying text).
I have some text documents (.doc and .odf) with portions of colored code appearing inside.
This code was copied as RTF from Notepad++, that's how it got colored.
However, in Notepad++ (and in many IDEs as well), the line wrap function works makes the indented code look better when in does not fit and goes to the next line.
In LibreOffice/OpenOffice and Ms Word it's possible to achieve a similar line wrap with the "increase indent" button.
So, what I'd like to do, is to automatically replace the tabs (or 4 spaces, if you like) with proper indents. Or make the tabs behave like I expect them to. Is it possible? Thanks.
Here's a visualization of the problem
I achieved what I want through some (not that many) manual steps.
find out what is the maximum number of tabs (or sets of 4 spaces), say it's 3
open the search and replace window, input 3 tabs (or 12 spaces), and click "Find All"
now all groups of 3 tabs are selected, and you are working on all the lines with maximum indentation
park or close the search and replace window, click 3 times on the "Increase indent" button (or set the left indentation in the paragraph style menu)
delete the selected groups of 3 tabs
open the search and replace window, input 2 tabs (or 8 spaces), and click "Find All"
park or close the search and replace window, click 2 times on the "Increase indent" button
delete the selected groups of 2 tabs
open the search and replace window, input 1 tabs (or 4 spaces), and click "Find All"
park or close the search and replace window, click 1 time on the "Increase indent" button
delete the selected single tabs
Now you have a nice code indentation.
If you are using Microsoft Word, then there's no "find all", but there is a way to apply paragraph styles directly from the search and replace menu. But the steps are a little different.
First decide how wide a single indentation should be (e.g. 0.5 cm)
open the find and replace window, input 3 tabs (or 12 spaces) in the Find bar
leave the Replace bar empty, but click on it
if you don't see the Search options group, click More
click on Format
click on Paragraph
set a left indentation of 3 * the indentation width you want (e.g. 1.5 cm)
click Replace All, the paragraph style will be applied but the tabs/spaces will NOT be removed
click on the empty Replace bar (again)
click No Formatting
click on Replace All (again)
now the tabs/spaces will be deleted
Rinse and repeat until you get a nice indentation.
If you are using Python (or if you want to keep your white spaces) then instead of deleting the tabs (or spaces), you can replace them with a placeholder character you don't use in the rest of the code, say £ and replace them back in one pass when you are done. However, you'll get a skewed indentation.
I guess there's a way to do this with macros, but this was good enough for me.
Say I have my cursor position to the right of a right facing case curly brace, like so:
Now, if I press enter, I expect it to auto align the cursor two tabs in, just like the break statement. But what it does is this:
It adds a ridiculous five tabs! Knowing that Visual studio has a metric ton of settings, I navigate to Tools::Settings::Text Editor::C/C++::Formatting::Indentation, and see the following window:
But changing the highlighted options in any combination actually doesn't affect the indentation at all! None of the other options seem to apply to switch statements, so I don't know what to do. How do I make it not indent 5 spaces, without disabling auto formatting?
And I might add, it not only places 5 tabs when I press enter at the end of the curly brace, but when any auto format event takes place. So when I add a semicolon at the end of a line it places 5 tabs even if I had taken them out before.
This is probably a bit late for you now, but in case someone else finds this issue: it seems to be a Visual Studio bug, you're probably running the freshly installed version of the VS2K13 called REL.
Downloading the Update 4 at http://www.microsoft.com/en-us/download/details.aspx?id=44921 helped in my case.
The curly braces ({ and }) are throwing off the auto-indenter, and it's indenting to one tab beyond the brace.
Braces there are not illegal in a switch statement, but they usually don't do you any good. Unless you need it for scoping a variable declaration, just remove the curly braces. You'll get the same code flow, and you won't confuse the auto-indenter.
EDIT
Come to think of it, you can solve this by simply moving the brace to a new line. This isn't necessarily horrible - it highlights that you're using a brace.
case SDLK_g:
{
// etc
break;
}
I went into VS2013 and created a new project and just tried making a really simple switch but it formatted correctly for me, even with the curly braces. Are you able to post that set of code?
The only other thing I can think of is maybe a setting on how braces are set up, but I don't know why that would affect it. (Nor do I think there is really even a setting for that for C++...) Other than that though you could try just not using the braces at all since you are inside a case statement, you don't technically need them.
Other than that something may have happened during installation. So re-installing is an option too.
EDIT:
Also, could just go with it and finish the code and then when finished just highlight the rows and un-indent ([SHIFT]+[TAB]) them back to their correct spot.
I can't believe I can't find a way in Webstorm that when you highlight code, then move it right or left as a group (tab left or right, moving it over left or right).
Is there a way to do this? I can't find one. I need to shift several lines of code in JSON to tab and make it read better from withing Webstorm as just one example. Most editors have this capability! unless I'm just missing it, this is a huge hole in Webstorm that is fundamental that is simply not there!
On top of this I've also noticed that if you put your cursor at the beginning of a line of code and then do Shift + Home to highlight the empty space before it, typically in most editors you can hit tab and start moving it back from the farthest point left back to right. In webstorm, when you highlight the empty space to the left of a starting line and hit tab, it starts tabbing from the the start of the line, not from the first empty space. I find this bizarre and very frustrating.
select a code region and hit Tab (Edit | Indent Selection) or Shift+Tab (unindent)