indentation

How to correct indentation in IntelliJ

北城以北 提交于 2019-11-27 09:33:50
问题 How can indentation be automatically (not manually) corrected in IntelliJ? In Eclipse, it's possible to just highlight the code that needs indenting, right-click, and select Source > Correct indentation . Is there any method for doing the same thing in IntelliJ? 回答1: Code → Reformat Code... (default Ctrl + Alt + L ) for the whole file or Code → Auto-Indent Lines (default Ctrl + Alt + I ) for the current line or selection. You can customise the settings for how code is auto-formatted under

IntelliJ Scala Plugin's case class indentation is absurd

梦想的初衷 提交于 2019-11-27 09:04:55
问题 When a case class has many fields and their names are long, it is often a good idea to write each field in each line like: case class Person ( name: String, age: Int ) This resembles C/C++ struct definition and totally readable even when the case class becomes bigger. But IntelliJ IDEA's default Scala plugin automatically changes its indentation: case class Person ( name: String, age: Int ) which looks weird to me, but the Scala Style Guide doesn't mention anything about case class

Python: Expected an indented block

浪尽此生 提交于 2019-11-27 08:27:08
问题 I thought everything was properly indented here but I am getting an IndentationError: expected an indented block at the else: statement. Am I making an obvious mistake here? def anti_vowel(text): new_string = "" vowels = "aeiou" for letter in text: for vowel in vowels: if (lower(letter) == vowel): #do nothing else: #append letter to the new string new_string += letter return new_string 回答1: Do nothing translates to using the pass keyword to fill an otherwise empty block (which is not allowed)

How to convert a K&R function declaration to an ANSI function declaration automatically?

女生的网名这么多〃 提交于 2019-11-27 08:06:22
问题 // K&R syntax int foo(a, p) int a; char *p; { return 0; } // ANSI syntax int foo(int a, char *p) { return 0; } As you see, in K&R style, the types of variables are declared in new lines instead of in the braces. How to convert a K&R function declaration to an ANSI function declaration automatically? Does anybody know such an easy-to-use tool in Linux? 回答1: You can use cproto or protoize (part of GCC) to generate function prototypes or convert old style (K&R) functions to ANSI format. 回答2:

ANTLR What is simpliest way to realize python like indent-depending grammar?

给你一囗甜甜゛ 提交于 2019-11-27 07:27:47
I am trying realize python like indent-depending grammar. Source example: ABC QWE CDE EFG EFG CDE ABC QWE ZXC As i see, what i need is to realize two tokens INDENT and DEDENT, so i could write something like: grammar mygrammar; text: (ID | block)+; block: INDENT (ID|block)+ DEDENT; INDENT: ????; DEDENT: ????; Is there any simple way to realize this using ANTLR? (I'd prefer, if it's possible, to use standard ANTLR lexer.) I don't know what the easiest way to handle it is, but the following is a relatively easy way. Whenever you match a line break in your lexer, optionally match one or more

Remove all arbitary spaces before a line in Vim

↘锁芯ラ 提交于 2019-11-27 07:11:35
I'v written a plugin where it comes to parsing a XML tag. The content inside the tag is indented and when i copy the parsed string into the file it's gettting like: Example line This is part of the parsed line Thats goes one End of line What I want is to remove all spaces in front of these lines, the final text should be Example line This is part of the parsed line Thats goes one End of line I've tried to use = but it doesn't work the way I want. How can I do that with minimal key strokes ? To format a line to the left I use :left . Use this format an entire file: :%le A simple search/replace

Tool to convert python indentation from spaces to tabs? [closed]

*爱你&永不变心* 提交于 2019-11-27 06:44:42
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 5 years ago . I have a some .py files that use spaces for indentation, and I'd like to convert them to tabs. I could easily hack together something using regexes, but I can think of several edge cases where this approach could fail. Is there a tool that does this by parsing the file and determining the indentation level the

Bash continuation lines

痞子三分冷 提交于 2019-11-27 06:13:17
How do you use bash continuation lines? I realize that you can do this: echo "continuation \ lines" >continuation lines However, if you have indented code, it doesn't work out so well: echo "continuation \ lines" >continuation lines This is what you may want $ echo "continuation"\ > "lines" continuation lines If this creates two arguments to echo and you only want one, then let's look at string concatenation. In bash, placing two strings next to each other concatenate: $ echo "continuation""lines" continuationlines So a continuation line without an indent is one way to break up a string: $

Is it possible to display Indentation guides in Vim?

隐身守侯 提交于 2019-11-27 06:10:29
I'm a longtime Vim user (3 or 4 years) who has recently started dealing with some deeply nested code. This code is indented with spaces, not tabs. I would like some clean and non-distracting indication of indentation to help with keeping track of which block of code I'm in when I'm looking at something many levels deep. :set list Only displays tab and endline characters. I have found one plug-in (can't seem to dig it up at the moment) that will highlight each indentation level in progressively darker colors but this is visually unappealing. Ideally I would like to see thin vertical lines at

Custom Brace formatting with Resharper

二次信任 提交于 2019-11-27 06:08:24
I'm using Resharper 4.5 and I need custom formatting of braces when writing an array or object initializer. Resharper supports some styles: Gnu Style: int[] array = new int[] { 1, 2, 3 } but I need: int[] array = new int[] { 1, 2, 3 } Is there any way to customize this templates? You can customize ReSharper to do just that, you'll need to do the following (All in ReSharper -> Options -> C# -> Formatting Style ): In Braces Layout , set Array and object initializer to At Next line (BSD Style) . In Other , make sure that Continuous line indent multiplier is set to 1 . In Other , make sure that