Resharper: I want all blocks in braces - resharper

I want to tell Resharper that if I have anything like
if (foo) { bar(); }
to turn it into
if (foo)
{
bar();
}
But I can't find the setting nor info on their support site.
Thanks!

Open your R# settings, go to ReSharper | Options | Code Editing | C# | Syntax Style and set Braces | In "if" statement to Enforce always:
Furthermore you have to go to ReSharper | Options | Code Editing | C# | Formatting Style | Line Breaks and Wrapping and disable Arrangement of embedded blocks | Keep existing arrangement of embedded blocks:

Related

Is it possible to stop the NERDTree window resizing when using Ctrl W Equals to make all split window equally sized in Vim?

Usually NERDTree doesn't get resized when I do this. But when I am working with a bunch of horizontal and vertical splits for a while, it can happen.
I don't know what the change in state of within the instance of Vim is that makes this issue happen during a vim session. I'm not sure if the number of splits makes a difference.
Usually I set up 4 splits, along with the NERDTree window on the left like this...
|--|-----|-----|
| | | |
|NT|-----|-----|
| | | |
|--|-----|-----|
When I do the equal split resize I end up with this when things go wrong...
|-----|-----|-----|
| | | |
| NT |-----|-----|
| | | |
|-----|-----|-----|
That's not the end of the world. The real problem is when I close a couple of splits it ends up like this...
|--------|--------|
| | |
| NT |--------|
| | |
|--------|--------|
... which is just silly and I have to exit Vim and start over.
I use Ctrl-w followed by = to carry out the equal resizing of vim splits.
I think this is a bug, perhaps in NERDTree. There is a "change of state" that causes this problem to start happening. It is when you do a Ctrl-w followed by 'o' to maximize one of the splits. I've reported this as an issue in the NERDTree github project at https://github.com/scrooloose/nerdtree/issues/644

Autoformat of single statement blocks to one line with braces on same line

Just recently, I suspect after a ReSharper update, VS2015 has started with an auto-format that is blood-curdling:
If I type e.g:
using(var x = new Disposable())
{
...
}
as soon as I type the closing brace, it gets formatted to an ugly bloody single line:
using(var x = new Disposable()) { ... }
I have checked every formatting setting in VS and R# and can find nothing except 'Autoformat after }' in the VS settings, and have naturally turned it off. Does anyone have any idea what setting or device or demon is doing this to me?
To disable auto-formatting on closing brace in R#, please untick ReSharper | Options | Environment | Editor | Editor Behavior | Auto-format on closing brace
To disable moving braces to a single line with using statement, please select "Do not change" or "Force line breaks" here ReSharper | Options | Code Editing | C# | Formatting Style | Line Breaks and Wrapping | Preserve Existing Formatting | Break line in a block with a single statement

How to convert split windows to tabs and vice versa in Vim

For example, I use 3 split windows to open 3 different files:
+---------------+-----------+
| | |
| window 1 | |
| | |
+---------------+ |
| | window 3 |
| | |
| window 2 | |
| | |
| | |
+---------------+-----------+
Now, I want to open them with 3 different tabs and vice versa
Is there any trick to achieve this? Or do I need any plugin?
Besides, if I want to display 3 buffers in 3 full screen windows (as opposed to a split window), what should I do?
Not sure if there is a plugin, which will do all splits at once. But there is a way to do it one at a time
For moving the current split into a new tab use
ctrl + w, T (shift + t)
repeat the above process for all splits.
Now for getting the tab in to split, you can make use of a plugin call "Tabmerge", download Tabmerge.vim from http://www.vim.org/scripts/script.php?script_id=1961 to ~/.vim/plugin
then to merge the tab use :Tabmerge [tab number] [top|bottom|left|right]
If you are careful with your buffer list, you can use :sball and :tab sball to open in windows or tabs, respectively.

Cucumber scenario with quotes in the text

