indentation

Keeping code structure with string literal that uses whitespace

心不动则不痛 提交于 2019-12-03 22:16:47
So a bit of a weird question I was having trouble coming up with the search terms for. If I have a multi-line string literal in my program, is there anyway to keep the indentation of my code consistent without adding unwanted white space to my string literal? Ex: if (true) { if (!false) { //Some indented code; stringLiteral = string.format( @"This is a really long string literal I don't want it to have whitespace at the beginning of each line, so I have to break the indentation of my program I also have vars here {0} {1} {2}", var1, var2, var3); } } It's probably just my OCD talking, but is

How to indent XML properly using XMLSerializer?

六眼飞鱼酱① 提交于 2019-12-03 17:12:54
问题 I'm having a hard time trying to indent XML files using XMLSerializer . I've tried serializer.setFeature("http://xmlpull.org/v1/doc/features.html#indent-output", true); I've tried to append \n into FileWriter but the output is the \n 's and \t 's at the beginning of the file and not in the right place. I've tried setPropery with the proper URI etc. Part of the code: XmlPullParserFactory parserFactory = XmlPullParserFactory.newInstance(); parserFactory .setNamespaceAware(true); XmlSerializer

How to indent a selection in gVim (Win32)

妖精的绣舞 提交于 2019-12-03 15:39:08
问题 I'd like to indent a block of text . I am able to do this in the Linux build of gVim. I do this in the state of gVim where I'm not in the insert or visual mode. The bar at the bottom is blank on the left, and the line number and percentage are showing on the right hand side. Then I perform the following procedure : I select a block of text via click and drag. Then I hit Shift + . . After that, I hit Esc and the block of text will move over a tab. If I do this in Windows however, it just

How to disable vim's indentation of switch case?

爷,独闯天下 提交于 2019-12-03 15:08:19
问题 I'm currently fighting with Vim, I can't seem to make the indentation options do what I want. Here are my settings, I put them at the bottom of .vimrc to make sure they take precedence. As you can see I'm going a little crazy, so I tried turning off almost everything: set cindent set cinkeys=o,O set cinoptions= set cinwords= set indentexpr= In most cases it seems to work fine, it does one indent after opening a block and everything is fine. But there is one case that is driving me crazy, when

Why is vim indenting my Perl code incorrectly?

孤街醉人 提交于 2019-12-03 14:27:46
I have a subroutine in Perl that should be indented like this: sub GetFiles { my $pwd = shift; my @input = @_; my @returned; my @DirectoryContent = &GetContentInformation(@input); foreach (@DirectoryContent) { my %current = %{$_}; if ($current{'info'} =~ /<DIR>/) { my $RecurseDir = &GetRecurseDir($pwd, \%current); push(@returned, &GetFiles($RecurseDir, &GetDirectoryContents($RecurseDir))); } else { # clean up the data my $size = $current{'info'}; # filesize will be in number of bytes # remove file separators #$size =~ s/,//g; my $extension = &GetFileExtension($current{'name'}); delete($current

multi lines python indentation on emacs

我的未来我决定 提交于 2019-12-03 14:10:55
问题 Im an emacs newbie, I want emacs to be able to indent my code like this egg = spam.foooooo('vivivivivivivivivi')\ .foooooo('emacs', 'emacs', 'emacs', 'emacs') It's not possible to do this automatically by default (without manually inserting spaces or C-c >), since emacs always indents 4 spaces (unless Im splitting multiple arguments over multiple lines). Whats the best approach to do this? PS: If this is a bad idea (against PEP 8 or something) please do tell me 回答1: I agree with Aaron about

How to auto format code indentations in VS2012? [closed]

混江龙づ霸主 提交于 2019-12-03 13:33:40
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . How to auto format code in VS2012 to save time typing and deleting spaces and tabs? 回答1: If you are looking to format the code as you enter the text, there are some additional settings in Tools\Options\Text Editor area. Since your example appears to be a config file (XML) look at the XML editor. Otherwise, to

How to change indentation in text-mode for emacs

爱⌒轻易说出口 提交于 2019-12-03 13:07:58
I'm in text mode and want my tab key to indent a line to two spaces. The file looks like this: Line one Line two The cursor is situated before the 'L' : "Line two", and I hit TAB and it gets indented 6 spaces as opposed to the desired 2 spaces. Actions I've tried: I've tried updating the variable: tab-stop-list (setq tab-stop-list '(2 4 6 8 10 12 14 16)) I've tried adding a text-mode-hook (add-hook 'text-mode-hook '(lambda () (setq tab-width 2))) Jérôme Radix Add this to your .emacs : (add-hook 'text-mode-hook '(lambda () (setq indent-tabs-mode nil) (setq tab-width 2) (setq indent-line

Auto indent doesn't work when using vim coding python

喜夏-厌秋 提交于 2019-12-03 12:50:36
I want to use vim to write python code but there is a problem on auto indention. First I downloaded the latest python.vim from http://www.vim.org/scripts/script.php?script_id=790 and putted it in the correct dir. Then I edited my vimrc. syntax on set nu set tabstop=4 set softtabstop=4 set shiftwidth=4 "set cindent set autoindent set smartindent set expandtab set filetype=python au BufNewFile,BufRead *.py,*.pyw setf python Now I find that keywords like 'for', 'if', 'while' can autoindent perfectly. But it doesn't work on 'def', 'try', 'except'. What should I do? Thank you very much. I have this

emacs: different indentation for class and struct

↘锁芯ラ 提交于 2019-12-03 12:25:55
问题 I'm trying to achieve the following indentation in emacs: class A { // I ALWAYS use access labels in classes public: // access-label int member; // inclass }; struct B { // I NEVER use access labels in structs int member; // inclass }; However with the following configuration file... (defun my-cpp-mode () "My C++ mode" (c++-mode) (c-set-style "K&R") (setq c-basic-offset 4) (c-set-offset 'access-label '-) (c-set-offset 'inclass '++) ;; ... (setq mode-name "My C++") ) (add-to-list 'auto-mode