indentation

Why does vim not obey my expandtab in python files?

ⅰ亾dé卋堺 提交于 2019-11-27 01:08:17
After I installed Vundle, my vim no longer obeys the expandtab settings I had. My tabs were set to 2 spaces, but now in python files it no longer does that. The problem is being called by this line: filetype plugin on What does this line do (It is required by vundle)? Also, what can I do to make sure my settings are obeyed? Thanks! VIMRC: pastebin.com/tGmfCi78 John Szakmeister The problem is that your settings are being overridden by a filetype plugin that's part of Vim. The issue is in ftplugin/python.vim : " As suggested by PEP8. setlocal expandtab shiftwidth=4 softtabstop=4 tabstop=8 The

Visual Studio, per solution indentation settings

回眸只為那壹抹淺笑 提交于 2019-11-27 00:55:42
问题 I'm working on a couple of different things and some use tabs, some use 2 spaces for indents, another users 4 spaces for indents etc. The option to set this in Visual Studio is in Tools->Options->Text Editor-><language>->Tabs Is there some way to override these settings on a per solution bases? 回答1: Here is one (admittedly hacky) way to achieve what you are looking for: 1) create a macro that changes the indentation (source) Sub Set-Indent(indent As integer) Dim props As EnvDTE.Properties =

How do I correctly organize output into columns?

孤者浪人 提交于 2019-11-27 00:55:25
问题 The first thing that comes to my mind is to do a bunch of \t's, but that would cause words to be misaligned if any word is longer than any other word by a few characters. For example, I would like to have something like: Name Last Name Middle initial Bob Jones M Joe ReallyLongLastName T Instead, by including only "\t"'s in my cout statement I can only manage to get Name Last Name Middle initial Bob Jones M Joe ReallyLongLastName T or Name Last Name Middle initial Bob Jones M Joe

Conditional with statement in Python

穿精又带淫゛_ 提交于 2019-11-27 00:41:30
问题 Is there a way to begin a block of code with a with statement, but conditionally? Something like: if needs_with(): with get_stuff() as gs: # do nearly the same large block of stuff, # involving gs or not, depending on needs_with() To clarify, one scenario would have a block encased in the with statement, while another possibility would be the same block, but not encased (i.e., as if it wasn't indented) Initial experiments of course give indentation errors.. 回答1: If you want to avoid

Vim automatically removes indentation on Python comments [duplicate]

拈花ヽ惹草 提交于 2019-11-27 00:05:18
问题 This question already has an answer here: How to configure vim to not put comments at the beginning of lines while editing python files 8 answers I'm using Vim and editing Python scripts. Autoindent works pretty well in general, but when I start a new line and type '#' to type a comment, Vim unindents that line for me. For example, if have def foo(): and I press enter, Vim will indent properly def foo(): pass but, if instead of typing pass , I type # , it unindents automatically def foo(): #

Emacs C++-mode incorrect indentation?

霸气de小男生 提交于 2019-11-26 23:59:21
问题 I'm running emacs 23 with c++-mode and having some indentation problems. Suppose I have this code: void foo() { if (cond) { <--- int i; ... } <--- } This seems to be the default behavior of the automatic indentation. However I'd like to change it so it'll be like this: void foo() { if (cond) { int i; ... } } Is there a way to do this easily by configuring c++ mode or my .emacs file? 回答1: I have the following in my .emacs file: (defun my-c++-mode-hook () (setq c-basic-offset 4) (c-set-offset

How to automatically indent source code?

↘锁芯ラ 提交于 2019-11-26 23:57:15
问题 How can I automatically indent source code in Visual Studio 2010? I have used Ctrl + K , Ctrl + F , but it does not work; is there any other way/plugin to do this? 回答1: Ctrl + E , D - Format whole doc Ctrl + K , Ctrl + F - Format selection Also available in the menu via Edit|Advanced . Thomas Edit- Ctrl + K , Ctrl + D - Format whole doc in VS 2010 回答2: In 2010 it is Ctrl + k , Ctrl + d . See image below. 回答3: In Visual Studio 2010 Ctrl + k + d indent the complete page. Ctrl + k + f indent the

Auto-indent in Notepad++

断了今生、忘了曾经 提交于 2019-11-26 23:44:52
We always write code like this formal: void main(){ if(){ if() } But when I use Notepad++ , the display is: void main(){ if(){ if() } How do I use Notepad++ to auto indent? Thanks to Jonathan , I have set it, but it does not take any effect. The snapshot is below: I am using Notepad++ version 5.1.3. Notepad++ will only auto-insert subsequent indents if you manually indent the first line in a block; otherwise you can re-indent your code after the fact using TextFX > TextFX Edit > Reindent C++ code . If the TextFX menu does not exist, you need to download & install the plugin. Plugins->Plugin

JavaScript error (Uncaught SyntaxError: Unexpected end of input)

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-26 23:33:34
I have some JavaScript code that works in FireFox but not in Chrome or IE. In the Chrome JS Console I get the follow error: "Uncaught SyntaxError: Unexpected end of input". The JavaScript code I am using is: <script> $(function() { $("#mewlyDiagnosed").hover(function() { $("#mewlyDiagnosed").animate({'height': '237px', 'top': "-75px"}); }, function() { $("#mewlyDiagnosed").animate({'height': '162px', 'top': "0px"}); }); </script> It says the error is on the last line which is }); Add a second }); . When properly indented, your code reads $(function() { $("#mewlyDiagnosed").hover(function() { $

Tab Error in Python

ぃ、小莉子 提交于 2019-11-26 22:11:31
问题 The following python code throws this error message, and I can't tell why, my tabs seem to be in line: File "test.py", line 12 pass ^ TabError: inconsistent use of tabs and spaces in indentation My code: class eightPuzzle(StateSpace): StateSpace.n = 0 def __init__(self, action, gval, state, parent = None): StateSpace.__init__(self, action, gval, parent) self.state = state def successors(self) : pass 回答1: You cannot mix tabs and spaces, according the PEP8 styleguide: Spaces are the preferred