Xcode indentation settings for Swift vs. Objective C - swift

I have a project with a large codebase, where newer modules are being added in Swift 3, but most of the code is in Objective C. Like many projects, our Swift style uses 2 spaces for indentation. The legacy Objective C codebase, however, uses 4 spaces.
Is there any way in Xcode 8+ to configure indentation on a per file type basis? If not, is there a better alternative to:
Converting all Objective C files to use two spaces.
Impose the Objective C 4 space style on Swift code due to Xcode limitations.
Both of the above seem like bad ideas, but without Xcode support for per file type configuration, there seems to be no other way.

To answer your question of:
Is there any way in Xcode 8+ to configure indentation on a per file type basis?
Yes, there is. On the File Inspector of each file, you can set the Indent type to Spaces or Tab and also the number of spaces.
I have attached the screenshot here:
You can select multiple file and update the settings at the same time. The settings here will overwrite what you have set in the Preferences > Text Editing > Indentation.

Related

Ignore files when calculating Code Coverage in Xcode [duplicate]

I have enabled code coverage statistics in Xcode 7.0 and Objective C (like this) and it's working well.
Is it possible to mark some source lines so that they are ignored by the coverage report? If I was using lcov then I could use LCOV_EXCL_START and LCOV_EXCL_END markers (as in How to tell lcov to ignore lines in the source files) but Xcode doesn't recognize those.
Does Xcode have an alternative mechanism for doing this?
Xcode7 and later (based on some forum posts), the coverage system uses LLVM's coverage generation and reporting mechanisms, the format for which is detailed at http://llvm.org/docs/CoverageMappingFormat.html. As of Xcode 9, this format does not support any means of exclusion of lines (or other structures).
The resulting mapping is exported into a consumable format (txt or html) by llvm-cov, which also doesn't really have much in the way of exclusion mechanisms. llvm-cov does have some simple thresholding for only reporting on "greater than" or "less than" coverage for both lines and regions, but I suspect that's not entirely what you're after based on the question above.

Notepad++ and autocompletion

I'm using mainly Notepad++ for my C++ developing and recently i'm in need for some kind of basic autocompletion, nothing fuzzy, just want to type some letters and get my function declaration instead of having a manual opened all of the time..
The integrated autocompletion feature of my Notepad++ version (6.9.2) gives the declaration of basic C functionality like say fopen and parses my current file user defined functions, but without declaration.
I guess it's normal for a text editor to not give easily such information since it has nothing to parse i.e. other files where your declarations are (as it's not an IDE), but i don't want either to mess again with MSVC just for the sake of autocomplete.
Is there an easy, not so-hackish way to add some basic C++ and/or user defined autocomplete?
UPDATE
Adding declarations the "hard way" in some file cpp.xml is a no-no for me as i have a pretty big base of ever changing declarations. Is there a way to just input say some list of h/cpp files and get declarations? or this falls into custom plugin area ?
Edit the cpp.xml file and add all the keywords and function descriptions you'd like. Just make sure you add them in alphabetical order or they will not show up.
Another option is to select Function and word completion in the Auto-Completion area of the Settings-->Preferences dialog. NPP will suggest every "word" in the current file that starts with the first N letters you type (you choose a value for N in the Auto-Completion controls).

Highlighting line which are not correctly formated [Eclipse]

So I have some formatting rule to follow, such as :
Space on each side of operator (*, =, +, %, etc)
No space at the end of a line
No more than 80 chars per line
Is there a way to highlight in red line containing formating error?
The eclipse auto-formating tool is no good because either :
It will change to many line (old code not written by me)
or it won't (only my code)
Because I must follow some "colorfull" guideline :
You must change formating error relative to operators in old code but nothing else
Your code must be correctly formated.
Any ideas?
Thanks
You can select which lines of code you want to format. The Eclipse formatting tool doesn't have to run across the entire file. To do this: select the lines you want to format, then press Ctrl-Shift-F.
You could try using the Eclipse Checkstyle Plugin.
You'll need to configure it with just the rules that you need (the default configuration is very strict, so create a new one with just the rules you care about).
This will highlight all lines with formatting issues. I don't think it's possible to ignore old code using the plugin.
Talk to whoever created that coding guideline. It does not make sense in the long run, because editing code in Eclipse will always apply all current formatting rules (which violates that guideline) or none, if you disable the formatter (which leads to you writing bad code).
If there is really no way around that guideline, then you should split your workflow into 2 phases: Reformat all existing code one time to fulfill that operator guideline. You may use any tool you like, even just a regular expression search and replace might be fine.
After that has been done, configure Eclipse to auto-format only changed lines, but always apply all formattings to each changed line. There is no good reason to not re-format the other 75 characters in an existing line of code, if you already touched 5 characters of it.

Change number of spaces for soft tabs in vim depending on extension

So I started learning Scala today and I got all my vim config files working for Scala syntax highlighting and such, but the files I downloaded (http://lorenzod8n.wordpress.com/2008/01/11/getting-scala-syntax-hightlighting-to-work-in-vim/) did not seem to include the apparent Scala convention of indent by 2 spaces.
Since for my job I mostly work in C++ and Python, I currently have my set tabstop=4.
I've been trying to figure out how to use the if/endif statements for .vimrc files to do set tabstop=2 if the extension if *.scala, otherwise use tabstop=4 but not having much luck.. help?
Thanks!
-kshot
set tabstop=4
au BufNewFile,BufRead *.scala set tabstop=2

Advice moving from Eclipse to Xcode

To Xcode xPerts:
I have been doing Java in Eclipse for about 9 years now and I have really gotten used to the power of the refactoring tools. There are a few operations I do all the time. I am looking for equivalents in Xcode since it has better support for objective-c than eclipse. (I'm not at my Mac as I write this. So some of this is from memory. I am still very new to Xcode.)
1 "rename".
It seems that the Xcode equivalent for variables is "edit all in scope". Does this work for files/classes/methods too?
2 "extract local variable"
select an expression it creates a local var initialized to that expression. It even creates a usable name for the variable.
3 "extract method"
select some code and it will create a method with that code and appropriate parameters/return value.
4 "inline" (variable or method)
opposite of extract, inlines all or just the selected occurrence of the selected var or method.
5 "find next"
occurrence of selected text. In eclipse I can select some text and hit ctrl-k to go to the next occurrence of that in the file. likewise shift-ctrl-k finds backwards. IIRC the Xcode "find next" ignores the selection and only uses what is in the find box.
6 "change method signature"
This would be very useful with ocjective-c's named parameter messaging syntax. This is great for adding parameters to a method.
7 "pull-up/push-down"
for moving methods up or down the class hierarchy.
8 "move"
for moving elements around to other classes etc.
Those are the ones that I use all of the time. I have estimated that these tools cut my coding time in half. Are any of these supported in Xcode?
Thanks in advance for any advice.
You can read the Xcode user documentation on Refactoring on any machine. It will answer most of these questions.
For #1, if you right click a symbol name, you should have the Refactor menu option that permits you to rename the ivar, property, type name (including file names), etc.
Yep, right-click on a symbol then select Refactor.
There doesn't appear to be a "change method signature". I've used that feature for years in other IDEs. I guess the only thing to do in xcode is change the signature and hope that you get a compile error for everything that needs changing...not a great refactoring tool.
Xcode look slick in many ways, but there are some annoying omissions (anyone want to view the content of collections in the debugger?)