I have the following problem.
I use ubuntu 12.04 and sublime-text-2 or gedit.
Sometimes i copy/paste something in a haml/ruby file, i indent it at 2 spaces, but when i push it up to github, the indentation is all wrong and not only the part I've copy/pasted. In my editor looks good.
If I open the file with LibreOffice/LeafPad the identation is like on github, but i wanna have it working on ST2.
Any suggestions?
To have correct indent across the service you should not use hard tabs
http://opensourcehacker.com/2012/05/13/never-use-hard-tabs/
You can achieve this functionality in Sublime Text 2 with a tab policy setting:
http://opensourcehacker.com/2012/05/11/sublime-text-2-tips-for-python-and-web-developers/#Configure_sane_tab_and_whitespace_policy_and_other_settings
Also not that you might need to choose new policy for existing files from View > Indentation menu.
You can also mass-convert existing files away from tabs.
With Sublime Text 2:
http://opensourcehacker.com/2012/05/11/sublime-text-2-tips-for-python-and-web-developers/#Converting_existing_files_to_use_spaces_instead_of_tabs
... or batch convert the whole project:
http://miohtama.github.com/vvv/tools/expandtabs.html
Related
I was trying to copy from GitHub the following file: https://github.com/vineodd/PIMSim/blob/master/GEM5Simulation/gem5/configs/common/MemConfig.py
I have tried using git clone, downloading directly from the website and also copying and pasting. I have done this in four different text editors: sublime text, atom, textWrangler and Spyder. In Spyder it gives me the following message:
Contains mixed end-of-line characters.
Every time, when I open the file the indentation is wrong in a lot of places, what is a problem because it is a Python file. You can see it for example in the line 280. In GitHub all appears to be fine. Can I do something to fix this? Has this happened to anyone before? Any help would be appreciated. Thanks in advance!
I have already figured it out what was happening here. The file was combining spaces and tabs for indentation. GitHub displays tabs as 8 columns (spaces), but in the text editors it was equivalent to 4 columns. So to fix it I opened a new file where I just wrote a tab. I copied it and used it to replace all tabs for 8 columns.
If you're using intellij/Android studio, you can 'Paste as Plain Text'
I was editing a project, as I have been for months, and randomly only one of my files converted all of its tabs into two spaces. I use "4 spaces" for my tabs, now this one single file decided to become 2 spaces. How can I fix this and convert this file back to 4 spaces? It is only affecting this file, all other files still use 4 spaces.
This thing is just buggy. It is now back to 4 spaces and I have no idea why.
Try going to settings (CTRL+, or CMD+, on Mac) and search for 'detect indentation'.
Play around with that setting as well as with the Tab Size setting. When you're done, go to your file, select all content (CTRL+A or CMD+A on Mac), unindent everything (SHIFT+TAB), then open the command pallete and search for 'Reindent'.
Click the 'Reindent Lines' option and see where it gets you.
Also, check if you have a .vscode folder in your project. It may contain settings that override your global vscode settings.
For my code I'm using Brackets. In editor, code looks proper but after pushing it to github repository, indentations are messed up.
I'm using tab key to make indentation but in preferences there is set "use 2 spaces" after pressing tab key.
I've find out that Github is using 8 spaces for recognised tab keys. But still, it does not give me anything.
The biggest problem is when I use "one var statement".
I've also used jsbeautifier and it doesn't help me at all.
Here you can find an example: My Github code example
Does anybody had such a problem with brackets and github indentations?
Yes I had such problems.
These problems did not reappear when we moved to eslint inside of our IDE. The setup varies for each IDE. You can refer https://eslint.org/docs/rules/indent
If setting eslint is hard for you. Try bracket extensions like https://github.com/brackets-beautify/brackets-beautify . When used correctly it will beautify on save. Caution: Dont beautify code written by others or a team.
I'm using Eclipse for PHP Developers (PDT). Normally I use spaces instead of tab characters for indentation. However, I'm editing someone else's file who indents using tabs and I want to preserve indentation style while editing their file. This is turning out to be difficult because whenever I press the Tab key it inserts spaces. I don't want to change my configuration to use spaces instead of tabs as I'll have to remember change it back. Is there a way I can insert a literal tab character?
I've tried copying a existing tab character in the file yet past results in spaces being inserted!
While I haven't found a way of inserting a literal tab character, with the AnyEdit Tools add-on installed I've found this simple procedure works for me:
Edit the file ignore the whitespace inconsitencies.
Once finished edits, right-click and select Convert > Spaces to Tabs.
Should work the other way round if one was normally used to Tab indentation.
I've followed all the suggestions here.
When I press return, I get a new line that is indented with tabs instead of spaces.
If I backspace to clear the tabs, and then press TAB a series of times, it correctly indents with spaces.
I'm pretty sure I have all my settings set up correctly. I created a new Code Style > Formatter policy for every language in the project, and specified to always use spaces. It seems as though these settings are partially active (ex: when I press tab), but inactive when I use return. I tried restarting Eclipse. I'll try restarting the computer now...
I'm using Mac OS X 10.9.2 and a Liferay Developer Studio (1.6.3.v201312111844) version of Eclipse (not sure which Eclipse build its based on though).
Can anyone think of another setting/solution to ensure that newlines are created with spaces instead of tabs? I recently saw http://editorconfig.org/, and I'm wondering if there's some interference.
Thanks for any suggestions
If the file has existing lines that are using tabs, then Enter will respect that and try to create new lines in a similar way (see this comment by topchef for a solution). Also, it could be something in Liferay Studio's proprietary settings is overriding Eclipse standard preferences (as suggested by user John).
Keep in mind that each type of editor in Eclipse can have its own preferences and perhaps that's what you're running into here. You can try to find them all by opening Preferences and searching for "indent" in the search field. That will show all the preferences pages where indentation can be configured.
Also note that the Formatter settings don't have any affect on as-you-type formatting; that's for when you select a file or group of files or part of a file and choose Source > Format from the menu.