Webstorm: save only open tab vs. save all tabs? - webstorm

I'm new to webstorm since I started my latest job, and I'm finding some features difficult to adapt to. In particular, the fact that it forces you to save all open changes in all tabs at once is problematic.
I have a somewhat organic method of development, swapping between HTML and LESS frequently until I reach a point where I want to save the files and see what my work has accomplished. Whenever I save an open HTML doc, it saves the incomplete LESS that I just left mid-thought as well, and pops up a compiler error. Is there any way to force webstorm to only save the active tab?
(Aside: Please don't suggest I adjust my mindset or my workflow to adapt to my environment. Not only is that poor usability, it would require me to override an instinct that was developed for good reason: when you reach a milestone, you save it lest something bad happen. Leaving an unsaved doc open makes my eye twitch.)

This has been (sort of) implemented in v7.0. You'll need to dig into Settings > Menus and Toolbars to add "Save Document" to the program menu, and Settings > Keymap if you want to assign a keyboard shortcut (and disable Ctrl+S for Save All).
You may also want to tick "Mark modified tabs with asterisk" under Settings > Editor > Editor Tabs.
Note: You will not be warned if you exit without saving your changes.

Related

Is there any sort of "Codelet Template" in KDevelop?

Everytime I need to input a piece of code such as "switch .. case" or "declaring a class", I desire a way I can rapidly achieve it by hitting a shortcut.
In many IDEs, we can do it by pressing some shortcut keys, and IDEs will paste a little piece of pre-defined code at the position of the focuse.
Is there any similar way in KDevelop?
I'm not meaning the File/Project Templates here.
Thanks!
Yes, use the 'Snippets' plugin distributed with Kate.
Install the Kate editor. Several of the plugins included can also be used in KDevelop; there's been some discussion of distributing those separately but it hasn't happened yet.
In KDevelop, use the menu Window -> Add Tool View and select 'Snippets'.
There will be a 'Snippets' toolview. Click on entries to paste them, or you can bind a shortcut. You can add new entries and categories.

Sublime Find and Replace without having to click save

When I do a global search/replace in a project, Sublime will automatically open all the files involved, and not save them. I then have to manually save every single file.
Is there a way to have Sublime automatically save all the changes that have been done, and not open the files that where not previously open?
Thanks in advance for anyone who can help me with this.
http://www.sublimetext.com/forum/viewtopic.php?f=3&p=40348
I think it's Option + Command + S(Mac) or Command + Alt + S(Win).
Just performed a similar task with the free Visual Studio Code. Replace in Files without opening files and fast. Just made 60k changes in just a few minutes.
Robust if awkward.
While it doesn't change the fact that Sublime Text doesn't seem to be the best tool for this job, here's a practical workaround procedure I've come to rely on. It's reasonably slow but painless if done correctly. Memory consumption impact seems negligible, if you're wondering. The ballpark of my use cases is up to about 10k files in up to a handful of minutes on a mediocre memory-cramped machine using Sublime Text 3.2.2 (3211) on Windows 10 Pro x64.
Requirements
You'll need the package SideBarEnhancements to be installed.
…which in turn relies on Sublime Text 3 or newer as of writing this.
Procedure
(Could probably be deferred until step 3.) You add the directory A that you're going to operate on to the project sidebar.
You initiate your batch replacement operation over numerous files inside directory A.
Sublime Text takes its time to open numerous tabs belonging to directory A recursively and perform replacement in each.
You right-click on the directory A in the project sidebar to bring up its context menu and choose "Save Views".
Sublime Text takes its time to save each tab belonging to directory A recursively.
You right-click on the directory A in the project sidebar to bring up its context menu and choose "Close Views".
Sublime Text takes its time to close all tabs belonging to directory A recursively.
Disclaimers
Warning
Do not make the mistake of skipping step 3 or you'll effectively become stuck in a GUI loop of writing confirmation dialogs defaulting to "Yes" for however many thousands of files you're operating on.
If you decide to abort operation between steps 2 and 3 — your best course of action, is to back the files up on disk, proceed with the outlined procedure and then restore the backup.
Caution
All of the tabs belonging to the directory you'll operate on will be closed by the end of this procedure. If you need a substantial portion of them to remain open throughout replacement — consider organizing the files contained into a sub-directory structure conducive to cherry-picking.
General advice
As a rule of thumb, before proceeding with this procedure, it would be wise to check if the required context menu entries are in fact present (greyed out or not) in your combination of editor+package versions. And to be on the safe side, you might want to back up your data and Sublime Text session before massive operations.

Is there a way to choose which files are displayed to the user via the standard OPENFILE dialogs?

Vista introduced an interface: IFileDialog::SetFilter, which allows me to setup a filter that will be called for every potential filename to see if it should be shown to the user.
Microsoft removed that in Windows 7, and didn't support it in XP.
I am trying to customize the our Open file dialog so that I can control which files are displayed to the end user. These files are marked internally with a product-code - there isn't anything in the filename itself to filter on (hence file extension filters are not useful here -= I need to actually interrogate each one to see if it is within the extra filter parameters that our users specified).
I would guess that Microsoft removed the SetFilter interface because too often it was too slow. I can imagine all sorts of similar ideas to this one which don't scale well for networks and cloud storage and what have you.
However, I need to know if there is an alternative interface that accomplishes the same goal, or if I really am restricted to only looking at the file extension for filtering purposes in my File dialogs?
Follow-up:
After looking further into CDN_INCLUDEITEM, which requires the pre-vista version of OPENFILENAME, I have found that this is the most useless API imaginable. It only filters NON-filesystem objects. In other words, you can't use it to filter files. Or folders. The very things one would filter 99.99% of the time for a file open or save dialog. Unbelievable!
There is a very old article by Paul DiLascia which offers the technique of removing each offending filename from the list view control each time the list view is updated.
However, I know from bitter experience that the list view can update over time. If you're looking at a large folder (many items) or the connection is a bit slow (heavily loaded server and/or large number of files), then the files are added to the dialog piecemeal. So one would have to filter out offending filenames repeatedly.
In fact, our current customized file open dialog uses a timer to look at the view's list of filenames periodically to see if any files of a given pattern exist, in order to enable another control. Otherwise it's possible to check for the existence of these files, find none, but a moment later the view updates to have more filenames, and no events are sent to your dialog to indicate that the view has been changed. In fact, my experience with having to write and maintain code for the common controls file dialogs over the years has been that Microsoft is not very cluefull when it comes to how to write such a thing. Events are incomplete, sent at not-useful times, repeated when not necessary, and whole classes of useful notifications don't exist.
Sadly, I think I might have to give up oh this idea. Unless someone has a thought as to how I might be able to keep up with the view spontaneously changing while the user is trying to interact with it (i.e. it would be awkward to go deleting out entries from the list view and changing the user's visual position, or highlighted files, or scroll position, etc.)
You need to initialise the callbacks for your CFileDialog. Then you need to process CDN_INCLUDEITEM notification code to include or exclude items.
You can also check this great article. The author uses some other approaches in addition to callbacks
As you have already discovered, starting in Windows 7 it is no longer possible to filter out files from being displayed based on content, only file extension. You can, however, validate that the user's selected file(s) are acceptable to you before allowing the dialog to close, and if they are not then display a message box to the user and keep the dialog open. That is the best you will be able to do unless you create your own custom dialog.

Prompt for saving Normal.dot

I've been experiencing some issues when trying to manually close a Word document created from my VBA project (actually developed with Access 2003). Depending on the method I use, it may prompt for saving Normal.dot and then tell me that it's already opened or being used. This is a little bit annoying, because I'm then unable to close Microsoft Word. A big waste of time.
Some frustration later, I found a little trick to solve my issue. I've decided to post it there because I've been unable to find any information about this problem on Stack Overflow.
Here's how it goes:
Set WordApplication = CreateObject("Word.Application")
WordApplication.NormalTemplate.Saved = True
Nothing really fancy here, but the second line prevents the prompt for saving Normal.dot. It does NOT actually save anything to the template, it just let MS-Word believe it's been already saved.
Be sure that the option to prompt for saving Normal.dot is disabled in your MS Word's Preferences (Tools > Preferences > Save > Prompt to save Normal template). Disabling so will prevent the prompt in normal use situations. However, there might be some issue like the one above when you're creating a document from scratch with VBA (and probably many other languages), always depending on the method you implement to create/open your document.
Hopefully this little line will save you some more minutes of research.

Custom client app - need ability to control where documents are saved

Okay SO. I need some guidance. I apologize for the length of this post, but I need to provide some details:
I've got someone who is interested in me to do a small project for them. The application in general is a fairly straightforward employee record keeping / documentation app, but it makes pretty heavy use templated Word and Lotus documents. The idea is you select the employee “event” such as commendation, promotion, discipline, etc., and it loads the appropriate template doc and you fill it in from there, and later you can select an employee, view all the “events,” and view the individual documents associated with each one.
Thus, the app must know where the .docs are saved when the user is done.
The client actually has a v1 of this app (it doesn’t do any management of the files or anything, just launches Word/Lotus with the document you wanted to view in a new instance, presumably via a system() call.) We’ve not gotten into a detailed requirements phase, but the client and I agree that for this to really work, some kind of control over where the user saves the .doc’s to is going to be critical , because otherwise the app provides them with the new copy of the template doc, they "Save as" somewhere else, and the app is pointing to the blank copy it provided them with.
Obviously, I can’t think of a way to achieve “Save as” restriction/control in any way via just launching a new instance of Word. The client has the idea of an embedded Word/Lotus instance in the app with the template doc when you choose one, but I’ve few reservations with that:
I’ve dug around online and I’ve read that whichever version of Word I borrow MSWORD.OLB from will be the one the end user would require?
I’ve tried to do the MSDN example of embedding a Word doc from here, but as I’ve come to get used to, the MSDN example doesn’t even compile.
Even if I CAN figure out how to embed a .doc file into their application, I don’t know that I could control the use of “Save as…”
All of this STILL hasn’t touched on Lotus (!)
So… instinctively, I feel the embedded Word/Lotus thing has to be more work than it’s worth in the end.
So I’ve had a few other ideas brewing around.
One is looking into using Office XML (and if there’s a lotus equivalent), and get the user’s “inputs” separately and generate the document on the fly each time. I’m not particularly thrilled with that idea, but I think it COULD work, provided I just use old features to try and stay far backwards compatible.
Get user’s “inputs” separately and generate a document in HTML. Meh. Works, very cross platform and easily parsed and understood, but not good if you want to be able to email it to someone (who emails a .html? Works, yes, very unconventional which to the average user will throw them off) and even worse if you need to email it to someone for revisions…
Perhaps some kind of editable PDF? I know there are PDF libraries out there, and the more I stew on it, the more this sounds like the best option, though I’ve not done much work with PDFs and I don’t know how easily embeddable they are / what options one has when creating them. I know they can be save-disabled, I’ve had that with my bloody state taxes before.
I need some input here. Here’s the TLDR questions:
Is launching a new instance of Word for each .doc as bad as I feel, given user can “Save as” document wherever and then application is left pointing to a blank document?
Is trying to support embedded Word as big of a trouble as I feel like it is / more work than it’s worth / likely to cause problems with supporting multiple versions of Word? (Forward compatibility as well as currently released versions?)
What are thoughts on the PDF plan?
Any other good ideas?
Word does allow for programming some "Save" and "Save As" control via its object model. Any subroutines coded in VBA and placed into your Word template will be copied into all documents generated from that template. Additionally, most menu and Ribbon commands can be intercepted by creating a module containing subroutines named for the intercepted commands. So, for example, if a module contains a sub named FileSaveAs(), any code in that sub will be executed instead of the standard File|Save As command. Lastly, this code will replace Save As commands executed via keystroke, toolbar, menu, or Ribbon.
The code below will launch a dialog box to a predetermined path whenever a "Save" or "Save As" command is executed:
Sub FileSave()
ControlSaveLocation
End Sub
Sub FileSaveAs()
ControlSaveLocation
End Sub
Sub ControlSaveLocation()
Dim Directory As String
Directory = "C:\Documents\"
With Application.Dialogs(wdDialogFileSaveAs)
.Name = Directory
.Show
End With
End Sub
Hope this helps.