I'd like to have quotes in my scenario data. It's not working when that data has quotes in it. An example modified from The Cucumber Book would be:
Then I should see the "<message>" message
Examples:
| type | message |
| Swiss | I love Swiss cheese |
| Blue | I love "Blue" cheese |
| Cheddar | I love Cheddar cheese |
In my particular case I get an undefined step definition message because of "Blue" in the second scenario above. Is there a way I should be escaping the quotes? (I've tried backslashes but that didn't make any difference.)
My guess is that your current step definition looks like:
Then /I should see the "([^"]+)" message/ do |message|
p message
end
The [^"] tells the regex to match anything except double-quotes. This would be why your "Blue" example does not match.
Given that you are only looking for one argument, it would be safe to do:
Then /I should see the "(.*)" message/ do |message|
p message
end
Using (.*) would match everything between the quotes, including the quotes around Blue.

Word Wrap in Vim (preserving indentation)

I was just looking at this post which describes how to wrap entire words in vim. The accepted solution was this:
:set formatoptions=l
:set lbr
Which takes this text (tabs are shown as \t):
*Inside of window *Outside of window
|---------------------------------------|
|\t\tthis is a like of text that will wr|ap here
|\t\tcan you see the wrap |
| |
|---------------------------------------|
This accomplishes a behavior like this (tabs are shown as \t):
*Inside of window *Outside of window
|---------------------------------------|
|\t\tthis is a like of text that will |
|wrap here |
|\t\tcan you see the wrap |
| |
|---------------------------------------|
I would however like to redefine this function. I would like the wrapped line to have the same number of tabs in front of it that the line above has plus one. Ie:
*Inside of window *Outside of window
|---------------------------------------|
|\t\tthis is a like of text that will |
|\t\t\twrap here |
|\t\tcan you see the wrap |
| |
|---------------------------------------|
Any ideas?
This did not work when the question was originally asked, but as of June 25, 2014, this will work. (Assuming you update your vim to a version newer than that date)
Add to your .vimrc:
" Indents word-wrapped lines as much as the 'parent' line
set breakindent
" Ensures word-wrap does not split words
set formatoptions=l
set lbr
And that's it!
--
Some people (myself included) share a single .vimrc across multiple computers. In that case, it's important to have this line be robust (to avoid annoying error messages). This is a little better:
if has("patch-7.4.354")
" Indents word-wrapped lines as much as the 'parent' line
set breakindent
" Ensures word-wrap does not split words
set formatoptions=l
set lbr
endif
This way, if you're on an earlier version of vim, you don't get an error message.
The breakindent patch has what you're looking for. I successfully applied it using instructions found in this thread:
Patch Vim with the breakindent patch on OS X with Homebrew
Specifically, echristopherson's Homebrew formula.
I know this thread is old but it's popular on google and I came across it multiple times when trying to find a solution.
EDIT: This patch is now included with vim as patch 7.4.338. See: https://retracile.net/blog/2014/07/18/18.00
On Yosemite (Mac OS X), I used snowbound's command with hombrew:
brew install macvim --with-features=huge --override-system-vim --HEAD
The best you're going to get is the showbreak option which will put a fixed string in front of each wrapped line (I use set showbreak=...).
I agree with the answer that says 'showbreak' is the best option. Showbreak does not typically allow you to put nonprinting characters (e.g., spaces or tabs) into the showbreak string, so as typically used it will just give you an indicator along left margin, i.e., no real indent. This isn't great, since main goal of OP, I think, is to give wrapped lines an indent keep them from cluttering left margin area and looking like lines of their own.
So one way to add an (ugly) indent using showbreak is to just use a lot of characters, .e.g, ":set showbreak=>--------------->". This results in something that looks like this:
*Inside of window *Outside of window
|---------------------------------------|
|\t\tthis is a like of text that will |
|>--------------->wrap here |
|\t\tcan you see the wrap |
| |
|---------------------------------------|
A better alternative might be to make use of nonbreaking space characters (assuming your instance of Vim is unicode enabled), each of which can be entered into the showbreak string using the key sequence of ctrl-v,160. That way you can enter a showbreak string that is blank at the left side and appear to be a true indent. E.g., ":set showbreak=. . . . . . . . . . >>" where each '.' in the command is actually a nonbreaking space character entered by pressing ctrl-V,160. That way you end up with a wrap that is nicely indented, like this:
*Inside of window *Outside of window
|---------------------------------------|
|\t\tthis is a like of text that will |
| >>wrap here |
|\t\tcan you see the wrap |
| |
|---------------------------------------|
You still don't have any ability to vary the level of indent according to indent of previous line, but at least you get clean indent of wrapped lines without lots of visual clutter along left margin of window. There could still be confusion if indent of a wrapped line is less than that of the beginning of an actual line, but this could perhaps be avoided by making the showbreak "indent" quite large (i.e., greater than any indent commonly found in your code) but still small enough that it provides enough space for legible wrapping of the text. For many uses I think a showbreak indent of 40 or 50 spaces would do this pretty well.

Resources