Why LiveServer extension in VS Code does not open the right HTML? - visual-studio-code

I want to use LiveServer to quickly live view one HTML file index.html, which i created on the fly.
But Everytime I click on button Go Live on bottom-right corner of VS Code, it opens another HTML file (under folder TailwindCSS in workspace .
What on earth is going on? LiveServer extension is not intuitive at all as its guide shows ! This malfunctioning LiveServer extension has wasted me 1 hour !!

Right-click the main file you want to open in the live server and click on "Open with live server". This might work.

I had the same problem. I just had to open the whole folder via File->Open Folder.

Related

How to open files in new tabs in Visual Studio Code

I recently started using Visual Studio Code and I would like to know, is a way to open files in a new tab? Currently whenever I open a new file the files I currently have open disappear. I say new tab, but any option that will let me open a new file in the same window as the old one works.
I have tried disabling Preview Mode through the workbench settings as shown in this answer: How to config vscode to open files always in a new tab?. However, when I choose Open or Open Recent the new file still replaces my old file.
Thanks.
Once you have to open your settings file, add the "workbench.editor.enablePreview" property and set value to false.
For 1.21.1 version.
In user settings =>
"workbench.editor.enablePreview": false,
"workbench.editor.enablePreviewFromQuickOpen"
the best way i found.
Starting with VSCode 1.52 (Nov. 2020), you should not have any more issue: all files will open in new tabs, even in preview mode.
Better handling of preview editors:
Preview editors are now better handled with numerous improvements based on feedback and making this feature work more consistent.
The setting workbench.editor.enablePreviewFromQuickOpen is now disabled by default so that editors opening from quick open will not appear in preview mode anymore.
When you start a navigation (e.g. go to definition), the editor you start from will move out of preview mode to keep it open while the new editor will be in preview mode until you navigate further.
We changed all of our custom trees (the ones used from extensions or Git changes view for example) to work more consistently like our built-in trees (like the explorer).
This means, the following interactions now apply to all of them:
double-click or mouse-middle-click to open non-preview
Enter to open non-preview (Space to open in preview-mode)
Note: if you are the author of an extension that is leveraging our custom tree API, you can benefit from this change as well.
Make sure to use vscode.open or vscode.diff commands for the TreeItem.command and you are in!
A new menu item in the editor overflow menu allows to quickly turn off preview editors altogether:
You need to double click on the name of the file. Also, it needs to be done swiftly elsewhere you will be opening in the same tab.
You can drag and drop file near to the opened tab and the file will open in new tab.
Thanks everyone. Double clicking and dragging was useful, but it still didn't solve my problem when opening files from different projects with the "Open File" menu command. I found that Multi-root Workspaces is what I was looking for. https://code.visualstudio.com/docs/editor/multi-root-workspaces
This is likely due to Visual Studio Code opening file in what's called "Preview Mode", which allows you to quickly view files, ideally if a tab is in Preview Mode then its title in the tab bar, will be italic.
To disable Preview Mode set "workbench.editor.enablePreview": false in your settings file or use the "workbench.editor.enablePreviewFromQuickOpen" option to disable it only from the quick open menu.
Alternatively, use command palette CTL+Shift+P (to get all settings) VScode settings then in User => Workbench => Editor Management you can uncheck Enable Preview and Enable Preview from Quick Open to get the same results described above

Visual Studio code always opens the wrong file for me

I have a very weird problem with Visual studio code (Version 1.20.1 (1.20.1)).
In full screen mode on a Mac. (High Sierra) when I double click a file. it always opens the file above it. Meaning that it opens the wrong file (not the one which I double clicked).
Please have a look at this video which I recorded.
https://youtu.be/VG8-AnEpZjY
The video starts with me double click on the file "Tables.scala" but the editor opens the file "ScanFromCassandra" which is above it.
Then I double click Models.scala and it opens the file correctly.
Then I double click Config.scala but the editor opens CommonFlow.scala
This is very very annoying. I don't know if anyone else is facing this issue or not.
Edit:: If I switch off the "open editors" window, then the issue disappears. but I like the "open editors" window. I think the open editors window causes some kind of "jumping" in vscode making it open wrong files.
Actually I figured out the answer after using the editor for some time.
in VSCode when trying to open files in the "explorer" we have to single click on the file name. not double click.
If I single click on the file name it works perfectly.
The problem comes when I double click but that's not required. a single click on the file name to open it works smoothly.

Eclipse File Associations: displaying images

I am developing some help documentation in a Java project in Eclipse. In the resources folder there are my HTML pages and a couple of GIF and PNG images that will be displayed inside the HTML.
Now for my convenience I want to preview the images in the file structure of the project, to see what they show and which one to include in the HTML page. If I double-click an image, the default action that Eclipse does is: it opens it in Internet Explorer. Since I don't like IE, I want to change this default action. What I would prefer actually is that it opens some image viewer of some kind inside Eclipse.
I know this is a matter of file associations. However I was not able to get it working.
What I tried to do so far:
As an example I did it for *.gif.
I went to Preferences -> General -> Editors -> File Associations. There I pressed "Add..." and added *.gif.
Then I pressed "Add..." at the Associated Editors section and added an external gif viewer:
I expected this to open the default image viewing program from my Windows system, but for some reason it still opens it in Internet Explorer.
So what can I do to change this? Does Eclipse have an internal image viewer of some kind?
Why not just install plugin for viewing images
http://marketplace.eclipse.org/content/quickimage -> http://psnet.nu/c/quickimage
Sources https://github.com/persal/quickimage
There was nothing wrong with Eclipse, and the described solution is fine.
In fact the problem was with the Windows system. The system's default file association with images was the Internet Explorer. Changing that solved the problem.
right click on the file -> open With.. and then select -> System Editor (it should remain selected as a checkbox does)
After that you should be able to double click on a file and open it with the right app.
My environment is eclipse indigo build 1857 on gentoo linux
EDIT:
When you associate some external software with an extension, you should see on the menu "open With.." all application associated with the extension(On the top).
Then you can see : Text Editor - System Editor - Default Editor - Other...
Text Editor: open your file with the text editor
System Editor: open your file with the app associated with extension in the operating system
Default Editor: open your file with the (default) app associated by you under Preferences ->General -> EDitor -> File Associaton etc...
You should have something like this picture, without "In-Place Editor" option
Eclipse Oxygen (4.7)
Eclipse Oxygen (4.7) added the following feature - Images are opened in the Eclipse IDE.
You just need to double click the file name in the Package Explorer.
The file URI looks like this file:/// + absolute path:
Now there is a bug related to the URI shown on the right side.
If you rename the file, it won't be updated without reopening the file.

Getting Eclipse to open .html in text-editor by default?

Eclipse Juno keeps opening my HTML files in a embedded web-browser, rather than in an embedded syntax-highlighting editor.
I have installed:
Web Page Editor
Eclipse Web Developer Tools
PyDev for Eclipse
Specifically see the screenshot of my install applications.
I need it to work with Django templates + any other Python templates with HTML + normal HTML+JS files.
How do I find this editor, and select it as default?
Select Window -> Preferences from the main Eclipse menu.
Select General -> Editors -> File Associations from the Preferences menu.
For .htm and .html, left click on the extension in the upper view. Left click on the Add button to the right of the lower view to add one or more HTML editors. Left click on your favorite HTML editor and left click on the Default button to make it the default editor.
If the extension you want is missing, left click on the Add button to the right of the upper view to add the extension.
If you want to add an HTML editor to Eclipse:
Go to Help -> Install New Software
Choose the site http://download.eclipse.org/releases/your_eclipse_version
Type the filter text Web Page Editor
There should be one result. Check off the box and press the Finish button.
Now you should have the option to choose the HTML editor when opening files by right-clicking, Open With -> HTML Editor.
If you want to always use the HTML editor to open HTML files then go to the Eclipse preferences -> General -> Editors -> File Associations. Select the extension up top (e.g. *.htm, *.html) then select the HTML editor in the bottom pane and press the Default button.
I had a similar problem.
Once I installed the html editor (thanks to CgodLEY), still my html files wouldnt show up with that editor.
Solution? Right click on the html/htm file, go to "open with" and select "HTML editor". Fortunately that solve everything...
For those still finding their way here, yes, do add an HTML editor to Eclipse as CgodLEY suggests, if you're having this problem. However, even if you already have an HTML editor in your Eclipse installation, consider installing CodeMix for a superlative HTML editing experience - take a look at the differences here.
Now, there's a Django-aware template editor available for free:
http://eclipse.kacprzak.org/
I installed it in Eclipse Kepler / Django 1.6, it's working fine for me.
Note: if you previously opened a specific .HTML file with some other editor, you need to go back to the project view, right click on the .HTML file, select 'open with...' and explicitly select Django editor.
To answer the opening of your question: Note that Eclipse will use the built-in web-browser to view html files if you are opening them outside of a project, as in "File->Open File ...", when that file isn't part of a project.
I just created a dummy project, and now the html files are correctly opened with the editor selected in my preferences. Success!
Nothing worked and I had begun getting an unrelated error on startup with a troubleshooting step requiring reinstall.
This time I downloaded Eclipse for Mobile Developers, and since then I have added my other packages and it's all working fine =).
None of the editors work the way I want them to though, however I have ended up with Django-Editor (which is slightly better than Aptana's one).

Netbeans: how to change the default tool which opens .txt file?

I was living in peace and netbeans used to open text files in the netbeans editor. Then one fine day I wanted to open 1 of the text files in a web browser (to render some html, and I didn't want the headache of making a new html file. Yup, yup, I know I was being a fool). So I right clicked the file from inside netbeans and chose an 'open as' option and used treat file as "html/text" expecting it will open in the browser. And to my surprise the browser did come up and tried opening the file. But then all the text files now always open the browser and none of them get opened in the netbeans editor, no matter how hard I try, and netbeans no longer shows the 'open as' option when right clicking the text files.
Can some one suggest some way to fix this ?
Try going to Tools->Options then click Miscellaneous and then the files
tab. There should be an associations editor you can use to change this.