I keep running across a problem where source code that uses tabs to line up key/value assignments is displayed differently in different editors.
For instance, a file on Github in both the highlighted and raw versions shows the $labels array at line 55 with mis-aligned spacing. It also looks that way in Notepad.
But, that same file, copied into Aptana or Notepad++ will display the values lined up perfectly.
Why does that happen, and is it possible to create the file in such a way that it will be displayed correctly across all editors?
Depending on your settings in each editor, they will each use a different number of spaces for a tab.
Some use 2, some use 3, some use 4, and some use 6. You can see by highlighting one of the tabs in github, the tab takes up 8 spaces.
This should be adjustable in the editor.
If you create a file in an editor that uses a particular number of spaces, and view it in an editor that uses a different number of spaces, things will look different.
There has always been a debate about whether to use spaces or tabs for indentation. It's a personal preference thing, but using spaces rather than tabs will prevent this issue.
You should be able to set your editor to use spaces instead of tabs.
Related
I have this weird bar that shows up on some of the pages that I am working on in PhpStorm that is really annoying, as it often blocks what I am trying to work on. I can't move it or remove it. Does anyone know what it is and how to get rid of it?
This floating toolbar appears in Markdown files (not sure about any other file types, at very least I see it only there).
I see 3 icons only (in current stable PhpStorm 2022.2.3 version), which may depend on the features used (e.g. I have Diagrams plugin disabled):
Text only mode
Split mode: text + rendered preview
Rendered mode only (HTML preview)
https://www.jetbrains.com/help/phpstorm/markdown.html#preview
The other 2 icons visible on your screen MIGHT be for:
Visualizing diagrams for the Mermaid and PlantUML languages (I do not have them in any of my files so cannot check it. But it should be that).
https://www.jetbrains.com/help/phpstorm/markdown.html#diagrams
Pandoc Converter for HTML, Microsoft Word, and PDF formats (not using it myself).
https://www.jetbrains.com/help/phpstorm/markdown.html#convert-markdown-files
...it often blocks what I am trying to work on. I can't move it or remove it. Does anyone know what it is and how to get rid of it?
It is displayed in the top right corner where it is hard to cover anything.
I see no options anywhere to remove it. But you can "convert" it into the permanently visible toolbar instead if you prefer:
Help | Find Action...
Type registry to locate and invoke Registry... entry.
Once in the Registry, locate ide.text.editor.with.preview.show.floating.toolbar entry there (just start typing, the speed search works there)
Disable it (make sure it's saved) and restart the IDE. Now it will look like this (a fixed bar instead of "annoying floating" one):
what is the correct way to view and edit tab-delimited text files in emacs, as if they were a spreadsheet?
if I write tsv files in emacs by using C-q TAB, it has the annoying quirk that tabs are not equispaced. It would be nice to be able to edit cells and have emacs automatically realign it so that it appears in a column, similar to table modes. However, I do not want to make a table, I just want to edit a tsv file. I do not see how this can be done with org-mode. Is there a built in mode for this?
for example using org-mode, I can make the tabs appear equispaced, but emacs does not automatically realign the columns when one of the cells gets more text in it. what is the right way to do this?
You can use csv-mode, available from GNU ELPA. It supports both comma-separated and TAB-separated format, and is able to properly align columns. Note that the columns won't be automatically resized on-the-fly, instead you'll have to ask Emacs explicitly to re-align columns after you've edited them.
Tabs are converted to column breaks when pasted into most spreadsheet programs... but not when those tabs are copied from a web browser. What's going on here?
Steps to reproduce:
Copy some tab-delimited data (example) from a browser into your clipboard
Open a Google Sheet
Click once on any cell
Paste the contents of your clipboard
Expected result:
The tabs are converted to column breaks. Pieces of text that were separated by tabs now reside in their own cells.
Actual results:
The tabs are not converted to column breaks. All text is pasted into one cell.
However... and this is where things get weird... if the tab-delimited data is first copied into a textarea (example), and then that same tab-delimited data is copied from the textarea into a Google Sheet, the tabs are converted to column breaks as expected.
Very strange indeed. Can anyone offer insight into why this happens?
Insight, yes. An explanation of why this feature has been broken for years, even with the "New Sheets"? Sorry, no.
The tab-delimited text from the pastebin example appears in the Windows clipboard like this, in "49407: HTML Format":
Contrast this with the text copied from a textarea (or a text editor; I tried the same with wordpad), which is plain "1: CF_TEXT" format:
Since there is no option to "paste as plain text" into Sheets, the HTML version of the clipboard is used (when there is one). That's nice if the HTML includes formatting that might be retained - but isn't so handy in this case.
I have a SCSS file I am currently working on. The indentation is 4 spaces, but for some reason PHPStorm only moves the cursor 2 spaces every time I tab. Is there a way to change this? Strange thing is I have other files in the project (mostly JS) and they are tabbed 4 spaces.
Settings/Preferences
Editor | Code Style
Now select your desired language (as it's configured on per language basis) and check the option on the "Tabs and Indents" tab.
If you are using the actual Tab symbol for intents then you will see the changes straight away. But if you use Space then you will need to invoke Code | Reformat Code (or similar Code | Reformat File...) to see the changes in the indents.
In case if you have changed the settings in Code Style but still see the old/different settings being applied: check if you have .editorconfig file(s) in your project and EditorConfig is enabled (by default).
The settings from such a file will overwrite your Code Style settings (it's expected as it's the nature of such files). In this case you will need to edit your .editorconfig file (or disable EditorConfig integration).
P.S. I prefer setting the basic settings (like indent size, indent symbol etc) in the .editorconfig file. It's portable, flexible, and allows setting up different settings for files that do not have dedicated Code Style settings in the IDE.
After applying the settings, the tab will not apply right away. For this to work you have to Code -> Reformat Code
You can set the tab and indent for each language you code in.
Basically, I have a stylesheet I need to add to a LOT of HTML files. It would take so long to add it to each one manually that it wouldn't even be worth it. Is there any script or application I can use to help me with this, or any tricks in HTML I can take advantage of? Thanks.
Most IDE's have a function called 'find and replace'. I work with Netbeans, but I imagine almost every IDE can do this, perhaps even a decent text editor may be sufficient. Usually you can find it in the 'edit' menu somewhere.
You could search for </head> and replace it with <link href=.../></head> or something similar.
Ususally you can tell the replace function which folder it should search in, and even wich file types to check for. Should be easy and done in a couple of seconds.
Do these HTML pages share some resource? You can consider 2 options:
1 - Make a script to insert those stylesheets to the HTML files head automatically or;
2 - Insert the stylesheet once in an resource(Require the file for an script i.e) already shared by those files;
use php include(); and paste it on top of files. wont take you more than 5sec per page.
You can do this fairly easily using a good text editor like Sublime Text 2 or TextMate (Mac OS X). Here are instructions for how to do this in Sublime Text 2:
Open Sublime Text 2
Create A New Window (File » New Window)
Make sure the Side Bar is visible (View » Side Bar…)
Drag and drop the HTML files (you want to add the stylesheet to) onto the Side Bar
Find » Find in Files… (Note the mini find-replace dialog at the bottom of the window)
Search: </head>
Where: (Clear this field so it will look in: Open files and folders)
Replace: <link href=.../></head> (Hat tip to: #PeterVR)
Click Replace
Confirm dialog and be sure to save all your files!
Good luck!