indentation

PHP - indent block of html

↘锁芯ラ 提交于 2019-12-04 09:16:27
Let's say I have the following code: <?php echo "<div id=\"root\">"; echo "<div id=\"child_of_root\">"; echo "<img src=\"picture1.png\">"; echo "<img src=\"picture2.png\">"; echo "<img src=\"picture3.png\">"; echo "<img src=\"picture4.png\">"; echo "<img src=\"picture5.png\">"; echo "</div>"; echo "</div>"; ?> If I ran this the following HTML would be rendered all inline without any line breaks: <div id="root"><div id="child_of_root"><img src="picture1.png"><img src="picture2.png"><img src="picture3.png"><img src="picture4.png"><img src="picture5.png"></div></div> If I ran the following code:

Emacs indentation difficulty

百般思念 提交于 2019-12-04 08:54:30
问题 I'm really trying to switch to emacs, but learning to setup the environment is a real pain. Everybody says it's worth it, so I just continue. I want my c code to be implemented that way: if(asdf) { asdr = 1; } Depending on the current standard (I know, don't get me started), could be: if(asdf) { asdr = 1; } I can't seem to change the indentation size from 2, it always looks like the GNU standard: if(asdf) { asdr = 1; } , which I dislike. Here is what I have put in my .emacs: ; Warn in C for

Vim indentation for c++ templates?

隐身守侯 提交于 2019-12-04 08:42:20
问题 Does anyone have or know about vim plugin/macro/function that indents nicely c++ templates? When I highlight template definition in vim .hpp/.h file and indent it with '=' I get something like this: > template < > class TFilter, > class TParser, > class TConsumer, > class TDataProcessor, > class TDataFeed, > class TSymbolMap > > > struct DataFeedTraits > { > typedef TFilter Filter; > typedef TParser<TSymbolMap> Parser; > typedef TConsumer<Parser> Consumer; > typedef TDataProcessor<Filter

How to auto indent a C++ class with 4 spaces using clang-format?

那年仲夏 提交于 2019-12-04 08:03:43
问题 I got the next .clang-format file in my project's root directory: --- AlignTrailingComments: true AllowShortFunctionsOnASingleLine: false AllowShortIfStatementsOnASingleLine: true AllowShortLoopsOnASingleLine: true BreakBeforeBinaryOperators: false IndentWidth: 4 SortIncludes: false NamespaceIndentation: All ... Problem comes when I run clang-format on my c++ headers, the classes become autoindented like this: As you can see, labels public & private are indented only with 2 spaces. But what I

AutoIndent for JavaScript in Vim that understands Semicolon Insertion

夙愿已清 提交于 2019-12-04 08:03:22
I don't end my JavaScript statements with semicolons when newlines will work. No flames, please. My question is, is there an automatic indentation package for vim that will work? Here is an example of how dumb it is: $(function(){ var foo // code starts here, // The following line breaks things, but adding a comment to it fixes things ({a:1}) var foo // everything is stuck left now. ({a:1}) var foo // previous line justifies all following lines wherever you put it function flat(){ var foo // function starts out right, but the next line dedents it ({a:1}) var foo } var foo // now we're over

How can I make code indentation behave correctly in vbhtml razor files?

邮差的信 提交于 2019-12-04 06:48:35
This is driving me round the bend. I'm a long time VB.NET forms developer, quite new to ASP.NET and completely new to MVC . I'm creating vbhtml pages that use the VB.NET Razor syntax, and I seem to be constantly fighting against the UI which is trying to indent my code incorrectly. Take the following example, based on the template page for a new Razor view: @Code Layout = Nothing End Code <!DOCTYPE html> <html> <head> <title></title> </head> <body> <div> @If True Then @<ul> @For x = 1 To 2 Next </ul> End If '<-- Randomly indented too far </div> </body> </html> In the above example, as soon as

XSLT output formatting: keep line breaks, remove indent

那年仲夏 提交于 2019-12-04 06:34:14
问题 Here's my XML: <doc> <article> <texte> <notes>-</notes> <content> <title>T 1</title> <argument>Arg 1</argument> <p>Paragraph 1.1</p> <p>Paragraph 1.2</p> <p>Paragraph <i>1.3</i></p> <short-author>FB</short-author> </content> <notes>-</notes> <content> <title>T2</title> <p>Paragraph 2.1</p> <short-author>JD</short-author> </content> <notes>-</notes> <content> <title>T3</title> <argument>Arg 3</argument> <p>Paragraph 3.1</p> <short-author>NC</short-author> </content> </texte> </article> </doc>

Converting multiline, indented json to single line using javascript

别等时光非礼了梦想. 提交于 2019-12-04 06:09:48
问题 I've come up with the following function for converting a multiline, nicely indented json to a single line function(text) { var outerRX = /((?:".*?")|(\s|\n|\r)+)/g, innerRX = /^(\s|\n|\r)+$/; return text.replace(outerRX, function($0, $1) { return $1.match(innerRX) ? "" : $1 ; }); } Can anyone come up with something better, both in terms of efficiency and fixing bugs that exist in my implementation (e.g. mine breaks when parsing { "property":"is dangerously spaced out" } or { "property":"is

Indenting Javascript in Vim - Problems with Lambda Functions in Functions

怎甘沉沦 提交于 2019-12-04 05:10:48
问题 I have a problem with javascript indenting in vim. Everything works great, except that the indenting of inline functions as parameters of a function do not work. This is a javascript only problem (no html involed). Example someFunc(function() { if(foo) { bar; } else { bar; } }); is indented to someFunc(function() { if(foo) { bar; } else { bar; } }); Do you have the same problems? How can I fix that? I tried some scripts from vim.org but they seem to have the same problem. A script that

Can Vim display two spaces for indentation, while keeping four spaces in the file?

浪子不回头ぞ 提交于 2019-12-04 00:38:17
I want to work on someone else's project, and he uses 4 spaces for indentation. I use 2, and my screen is not big enough to edit using 4 spaces comfortably. Can I configure Vim to display 2 spaces for indentation, but write 4 to the file? This is the opposite of what was asked here . Yes, you can! If you have the "conceal" option, you can try this out. :syntax match spaces / / conceal cchar= "Don't forget the space after cchar! :set concealcursor=nvi :set conceallevel=1 Here are what these commands do: Set the replacement character for 2 spaces to 1 space Keep text under cursor concealed for