indentation

Avoiding label indenting in C++

[亡魂溺海] 提交于 2019-11-30 00:48:21
问题 I guess this was asked before, but I could not find any similar question. When writing part of the scope operator in C++, Vim guesses that it's going to be a label (on the first : ) and then indents it automatically, which is pretty annoying. Example: #1 - initial typing { std #2 - added : { std: #3 - added : { std:: Of course, it's correct at the end, but is there any way to disable the automatic indent for labels? I rarely use them, and it wouldn't be a great deal to indent manually in

How to avoid namespace content indentation in vim?

跟風遠走 提交于 2019-11-29 23:55:41
How to set vim to not indent namespace content in C++? namespace < identifier > { < statement_list > // Unwanted indentation } Surprisingly, 'cinoptions' doesn't provide a way to edit namespace content indentation. Not sure when it was introduced but my installed version of vim, v7.3.353 has a cino option that handles cpp namespace explicitly. I am currently using the example value: cino=N-s and as per :help cinoptions-values NN Indent inside C++ namespace N characters extra compared to a normal block. (default 0). cino= cino=N-s namespace { namespace { void function(); void function(); } }

Notepad++: disable auto-indent after empty lines

*爱你&永不变心* 提交于 2019-11-29 23:38:25
I find the autoindent style of Notepad++ a little weird: when I am typing on an indented line, I do want it to indent the next line after I press Enter (this it does properly). However, when I am on an empty line (no indentation, no characters) and I press Enter, it indents the next line, using the same indentation as the last non-empty line. I find this extremely annoying; have you ever encountered this problem and do you know how to fix it? (Note: I'm editing HTML/PHP files.) (Also, suggestions of other good free editors for HTML/PHP are welcome, in case there is no way of changing this

How to I configure emacs in java mode so that it doesn't automatically align method parameters

这一生的挚爱 提交于 2019-11-29 20:29:39
In emacs, when I type: public void foo(String one, String two) { It tabifies like this: public void foo(String one, String two) { I'd rather it didn't, and just aligned parameters like other line continuations. How can I configure it not to do this? Chris Jones This comes from the Info manual for Emacs CC Mode, using GNU Emacs 23.1 on Windows: Start building your Java class that's not indenting properly. In your case, exactly what you've typed above. Move your cursor to the start of the line that's not indenting properly. In your case, "String two) {". Hit C-c C-s ( c-show-syntactic

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

放肆的年华 提交于 2019-11-29 19:56:40
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. I want to indent a specific section of code in VSCode: Select the lines you want to indent, use Ctrl + ] to indent them. If you want to format a section (instead of indent it): Select the lines you want to format,

Indent several lines in Emacs

♀尐吖头ヾ 提交于 2019-11-29 19:45:08
In my Emacs, space key can indent correctly 1 line. If I select several lines, and press space key, the indenting does not work. By following this link , I try C-M-\ or C-M-q , but C-M deletes directly the whole block selected. Here is my .emacs , could anyone help? Louis If you want Emacs to correctly indent multiple lines, then the command is C-META \ also known as C-M-\ . In other words, it's not Control - M , but Control - Meta - Backslash ( Control + Alt + \ on most keyboards) Select multiply lines, then type C-u 8 C-x Tab , it will indent the region by 8 spaces. C-u -4 C-x Tab will un

Wanted: Command line HTML5 beautifier [closed]

旧时模样 提交于 2019-11-29 19:42:00
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 make it cooperate and not alter anything ? vim does too little. It only indents. I want the program to

Setting up Vim for Python

白昼怎懂夜的黑 提交于 2019-11-29 18:35:52
I really like the Emacs editor for Python because of it's smart tabbing for instance if I have something like this def foo(): if bar: blah [b]eep and I press tab on the cursor (which is on the b of beep), it will not insert a new tab causing a syntax error but it would toggle through the possible levels that beep can be on. Is there anyway of getting this effect on Vim? mvanveen In general, vim is a very powerful regular language editor (macros extend this but we'll ignore that for now). This is because vim's a thin layer on top of ed, and ed isn't much more than a line editor that speaks

Vim cursor position after expanding html tag

我怕爱的太早我们不能终老 提交于 2019-11-29 18:17:41
问题 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)? 回答1: 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

Python expected an indented block

痴心易碎 提交于 2019-11-29 18:17:00
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 floating point comparison should be fine. log(eps) works just # dandy. return 1 # random() returns a number in