Sublime Text edits since last save - sublimetext2

Can't seem to find anything online. Frequently spend time editing multiple text documents at the same time and loose track of which ones I have edited. When I close I am not always sure whether I have purposefully changed or accidentally edited a character in a file. Would be great to have a feature to show the edits since last save for sublime text.
Seems like such an obvious need that I am surprised that I cannot find anything in features. Am I missing something or am I the only one with this need?

I know this already has an accepted answer, but it is not necessary to install FileDiffs or anything else. Just right click on the modified window and select Show Unsaved Changes.
A pane will show up at the bottom, listing the differences. There isn't an obvious way to dismiss the pane, but Ctrl+F will replace it with the search pane again.

Add this line to your Preferences.sublime-settings file (If you're on a Mac, then open the Sublime Text 2 menu -> Preferences -> Settings - User):
"highlight_modified_tabs": true
This will highlight tabs that have unsaved changes.

You may use the "Marking Changed Rows" plugin, which places a small gutter marker for lines with unsaved changes.

You can install the FileDiffs plugin which among other useful things will give you a diff between the current (edited) file and what is saved to disk.

Show Unsaved Changes
Right-clicking anywhere in the file has long provided an option to show all unsaved changes.
It will list all changes in the dialog area also used for find/replace.
This should work for Sublime Text 2 and 3.
Incremental Diff
A more recent version of Sublime Text 3 added an Incremental Diff feature.
The gutter shows which lines have changed.
This works both for unsaved changes, as well as changes between file saves or git commits.
It can be configured to show diffs against: the last saved version (git not needed), git Head, or (via the API) any other content.
Show modifications:
Right-Clicking the
gutter marker, or
any code next to the gutter marker
(aka any area of modified code whether or not your theme shows gutter markers)
brings up options to:
show the diff versions inline, or to
open a dialog showing all tracked diffs
Or you can use the menu item:
Edit -> Text -> Toggle -> Hunk Diff
Or the shortcuts:
Ctrl + / (on Mac it's the clover icon, not Ctrl)
Or this shortcut variation, which will also close/hide all other diff Hunks
Ctrl + ; (on Mac it's the clover icon, not Ctrl)
I'm unaware of a menu item to show all unsaved changes.
Menu Items and Shortcuts are available to navigate between changes, and revert individual (inline) changes. (see linked doc above for details).
minor caveats:
your theme must support diff styling to be able to see the gutter markers. The docs indicate how to add custom styles if you use an older theme that does not include the necessary styles.
However, functionality should still work, even if you cannot see the gutter markers, as long as the option is enabled in your Preferences file.
if you make an edit, then change it back, the buffer will still be tagged as having (2) changes, unless you reverted via Undo (ie Ctrl-Z). It is not a "file diff" as much as it is a tracker for the edit buffer, which stores what and where. However, the Show Diff Hunk option will show you whether the change was "important", an actual file diff, or not.
Navigate:
To navigate between modifications (whether or not your theme shows gutter markers):
Ctrl + .
Ctrl + ,
menu Goto -> Next Modification
menu Goto -> Previous Modification
Revert a Hunk:
With cursor over modified code or gutter (whether or not your theme shows gutter markers):
Ctrl + K, followed by Ctrl + Z (on Mac it's the clover icon, not Ctrl)
menu Edit -> /Text -> Revert Modification
This will only act on the diff Hunk that is at the location of your cursor.
It will not have any effect if your cursor is not in an area of modified code / diff Hunk.
Here are the Sublime Text 3 SETTINGS that control the Incremental Diff feature:
mini_diff controls the incremental diff functionality (on / off / on for Git only)
Valid values include:
true – always enable incremental diff (the DEFAULT) (Git or Not-Git)
"auto" – enable incremental diff for files in a Git repository (only)
false – disable incremental diff
git_diff_target controls the behavior of incremental diff for files in a Git repository
Valid values include:
"index" – diff against the Git index (aka staged for commit), (the DEFAULT)
"head" – diff against the file at HEAD (aka last commit in checked out branch)

Related

Bin Icon is Gone From the Panel in Visual Studio Code

In Visual Studio Code, there was previously a trash image (icon) in the panel section. When I clicked on it the terminal was clearing. But it no longer exists. I changed accidently panel settings. For solving, I clearing settings.json folder but still same. Why does it never revert back to its old settings?
The Trash-bin Icon is Still Very Much Present in Your Editor
"The other solutions here, though no wrong in what they say, are not good solutions. The icon is still present if you know where to look, and you didn't accidentally change your settings. In the last VSCode update — "the May-2021 Update (v1.57.1)" — the VS-Code team added support for the new feature, "Terminal Tabs", which does more than add terminal-tabs, it offers users an entire new UI to use. It also switched the configurations of millions of unexpected VSCode users, so that the new UI was auto-equipped. In all fairness you are not the first person to wonder where the "Trash-bin Icon" went. I answered another question, 2 weeks ago, asking about the drop-down that is no longer visible."
You have two options available to you.
You can, keep the new UI the way it is, and below is a picture that shows where the new terminal tab trash-bin icon is.
Or you can switch back to the old UI using the setting bellow:
terminal.integrated.tabs.enabled: (true/false)
Image shows "terminal.integrated.tabs.enabled": false, and where the trash icon is. It is important to note that the icon auto hides, and one must scroll over it before it reveals itself.
Image shows "terminal.integrated.tabs.enabled": true, and where the trash icon is located using the old UI. I think its fair to note, the new UI was created to make VSCode better. People use to download extensions to get the same terminal tabs that the new UI offers.

PhpStorm single click preview like Sublime Text

At my new job I have to work with PhpStorm. I come from Sublime Text, and what bothers me most about PhpStorm is the lack of a single click preview of the files. In stead, it opens the files for editing and adds them to active tab, leaving me with A LOT of useless tabs.
I searched here on StackOverflow and Google, but I seem to be the only one who is annoyed by this. In Sublime it goes to edit mode only after a double click. Is there a setting or plugin to have it like in Sublime?
It's a native feature these days:
Settings... / Editor / General / Editor Tabs / Opening Policy > check "Enable preview tab"
on version PhpStorm 2022.3.2
Single Click To Open File
By default to open a file in phpstorm you have to double click it. I found this to be very annoying. Luckily you can change this to be a single click.
Steps:
Click the gear icon.
Make sure 'Autoscroll to Source' is checked
Make sure 'Autoscroll from Sourcce' is checked
http://www.ryanwright.me/cookbook/phpstorm/single-click-open-file
There is no such functionality currently available. I may only suggest to use View | Quick Definition to preview files.
Other than that: https://youtrack.jetbrains.com/issue/IDEA-130918 -- watch this ticket (star/vote/comment) to get notified on progress.
Welcome in late 2019 - we got a plugin for this now:
Plugin: https://plugins.jetbrains.com/plugin/12778-quick-file-preview
Plugin Source: https://github.com/SeeSharpSoft/intellij-file-preview
IntelliJ Issue: https://youtrack.jetbrains.com/issue/IDEA-130918
Don't forget to disable the "Autoscroll to Source" Feature, to get the full advantage of the plugin!
The closest you'll get right now is to enable 'Scroll To Source', however this will actually open the file in another tab, it will not be a preview.
Open the Project, Favorites, etc. side bar (cmd + 1 or ctrl + 1)
Click the gear in the top right
Select 'Scroll to Source'
Note 'Scroll to Source' can be enabled at the same as 'Scroll from Source', just make sure if you click on one file you wait until the sidebar catches up to click another, otherwise the sidebar will autoscroll back and forth between the two. You'll have to click one of them to break that loop.
Read more on JetBrains' website
This is now available as a native feature in the latest version: 2020.3!
See this comment on the YouTrack link someone posted above https://youtrack.jetbrains.com/issue/IDEA-130918#focus=Comments-27-4500169.0-0
Also on the 2020.3 feature list under User Experience there's a mention of "preview tab" here https://blog.jetbrains.com/idea/2020/12/intellij-idea-2020-3/

PhpStorm - Highlight active file in project navigator

Does anyone know how to highlight the current file in the project navigator, or a hotkey to expand folders to the active file?
I have looked around and couldn't find anything that points to this as an option.
Here is a nice feature: Autoscroll to Source and Autoscroll from Source.
It is available in all IntelliJ products .
On Demand
Should be used if you do not like when your Project View panel gets changed/moves without your consent.
Navigate | Select in... | Project View
Alt+F1, 1 for Windows/Linux
⌥+F1, 1 (or fn+⌥ Opt+F1, 1) for Mac OS
You may also click on "target like" icon on actual Project View panel with your mouse:
If you wish to use shorter/single shortcut instead of standard 2-step shortcut:
install "Extra Actions" plugin
assign custom shortcut to newly provided "Select in Project" action
As of some 2017.x version (or maybe even 2016.x) the IDE has own dedicated Select in Project View action (so no need for additional plugin). You can find it in Keymap under the Other branch (hint: use search box to narrow the list).
Automatically
Can be used if you do not mind (or even want) to have Project View panel keep focused on currently edited file (so it scrolls/moves up and down/expands when needed).
NOTE: with frequently switching between the files (e.g. CSS & HTML) when you have a lot of files in your project such "scrolling" may become quite annoying pretty fast (especially if such files are located in the invisible-right-now part of the project tree).
Activate Autoscroll from Source option in Project View panel (right click on tool window header bar/title or use menu under "gear" icon):
In modern versions (2020.3 and newer) that option was renamed and is now called Always Select Opened File:
Just click the circular icon (with tooltip Scroll from Source) to navigate in the project directory tree and highlight the corresponding active file in the PhpStorm editor.
On PhpStorm 2020.3 you have to click the cog icon in the project pane and select Always Select Opened Files:
The above answers are all valid but unfortunately you'll have to enable them for each project.
There's a plugin from Jetbrains that will enable this behaviour by default for all new projects.
http://plugins.jetbrains.com/plugin/7575?pr=

Can I save collapsed code in Sublime Text 2?

Have code I can forget about all looking nice:
However, upon closing the file and reopening it:
How can I collapse this code I'm not going to edit for years(hopefully!) and keep it hidden indefinitely?
I think the BufferScroll plugin will do what you want.
Buffer Scroll is a simple Sublime Text plug-in which remembers and
restores the scroll, cursor positions, also the selections, marks,
bookmarks, foldings, selected syntax and optionally the colour scheme,
when you open a file. Will also remember different data depending the
position of the file in the application (example file1 in window1 has
scroll line 30, file1 in window2 has scroll in line 40)
Also, via preferences, allows to enable syncing of scroll, bookmarks,
marks and folds between cloned views, live.
Update:
To install this package on ST2, you have to add the repository to your PackageControl user settings:
"repositories":
[
"https://github.com/titoBouzout/BufferScroll"
]
Now you should be able to do a standard install from ST2.

Auto-convert tab to 4 spaces in TextWrangler?

Is there a preference in Textwrangler to redefine a tab as 4 spaces? In Vim this is set expandtab in the vimrc, but I don't know how to set it in TW besides clicking "Detab" when I'm done editing the document.
Thanks,
Kevin
Go to "Preferences" -> "Editor Defaults" -> "Auto-expand tabs," and then set tabs to 4 spaces. Then restart TextWrangler for changes to take place.
For docs that already exist you have to hit the "Text Options" button in the top of the editor window of the open document. In older versions, it's the button that looks like a "T" with a light switch next to it; with newer versions, it's a gear "⚙" icon. In that drop down there is the "auto-expand tabs" as well.
in version 4.5.5, there is 'Text -> Detab...', which pops up a requester for how many space per tab, preset for 4.
Go to Edit -> Text Options and tick Auto-expand tabs. This will make all the new tabs to change to spaces.
To change all current tabs to spaces as well, go to Text -> Detab and hit Detab.
Hope that helps!
For Mac, another easy way to check and enable "Auto-expand tabs" is to hit the gear button on top left.
You can also use "Normalize Options..." to set the text options of an already-open document to whatever you have set in your Preferences. This is useful for dealing with pre-existing code.
There are two places you need to set the settings for this to work. One is for previously opened documents, and the other for all documents to be opened or created in the future.
The Settings
set "Auto-expand tabs" to checked
set "Tab width" to 4
Previously Opened Documents
Click the "Text Options" button. It is in the top left of the editor window directly above the document view of the open document. In newer versions it's a gear "⚙" icon. And in older versions it is a "T" and light switch.
New Documents
go to preferences menu: BBEdit -> Preferences
choose "Editor Defaults" from the side-bar in Preferences