indentation

“unexpected indent” error when using notepad++ for creating django function

帅比萌擦擦* 提交于 2020-01-01 04:18:27
问题 I am following this book to learn django using notepad++, something interesting happens, when I type the function using notepad++ for the following script: def current_datetime(request): now = datetime.datetime.now() html = "<html><body>It is now %s.</body></html>" % now return HttpResponse(html) It gives me an error like this: IndentationError at /time/ ('unexpected indent', ('M:\\DjangoStack\\projects\\beta_01\\..\\beta_01\\hello_world\\views.py', 12, 1, '\thtml = "<html>"\n')) But when I

indent python file (with pydev) in eclipse

只愿长相守 提交于 2020-01-01 04:11:06
问题 I'm a newbie in eclipse. I want to indent all the lines of my code and formatting the open file by pressing a shortcut or something like that... I know the CTRL+SHIFT+F (as it actually doesn't work in pydev!!) I've been searching for hours with no success. Is there any way to do that in eclipse. kind of like CTRL+K,D in visual studio, which formats and indents all the source code lines automatically? 回答1: I ... don't think this question makes sense. Indentation is syntax in Python. It doesn't

Indentation Error with Sublime Text

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-31 12:08:13
问题 I'm trying to use the auto-indentation feature in Sublime Text 3 for HTML. I've got some block comments in the html and selecting Edit>Line>Reindent works until it hits a block comment. Try to reindent the example here: <html> <head> <title>Testing Indent</title> </head> <body> <table> <tr> <td> Cell 1 </td> </tr> <tr> Cell 2 <!--Block Comment Here And a Little More Here --> </tr> </table> </body> </html> and it turns out like this: <html> <head> <title>Testing Indent</title> </head> <body>

VS Code indentation for Python

元气小坏坏 提交于 2019-12-29 06:49:28
问题 How do I enable indentation in VS Code? I'm trying to learn Python (newbie in programming) and need auto-indentation. It worked with the first version I tried, but it doesn't indent after a colon ( : ) anymore. How can I configure it to automatically indent? 回答1: You can install VSCode python extension which will provide intellisense, auto-completion, code formatting, and debugging. Here is more information on the python extension, here 回答2: As said there is the python extension which now do

Can CPP preprocessing statement in Fortran be indented?

风流意气都作罢 提交于 2019-12-29 01:47:07
问题 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

How to preserve whitespace indentation of text enclosed in HTML <pre> tags excluding the current indentation level of the <pre> tag in the document?

陌路散爱 提交于 2019-12-28 05:16:26
问题 I'm trying to display my code on a website but I'm having problems preserving the whitespace indentation correctly. For instance given the following snippet: <html> <body> Here is my code: <pre> def some_funtion return 'Hello, World!' end </pre> <body> </html> This is displayed in the browser as: Here is my code: def some_funtion return 'Hello, World!' end When I would like it displayed as: Here is my code: def some_funtion return 'Hello, World!' end The difference is that that current

Tab key == 4 spaces and auto-indent after curly braces in Vim

佐手、 提交于 2019-12-27 16:09:06
问题 How do I make vi-Vim never use tabs (converting spaces to tabs, bad!), makes the tab key == 4 spaces, and automatically indent code after curly brace blocks like Emacs does? Also, how do I save these settings so I never have to input them again? I've seen other questions related to this, but it always seems to be a little off from what I want. 回答1: As has been pointed out in a couple of answers below, the preferred method now is NOT to use smartindent, but instead use the following (in your

Tab key == 4 spaces and auto-indent after curly braces in Vim

随声附和 提交于 2019-12-27 16:08:07
问题 How do I make vi-Vim never use tabs (converting spaces to tabs, bad!), makes the tab key == 4 spaces, and automatically indent code after curly brace blocks like Emacs does? Also, how do I save these settings so I never have to input them again? I've seen other questions related to this, but it always seems to be a little off from what I want. 回答1: As has been pointed out in a couple of answers below, the preferred method now is NOT to use smartindent, but instead use the following (in your

Java: How to Indent XML Generated by Transformer

人走茶凉 提交于 2019-12-27 11:38:57
问题 I'm using Java's built in XML transformer to take a DOM document and print out the resulting XML. The problem is that it isn't indenting the text at all despite having set the parameter "indent" explicitly. sample code public class TestXML { public static void main(String args[]) throws Exception { ByteArrayOutputStream s; Document d = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument(); Transformer t = TransformerFactory.newInstance().newTransformer(); Element a,b; a = d

How to fix inconsistent indentation of a project in Sublime Text 3?

家住魔仙堡 提交于 2019-12-24 20:15:42
问题 I notice one of the file in my PHP Laravel project kept showing weird lines indetation in my Sublime Text 3. Both file in the same project, but I am not sure one show a lot more line than other. Is there a way to fix this in Sublime? Is there a way to fix the file indentation? 回答1: In situations where files don't seem to have the indentation that you would expect them to have based on your settings, the culprit is generally this setting: // Set to false to disable detection of tabs vs. spaces