indentation

Code Folding for CSS in VSCode

拈花ヽ惹草 提交于 2019-12-05 22:25:35
I can't get code folding to work in the editor in Css. In both html and js I can fold code according to comments, which enables me to create neat groups. But in Css you can't fold comments. Does anyone know of a way to enable this or another nice tip for creating groups of code in a Css file? Here are some pictures. Here you can see there is not minus button next to the Own Classes comment: But here you can see the comments fold nicely in js, this enables me to create nice groups of code: See the docs to read about code folding in VS Code: Since the 1.22 release, folding ranges can also be

Parsing python with PLY, how to code the indent and dedent part

北慕城南 提交于 2019-12-05 17:57:47
I was trying to parse the function definition for the python language with PLY. I am encountering issues related to the indentation. For instance for a for statement, I would like to be able to know when the block ends. I read the python grammar here: http://docs.python.org/2/reference/grammar.html And the grammar for this part is: for_stmt: 'for' exprlist 'in' testlist ':' suite ['else' ':' suite] suite: simple_stmt | NEWLINE INDENT stmt+ DEDENT I don't know how to describe the INDENT and DEDENT tokens with PLY. I was trying something like: def t_indentation(t): r' |\t' #some special

Tidying PHP and HTML Code?

老子叫甜甜 提交于 2019-12-05 16:27:21
I wonder if anyone could please help me I have been using HTML tidy and eclipses built-in function to tidy up my code. I am having great trouble with the following situations... when HTML is split between files via includes, having result structured with correct indentations helps with debugging via browser tools. PHP and HTML when used together. for example PHP if statements around HTML code where you wont the correct indentation for both the PHP and HTML. (automating this How to properly indent PHP/HTML mixed code? ) Situation one i can live with and there are ways around it. However, I

Making a region-indent-function keep the region marked

馋奶兔 提交于 2019-12-05 13:22:48
I'm having trouble with haml-mode's region-indent-function , which I'm trying to reuse in another major mode. We're supposed to be able to cycle the region indentation by keeping the region marked after the haml-indent-region is being evaled, but it doesn't work as intended. After some hacking around, I've found out that throwing an error at the end of the function makes Emacs keep the region marked, as in this example: (defun haml-indent-region (start end) (save-excursion ...) (error "")) ;; Terrible hack But I really don't like it. Is there a clean way of getting this behavior without such

Generating an indented string for a single line of text

随声附和 提交于 2019-12-05 11:43:58
What is the best way to generate an indented line from space characters. I mean something similar to this: string indent = String.Join(" ", new String[indentlevel]); s.Write(indent + "My line of text"); You can create your indention with this: var indent = new string(' ', indentLevel * IndentSize); IndentSize would be a constant with value 4 or 8. eandersson I would probably do something like this to add Indent . public static string Indent(int count) { return "".PadLeft(count); } To use it you can do the following: Indent(4) + "My Random Text" In your application you could simply do: s.Write

How to save XmlDocument with multiple indentation settings?

我怕爱的太早我们不能终老 提交于 2019-12-05 10:13:19
I need to save one XmlDocument to file with proper indentation (Formatting.Indented) but some nodes with their children have to be in one line (Formatting.None) . How to achieve that since XmlTextWriter accept setting for a whole document? Edit after @Ahmad Mageed's resposne: I didn't know that XmlTextWriter settings can be modified during writing. That's good news. Right now I'm saving xmlDocument (which is already filled with nodes, to be specific it is .xaml page) this way: XmlTextWriter writer = new XmlTextWriter(filePath, Encoding.UTF8); writer.Formatting = Formatting.Indented;

Keeping code structure with string literal that uses whitespace

安稳与你 提交于 2019-12-05 09:14:56
问题 So a bit of a weird question I was having trouble coming up with the search terms for. If I have a multi-line string literal in my program, is there anyway to keep the indentation of my code consistent without adding unwanted white space to my string literal? Ex: if (true) { if (!false) { //Some indented code; stringLiteral = string.format( @"This is a really long string literal I don't want it to have whitespace at the beginning of each line, so I have to break the indentation of my program

Properly indent KnockoutJS virtual elements

♀尐吖头ヾ 提交于 2019-12-05 08:39:00
I just started work on a large KnockoutJS code base in a Visual Studio MVC project. Everything so far seems fairly straightforward except the virtual elements. I understand the need and it is fairly nifty. However because the virtual elements are comments then indentation is all messed up which makes it a terrible pain to read. Is it possible to convert these to an actual html element or to get Visual Studio/Resharper to indent them correctly? For instance I have some code like the following which is all at the same indentation level. <!-- ko with: Home --> <!-- ko with: Model --> <!-- ko

Sublime Text 3 Deleting Code when I hit Tab Key

别来无恙 提交于 2019-12-05 08:22:38
问题 When I highlight a block of code in Sublime Text 3 and press the Tab key, it doesn't indent the whole block like it used to. Instead, it deletes the highlighted code. Anybody know how to fix this? 回答1: This is a simple alt-tab issue I have found that this happens when I've missed the "purchase this software" dialogue and have not dismissed it. Alt-tab (or Cmd-tab on Mac) to check if there is a dialog waiting for a response and dismiss it. This will fix the problem. 回答2: For anyone else who

Emacs indentation for html (web-mode) doesn't work properly

≯℡__Kan透↙ 提交于 2019-12-05 06:12:04
I'm using web-mode in Emacs to get syntax highlighting and indentation for PHP and HTML. If I have this code in a .php file <p> Lorem ipsum dolor sit amet, consectetur adipiscing elit. </p> And then put the cursor on the middle line and press tab then nothing happens. I want it to look like this: <p> Lorem ipsum dolor sit amet, consectetur adipiscing elit. </p> If I put the text in a tag on a single line and try to indent, it works. This: <p> <a>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</a> </p> turns into this, which it should <p> <a>Lorem ipsum dolor sit amet, consectetur