indentation

Pretty-print for shell script

☆樱花仙子☆ 提交于 2019-11-30 15:18:29
问题 I'm looking for something similiar to indent but for (bash) scripts. Console only, no colorizing, etc. Do you know of one ? 回答1: Vim can indent bash scripts. But not reformat them before indenting. Backup your bash script, open it with vim, type gg=GZZ and indent will be corrected. (Note for the impatient: this overwrites the file, so be sure to do that backup!) Though, some bugs with << (expecting EOF as first character on a line) e.g. EDIT: ZZ not ZQ 回答2: A bit late to the party, but it

Pretty-print for shell script

▼魔方 西西 提交于 2019-11-30 14:12:41
I'm looking for something similiar to indent but for (bash) scripts. Console only, no colorizing, etc. Do you know of one ? Benoit Vim can indent bash scripts. But not reformat them before indenting. Backup your bash script, open it with vim, type gg=GZZ and indent will be corrected. (Note for the impatient: this overwrites the file, so be sure to do that backup!) Though, some bugs with << (expecting EOF as first character on a line) e.g. EDIT: ZZ not ZQ A bit late to the party, but it looks like shfmt could do the trick for you. In bash I do this: reindent() { source <(echo "Zibri () {";cat "

Vim cursor position after expanding html tag

断了今生、忘了曾经 提交于 2019-11-30 12:16:01
I most IDEs and modern text editors (Sublime Text 3) the cursor is correctly indented after inserting a newline in between an html tag (aka 'expanding" the tag): Before: <div>|</div> After pressing CR: <div> | </div> But in Vim, this is what I get: <div> |</div> How can I get the same behaviour in Vim like in most other editors (see above)? The only correct behavior of <CR> in insert mode is to break the line at the cursor. What you want is an enhanced behavior and you need to add something to your config to get it: a mapping, a short function or a full fledged plugin. When I started to use

Indenting a bunch of lines in Vim

六月ゝ 毕业季﹏ 提交于 2019-11-30 12:15:21
问题 Is there a way to indent a selection of lines in Vim, like we have in text editors where we select a bunch of lines and press tab (or shift tab) to indent/unindent the selected lines? I am talking about general indentation and not related to code indentation. 回答1: Use visual mode as Peter suggests. You can also use X>> where X is the number of lines you want to indent. E.g. 5>> indents five lines from current line and down. 回答2: You can select a set of lines with visual line mode (via Shift +

Changing indentation settings in the Spyder editor for Python

别说谁变了你拦得住时间么 提交于 2019-11-30 11:51:41
I am using the Spyder editor for Python. I need to change the indentation setting (e.g., let "tab" mean "4 spaces"). How do I accomplish this? Tools >>> Preferences >>> Editor >>> Advanced settings >>> Indentation characters go to >>>Tools in the menu bar Preferences >>> Editor >>> Advanced settings >>> Indentation characters set indentation characters: to "4 spaces" hurray! Mission accomplished 来源: https://stackoverflow.com/questions/36187784/changing-indentation-settings-in-the-spyder-editor-for-python

Is there a way to enforce using tabs instead of spaces?

那年仲夏 提交于 2019-11-30 11:09:46
StyleCop offers to check for consistent use of spaces, but sadly lacks the opposite idea: Force source code to use tabs. Is there some way to add this functionality? It does not have to be StyleCop, other tools are welcome as well. Răzvan Flavius Panda You can use StyleCop+ plugin to enforce usage of tabs. After downloading StyleCopPlus.dll place it in Custom Rules folder inside the main StyleCop folder C:\Program Files (x86)\StyleCop 4.7\Custom Rules or directly in the main folder. Now, when opening a Settings.StyleCop with StyleCopSettingsEditor you will be able to set rule SP2001:

How to get auto indent (not smart indent) in emacs in all modes

◇◆丶佛笑我妖孽 提交于 2019-11-30 09:22:42
I'm new to emacs, and its indenting is driving me up the walls. It's too smart for its own good; it (incorrectly) thinks it knows how I want to format my source, but I don't have time to chase down every setting for every mode for every different language that I write code for; and many of those languages don't have any mode enabled at all. Here's the behaviour I'd like: TAB inserts indent RET inserts a new line then copies the blank characters from the start of the previous line to the first non-blank character, or end of line, whichever comes sooner DEL (backspace key) in the blank text

Check string indentation?

↘锁芯ラ 提交于 2019-11-30 08:50:33
问题 I'm building an analyzer for a series of strings. I need to check how much each line is indented (either by tabs or by spaces). Each line is just a string in a text editor. How do I check by how much a string is indented? Or rather, maybe I could check how much whitespace or \t are before a string, but I'm unsure of how. 回答1: To count the number of spaces at the beginning of a string you could do a comparison between the left stripped (whitespace removed) string and the original: a = "

How to add indention to the stream operator

こ雲淡風輕ζ 提交于 2019-11-30 08:41:01
In our project we use the c++ stream operator (<<) in our object model to print out an easy readible format of the data. A simplified example is this: std::ostream& operator<<(std::ostream & oStream, const OwnClass& iOwnClass) { oStream << "[SomeMember1: " << iOwnClass._ownMember1 << "]\n"; oStream << "[SomeMember2: " << iOwnClass._ownMember2 << "]\n"; } Resulting in this in the logging: [SomeMember1: foo] [SomeMember2: bar] What we want now is to be able to indent the result of that operator. Some calling class might not want the result like this, but want to add 2 spaces indention before

IOS7 UITableView grouped like in Settings App

岁酱吖の 提交于 2019-11-30 08:13:22
In IOS7 the UITableView does not have indentation anymore when using style=grouped. How can enable the indentation, so that the UITableView behaves like the settings app from apple? There is a much simpler way to achieve this. Place your UITableView away from the sides. eg: using Autolayout you'd have a leading and trailing space of 15px (or whatever you want). You're now creating the 'indentation' that Apple used to give you for free with grouped table views. Adjust the layer to add corners and a border. [[[self tableView] layer] setCornerRadius:5.0f]; [[[self tableView] layer] setBorderWidth