Resharper - wrapping long lines with continuation? - visual-studio-2010

I'm using Resharper 8. ( visual studio 2010).
I've enabled "wrap long lines"
Bu when I have long lines it does wrap them but it starts at "X=0" at the next line ( see number "2" : )
http://i.stack.imgur.com/mfdz3.png
Question :
Is there any configuration ( VS || R#) so that when 1 is wrapped , 2 will start under 3 ?

This isn't related to ReSharper. This is how Visual Studio handles wrapping long lines - it's still a single line of text, as you can see by the line number, but it's wrapped to all appear on the screen at once.
If you want to reformat the text, you can simply enter a carriage return, e.g. after the if statement, and the text will then move to a new line and should be indented under your number 3. ReSharper can do this for you with code cleanup (ReSharper -> Tools -> Code cleanup)

Related

How to remove word in a visual selection in Vim

Suppose I have the following input as shown below. What I would like to do is to visually select lines 2 through 4 (shift + v) and then delete the word dog.
How can I do that? I know I can use something like :s/dog// on my selection, but I was wondering if there's a more straightforward way.
1 The quick brown dog
2 dog jumps
3 over the
4 lazy dog,
5 but it should be just a fox.
The final output should be (affected only by the visual selection on lines 2 through 4):
1 The quick brown dog
2 jumps
3 over the
4 lazy ,
5 but it should be just a fox.
That's impossible.
Why?
tl;dr
I think, you are envisioning something like a normal mode within visual mode (so that you can "move and delete like in Vim" while you are in visual mode). Such a thing doesn't exist.
Think about it: if you visual select some lines, then those lines, and nothing else, are the object of whatever action you do next (d, s, c, or whatever).
But you want to take an action not on those visually selected lines, but on words within them. But how can you tell Vim to take action on the words dog and not on other words? You can do that with movements, but as long as you are in visual mode, that's not possible, because any movement will just change the visual selection, and not allow you to somehow move within it.
This means that you need to abandon the visual selection so that you can move to those words and use them as the textual object for the action.
If you really want to start from the visual selection, then the only way to give the info that you want to take action on the words dog, is to type them out while you are in visual mode. And that's precisely what the :s approach does.
You can take advantage of the marks '< and '>: they store the start/end position of the visual selection and they keep their value after you exit the visual mode.
In command line mode, Ctrl-RCtrl-W inserts the word under the cursor.
By combining this, you can create a mapping like that:
noremap <c-d> :'<,'>s/<c-r><c-w>//<cr>
Then to use it:
first select the wanted zone with V;
hit Esc to exit visual mode;
move your cursor under the word you want to delete;
then trigger the mapping, in this example Ctrl-D.
I think there is no way in way to just replace a specific word in specific lines with visual selection. You can also use sed for that (look at #5).
Anyways:
Here are 4 way to delete the word dog in a file and one way to do it with sed:
1 (with visual mode):
Type v to enter visual character mode
Highlight dog
Press d for deleting
2 (with substitute and confirmation):
:%s/dog//gc
g stands for global
c stand for confirmation
You will be ask for every entry, what to do with.
3 (with substitute):
:2,4s/dog//
4 (with search mode):
/dog
Type: n for next match
Type: d for deleting the match
For further information: Search and Replace
5 (with sed):
sed 2,4\s/dog// filename
When you are in visual mode, pressing : automatically inserts the visual range in the command-line so whatever Ex command you use after that is going to work on the visually selected lines:
: becomes :'<,'>, in which '<,'> is a range beginning on the first line of the visual selection and ending on the last line of the visual selection.
After that, you can do s/dog<CR> (no need for the //) to substitute the first dog with nothing on every selected line. This is effectively equivalent to doing :2,4s/dog<CR>.
From a semantic point of view, :s/dog<CR> is as close as you can get with the built-in features to "remove dog in the current visual selection" so, barring making an hypothetical custom mapping that would only save a couple of keystrokes, you are unlikely to find a more "straightforward" way.

SELE command with #2 && Name

Sele 2 && Conductor
I am asked to convert a Visual Fox Pro app to Asp.NET Core
I am having trouble finding out what this means.
In FoxPro, commands can optionally get four-letter abbreviated.
So that Sele is a lazy way to refer to the Select command and && Conductor is a code editor comment, similar to a hypothetical C# line like:
Select 2; // Conductor
Quoted from
Visual FoxPro 9.0 SP2 Help
SELECT Command
Activates the specified work area.
SELECT nWorkArea | cTableAlias
Parameters
nWorkArea
Specifies a work area to activate. If nWorkArea is 0, the lowest-numbered unused work area is activated.
cTableAlias
Specifies a work area containing an open table to activate. cTableAlias is the alias of the open table. You can also include a letter from A through J for cTableAlias to activate one of the first ten work areas.

How do I control indentation of wrapped lines in Visual Studio

I have Visual Studio 2019 (Community at home; Professional in the office). I also have ReSharper. I set up line length to be 120; indentation at 4, and autoformatting on close brace or semicolon. The language is C#
The problem is that indentation of the wrapped line is completely unpredictable (at least to me). Sometimes it is indented 4 characters as I expect; sometimes it is under a parenthesis or to the right of => or same operator (like &&). So, frequently wrapped line starts at character 80 or 90!
How can I make it always indent 4 characters from the previous line?
Needless to say that I tried a dozen of combinations of options under Visual Studio and Resharper Code Editing - Formatting options. Visual studio doesn't seem to have any option that would make it push the new line. Resharper has Parenthesis section under C# - Formatting style. But nothing makes wrapping simple
Example:
lstGroup.Select(s => new Group
{
...
Status = lookup.Where(w => w.LookupType == LookupConstants.CRIMETYPE &&
(int?)w.LookupIndex == (string.IsNullOrEmpty(s.TempCrimeType) ? 0
: Convert.ToInt32(s.TempCrimeType))).Select(w => w.LookupDescription).FirstOrDefault(),
...
});
(it may not be clear, but the lines don't run past char; so I would like it to stay this way!). After hitting semicolon at the end of the statement, it turns into
Status = lookup.Where(w => w.LookupType == LookupConstants.CRIMETYPE &&
(int?) w.LookupIndex == (string.IsNullOrEmpty(s.TempCrimeType)
? 0
: Convert.ToInt32(s.TempCrimeType))).Select(w => w.LookupDescription).FirstOrDefault(),
I'm not sure if you can completely simplify indents for wrapped statements/expressions, but the following options should make it much easier. If something still irritates you, please amend your question with examples.
Tabs, Indents, Alignment
Set all options in "Parenthesis" section to "Parenthesis and inside equally"
Turn off all options in "Align Multiline Constructs"
Brace Layout
Set "Expressions (initializers, switch expressions)" to "At next line indented (Whitesmiths style)"
Consider also to whether you want to also change "Lambda and delegate" to the same style
UPDATE: To prevent ReSharper from re-wrapping your code, go to "Line breaks and wrapping" page and look for options called "Wrap ..." with values "Chop if long or multiline" and "Chop always". Change them to "Simple wrap" as needed. You may also want to ensure that all "Keep existing arrangement..." options are turned on. Your particular example is influenced by a setting called "Wrap ternary expression".

pgAdmin 4 v3 Auto Indent not working

Since upgrading to 4.3, Auto Indent is not working (working in a Query Tool tab). When pressing enter at the end of a line of code, the cursor appears at a random position on the next line (sometimes right at the end) and not at the correct indentation position. This is very frustrating, as I have to click at the beginning of the line and indent correctly myself for every new line.
I have tried Chrome and Edge with no difference. I have changed the Tab Size and Use Spaces Options without any luck. I am using Windows 10 Pro.
Anyone else with this problem?
UPDATE!!!
This issue is fixed in pgAdmin 4 Version 4.3!
Thank you pgAdmin Team!
Note: This is still an issue up through pgAdmin 4 version 4.2
Updated: Feb 19, 2109
:(
/*
Issue:
(Tested on Windows Server 2012 R2, Chrome and Firefox, pgAdmin 4 3.2)
Using nested functions in a variable assignment, or just in a SQL statement
causes multiple tabs to be added when hitting enter for a new line anywhere
later in your code.
If you uncomment the first line with nested functions (below), all
carriage returns lower in the code create new lines with
many unwanted tabs.
Uncomment the line below and hit enter at the end of the line,
or before another line of code.
*/
/*
x := upper(substr('uncomment to test this. Hit enter after the semicolon.', 13));
*/
/*
My workaround is to unnest the functions and use multiple statements.
Note: Be sure the offending line above is commented out.
*/
x := substr('uncomment to test this. Hit enter after after the semicolon.', 13);
x := upper(x);
Have tried your suggestion and it does work. But it does seem odd that we have to comment out the entire offending line (i.e. with the nested text) to make this work. I haven't had this issue with other editors. For example, entering the same text in SQL Developer as follows:
SELECT *
FROM employees
WHERE deptno IN (SELECT deptno FROM departments
WHERE loc = 'CHICAGO');
Pressing enter will place the cursor under the 2nd WHERE (same as Postgres). I clear the tabs with Shift+Tab to column 1, and going forward I am fine. Each new line, cursor is at the beginning. This doesn't work with Postgres.
I am still new to a lot of this. Thank you for sharing.

VIM Blockwise Insert

I would like to insert a hash at the beginning of a selected block of text in VIM (ruby comment). I selected the lines in Visual Mode, but how do I perform the same operation to all lines?
You have two primary options:
Select in block visual mode (ctrl-v), then use I to insert the same thing along the left side of the entire block. Similarly A appends; see blockwise operators.
Select the lines in normal visual (v) or visual line (V) mode, then run the same command on all of them, for example s/^/# / or normal I#. Typing : while you have a visual selection automatically uses the visual selection as the line range (denoted by '<,'>).
While in visual mode do the
:'<,'>s/^/#
actually, '<,'> will be inserted automatically when you hit :.
You better use this.
COMMAND MODE with set number to see lines
:10,50s/^/#/g
First number before comma is the start line and second number after comma is the end line. Both are included.
Another question might have copied this question, so came here from How to Insert in Visual Block Mode.
Highly recommend that people take a look at this cheat sheet: http://www.rayninfo.co.uk/vimtips.html
As people do more research into VIM people will see a lot of %s/^/# with the % sign in front and by replacing the % sign with what pops up in Visual Block Mode with :'<,'> the symbols that pop up you are able to do insert, etc.
:'<,'>s/^/# (applied on selected lines only)
:%s/^/# (applied globally)
(sharing my two cents after researching how to add a hrefs' to different lines).

Resources