indentation

Wanted: Command line HTML5 beautifier [closed]

一个人想着一个人 提交于 2019-11-28 15:28:47
问题 Wanted A command line HTML5 beautifier running under Linux. Input Garbled, ugly HTML5 code. Possibly the result of multiple templates. You don't love it, it doesn't love you. Output Pure beauty. The code is nicely indented, has enough line breaks, cares for it's whitespace. Rather than viewing it in a webbrowser, you would like to display the code on your website directly. Suspects tidy does too much (heck, it alters my doctype!), and it doesn't work well with HTML5. Maybe there is a way to

IntelliJ Scala Plugin's case class indentation is absurd

隐身守侯 提交于 2019-11-28 15:14:15
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 indentation. I couldn't find anything in the IDE settings that can change this behaviour. Is there an option to

How to indent/format a selection of code in VSCode with ctrl+shift+f

雨燕双飞 提交于 2019-11-28 14:49:42
问题 I want to indent a specific section of code in VSCode I read How do you format code in Visual Studio Code (VSCode) post that gives shortcuts to indent the whole code but it doesn't work when selecting a specific section of code. I tried ctrl+shift+F after selecting some line in my code but the whole file is indented. I'm on Windows with VSCode Insider 1.8.0. Any help is appreciated. 回答1: I want to indent a specific section of code in VSCode: Select the lines you want to indent, use Ctrl + ]

Python: Expected an indented block

我们两清 提交于 2019-11-28 14:34:14
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 Cilyan Do nothing translates to using the pass keyword to fill an otherwise empty block (which is not allowed). See the official documentation for more information. def anti_vowel(text): new_string = "" vowels =

Can CPP preprocessing statement in Fortran be indented?

穿精又带淫゛_ 提交于 2019-11-28 14:31:05
I am fairly new to use Fortran preprocessing statement and have a question which is probably pretty native. Can Fortran preprocessing statement be indented? I tested using Gfortran 4.8.1 on Linux (openSUSE Leap) and it turned out I it can not be indented at all. The following code main.f90 works with gfortran -cpp main.f90 -o main : program main implicit none #ifdef DEBUG print *, "I am in debug mode" #endif print *, "hello world!" end program main But the following throws an error: program main implicit none #ifdef DEBUG print *, "I am in debug mode" #endif print *, "hello world!" end program

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

自作多情 提交于 2019-11-28 14:05:33
// 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? You can use cproto or protoize (part of GCC) to generate function prototypes or convert old style (K&R) functions to ANSI format. Since You wanna convert a multiline string, you chould consider perl you have void old_style( c , a ) char c; int a;

Python expected an indented block

左心房为你撑大大i 提交于 2019-11-28 14:03:53
问题 I am a newbie to Python and would like to genereate some numbers according to geometric distribution. i found this code on Internet but isn´t work: import random from math import ceil, log def geometric(p): # p should be in (0.0, 1.0]. if ((p <= 0.0) or (p >=1.0)): raise ValueError("p must be in the interval (0.0, 1.0]") elif p == 1.0: # If p is exactly 1.0, then the only possible generated value is 1. # Recognizing this case early means that we can avoid a log(0.0) later. # The exact

“Expected an indented block” error?

筅森魡賤 提交于 2019-11-28 09:47:24
I can't understand why python gives an "Expected indentation block" error? """ This module prints all the items within a list""" def print_lol(the_list): """ The following for loop iterates over every item in the list and checks whether the list item is another list or not. in case the list item is another list it recalls the function else it prints the ist item""" for each_item in the_list: if isinstance(each_item, list): print_lol(each_item) else: print(each_item) You have to indent the docstring after the function definition there (line 3, 4): def print_lol(the_list): """this doesn't works"

How to write an empty indentation block in Python?

风流意气都作罢 提交于 2019-11-28 09:35:43
The runtime keeps telling me: expected an indented block But I don't want write nothing inside my except block, I just want it to catch and swallow the exception. Just write pass as in try: # Do something illegal. ... except: # Pretend nothing happened. pass EDIT: @swillden brings up a good point, viz., this is a terrible idea in general. You should, at the least, say except TypeError, DivideByZeroError: or whatever kinds of errors you want to handle. Otherwise you can mask bigger problems. I've never done this in more permanent code, but I frequently do it as a placeholder if some_expression:

Hitting Tab in Visual Studio selects block instead of adding indentation

泪湿孤枕 提交于 2019-11-28 09:35:07
I am using Visual Studio 2015 and ReSharper 2016.2 and I have this strange behavior, that I probably activated (accidentally). When having the cursor in a line before the first word, hitting the Tab-key indents the line correctly: When the cursor is inside of any word inside the line, hitting the Tab-key selects the word or block. But the desired behavior would be to indent at the cursor (e.g. split a word into two words, if the cursor was inside of the word Stream after the letter r): Does anyone know how this 'feature' is called? Does it come from ReSharper? Where can it be enabled or