code-formatting

Declaring long strings that use string interpolation in C# 6

こ雲淡風輕ζ 提交于 2019-12-20 09:48:25
问题 I usually wrap long strings by concatenating them: Log.Debug("I am a long string. So long that I must " + "be on multiple lines to be feasible."); This is perfectly efficient, since the compiler handles concatenation of string literals. I also consider it the cleanest way to handle this problem (the options are weighed here). This approach worked well with String.Format : Log.Debug(String.Format("Must resize {0} x {1} image " + "to {2} x {3} for reasons.", image.Width, image.Height,

Enabling IntelliJ's fancy ≠ (not equal to) operator

放肆的年华 提交于 2019-12-20 09:09:04
问题 I witnessed this in the GOTO 2016 • Kotlin - Ready for Production conference by Hadi Hariri. In some of his code, what would normally look like: if (x != y) { /* do some stuff */ } Is being displayed in an elegant style: if (x ≠ y) { /* do some stuff */ } Here's a screen-shot from the live coding session: He's using the regular != operator, the IDEA is taking care of the rest. I've been playing with my IntelliJ's configuration but couldn't enable this new fancy feature. Any help? PS. I'm

C++ Pointer in Function

江枫思渺然 提交于 2019-12-20 02:45:16
问题 I know that technically all three ways below are valid, but is there any logical reason to do it one way or the other? I mean, lots of things in c++ are "technically valid" but that doesn't make them any less foolish. int* someFunction(int* input) { // code } or int *someFunction(int *input) { // code } or int * someFunction(int * input) { // code } I personally think the third one is annoying, but is there a "correct" way? I am typically more inclined to use the first one (as the second

Resharper formatting code into a single line

夙愿已清 提交于 2019-12-18 21:26:12
问题 I am having an issue with formatting code with Resharper. I have disabled the option for wrapping lines. With this option, the following code will be formatted to a single line. Does anyone have an idea how to have Resharper not format the following code? Mapper.CreateMap<CountryEntity, Country>() .ForMember(dest => dest.CreatedBy, map => map.MapFrom(src => src.CreatedBy)) .ForMember(dest => dest.DateCreated, map => map.MapFrom(src => src.DateCreated)) .ForMember(dest => dest.Id, map => map

How to format code in Visual Studio Code

时间秒杀一切 提交于 2019-12-18 18:49:11
问题 Hello I am asking how to format code in Visual Studio Code the last update on Windows . I tried ctrl k+ Ctrl d doesn't work .. I also tried Shift + Alt + F . it didn't work too. So please help me and it isn't duplicate because i tried the following solution: How do you format code in Visual Studio Code (VSCode) 回答1: if you are working on php you should download php exension format code. Press F1 and type : ext install PHP Code Format . Then Shift + Alt + F will work 回答2: You can also select

Custom indent width for BeautifulSoup .prettify()

狂风中的少年 提交于 2019-12-18 03:03:22
问题 Is there any way to define custom indent width for .prettify() function? From what I can get from it's source - def prettify(self, encoding=None, formatter="minimal"): if encoding is None: return self.decode(True, formatter=formatter) else: return self.encode(encoding, True, formatter=formatter) There is no way to specify indent width. I think it's because of this line in the decode_contents() function - s.append(" " * (indent_level - 1)) Which has a fixed length of 1 space! (WHY!!) I tried

How to customize Eclipse's text editor code formatting

醉酒当歌 提交于 2019-12-17 22:46:09
问题 How can I set my Eclipse's code formatter to allow code rows longer than 80 characters. I know that very long lines is hard to read but in my opinion 80 characters per line is very small value for wide screen monitors. 回答1: In Preferences , go to Java > Code Style > Formatter and edit/create the formatter and go to tab Line Wrapping . There in you can set the Maximum line width . Further on you can in General > Editors > Text Editors also set the Print margin column which should shift up that

How to format PHP files with HTML markup in Visual Studio Code?

天大地大妈咪最大 提交于 2019-12-17 22:39:33
问题 I'm using Laravel so all the views are .blade.php files. Visual Studio Code won't format the HTML because of the PHP extension. I removed the blade part of the filename, but it still isn't formatting the files properly (via Alt + Shift + F ). I also tried about five extensions but none of them do the reformatting. How can I format .blade.php files in Visual Studio Code? 回答1: The extension beautify just do it very well, either add php and any other file extension type to the config as said

How do I set up VSCode to put curly braces on a new line?

…衆ロ難τιáo~ 提交于 2019-12-17 22:27:02
问题 Let's say I type in the following code and format it. if (condition) { /* Hello! */ } If this is C# code, it is formatted like this: if (condition) { // Hello! } If it is JavaScript, VSCode formats it like this: if (condition) { // Hello! } So how can I use the first formatting style (curly braces on new lines) for all languages? I can't find a setting or something similar. Suggestions? 回答1: Follow the steps below to make Visual Studio Code format opening curly braces on a new line for Java

Directory layout for pure Ruby project

自作多情 提交于 2019-12-17 21:54:22
问题 I'm starting to learn ruby. I'm also a day-to-day C++ dev. For C++ projects I usually go with following dir structure / -/bin <- built binaries -/build <- build time temporary object (eg. .obj, cmake intermediates) -/doc <- manuals and/or Doxygen docs -/src --/module-1 --/module-2 -- non module specific sources, like main.cpp - IDE project files (.sln), etc. What dir layout for Ruby (non-Rails, non-Merb) would you suggest to keep it clean, simple and maintainable? 回答1: Bundler includes the