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.
Related
I recently moved to Sublime Text 3 for development and trying to figure out a way in which I can know whether a file is saved or not just by looking at it in the editor. For e.g.
Eclipse puts a star in front of the file name if there are unsaved changes
Notepad++ changes the tab color as red
Is there any such easy to see visual cue in Sublime Text 3 to know if a file has unsaved changes?
By default Sublime Text displays dot (•) instead of x used to close tabs when there are unsaved changes.
You can make this highlighting of modified tabs even more distinctive using following property which causes modified tabs to have different color:
{
"highlight_modified_tabs": true
}
The color of modified tabs with this property enabled will depend on the theme you are using. If you want to change it, either change the theme or change the color manually in your settings. See this answer for more details on that.
In Sublime text there is a indication on the tabs, a full circle is not saved, a cross (x) is a saved file, indicating that you could close it.
Not saved file:
Saved file:
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=
If my cursor is placed after an html closing tag and I press enter, I get a popup auto-completion suggestion as follows:
p> (element)
If I press enter again p> is printed on the screen.
This is annoying and I want to prevent it but how? I have already tried setting auto_complete to false in user preferences but that did not work.
There is complete description for Auto Completion on there site as
Disabling Auto Complete
Auto complete can be disabled with the auto_complete setting. To disable it, add this line to Preferences/File Settings - User:
"auto_complete": false
If auto complete is disabled, the completion popup can be shown manually, or tab can be used to insert the highest ranking completion without showing the popup.
Manually Showing Completions
Pressing Ctrl+Space will show the completion popup if it's not currently showing. If it is showing, it'll select the next item.
Commit on Tab
By default, the selected item in the completion popup will be committed when enter is pressed. This can create ambiguity between committing the completion, and inserting a newline. By setting the auto_complete_commit_on_tab setting to true, enter will insert a newline, and tab will commit the current completion. There are other benefits, too: because Sublime Text knows there is no ambiguity, it will show a more curated list of completions, with the one you want more likely to be in first place.
Enabling Commit on Tab is recommended, but it will take a short time to get used to.
Source :Sublime 2 Auto Complete
Hope this helps.
Answer in short (worked for me): Remove SublimeCodeIntel package.
After searching some more, I found that this is actually a long standing problem (7 months). The problem is posted on github as issue #279 and issue #359. Still not sure how to fix it exactly though (Without removing the package).
Long answer:
I was having the same problem you describe and it also annoyed me.
For me the problem was coming from the SublimeCodeIntel package that I installed in Sublime Text, so I guess you also have this package installed, causing this problem. I'm using ST version 3, but I guess there should be no difference to version 2 regarding this issue.
Although the answer by Jatin seems to be a work-a-round, (disabling the auto_complete will just mask the problem, what if you want to keep auto_complete on true), when I actually set auto_complete to false, I was still getting the auto_complete pop-up. After some thought, my guess was because of the SublimeCodeIntel package I had installed.
So I removed the SublimeCodeIntel package and behold, no popup auto-completion with the "p> (element)" suggestion.
Of course, removing SublimeCodeIntel may also seem a bit of a drastic solution. Maybe the package can be configured in such a way that the problem does not occur any more. I haven't looked into the problem why SublimeCodeIntel displays this incorrect auto complete suggestion. It might be good to send a bug report to the author of the package? (At the moment I'm happy enough to just remove the package)
You can disable the languages that CodeIntel autocompletes for.
The default setting is:
"codeintel_enabled_languages":
[
"JavaScript", "SCSS", "Python", "HTML",
"Ruby", "Python3", "XML", "Sass", "HTML5", "Perl", "CSS",
"Twig", "Less", "Node.js", "TemplateToolkit", "PHP"
],
Override the settings in your User Settings by removing the HTML and HTML5 items (paste this into your User Settings: Go to Preferences -> Package Settings -> SublimeCodeIntel -> Settings - User):
{
"codeintel_enabled_languages":
[
"JavaScript", "SCSS", "Python",
"Ruby", "Python3", "XML", "Sass", "Perl", "CSS",
"Twig", "Less", "Node.js", "TemplateToolkit", "PHP"
]
}
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)
I got problem with jQuery Snippet that i installed throughout package control. After installation I do not have popup with jQuery code hints and intalisance. Look at this video:
http://code.tutsplus.com/courses/perfect-workflow-in-sublime-text-2/lessons/adding-snippets-through-package-control
On 0:50 after typing . he got popup with code hints - I don't have this one. I have to type . on and then press Tab to display popup with snippet...
And yes, I'm in JavaScript file and I got default settings.
And after . he also got all jQuery functions like add or addClass. I do not have this one even if I press Ctrl+Space.
If you hit CTRL-SPACE you'll get the dropdown of available completions for what you've just typed.
http://www.sublimetext.com/docs/2/tab_completion.html
If you want the autocomplete dropdown to appear as you type then add this line to your User Preferences.sublime-settings file:
{
"auto_complete_selector": "source, text"
}
That should do what you're looking for :-)
Consider changing User Settings to the following:
{
// By default, auto complete will commit the current completion on enter.
// This setting can be used to make it complete on tab instead.
// Completing on tab is generally a superior option, as it removes
// ambiguity between committing the completion and inserting a newline.
"auto_complete_commit_on_tab": true,
// Controls if auto complete is shown when snippet fields are active.
// Only relevant if auto_complete_commit_on_tab is true.
"auto_complete_with_fields": true,
// As Richard Jordan suggested, this item
// controls what scopes auto complete will be triggered in
"auto_complete_selector": "source, text"
}
Open your User Settings by pressing Cmd+, on Mac or Ctrl+, on Windows
And if you want to fully grasp Sublime Text 2, I do recommend this course: Perfect Workflow in Sublime Text. It used to be free by the time I first posted this answer. I still recommend it anyways.
Which OS are you using? I'm guessing Windows.
The problem here seems to be that the jQuery snippets in the available plugins have <tabTrigger> attributes that start either with a $ or a ., which causes trouble.
Try the following: Find the jQuery package that contains those snippets (Under Preferences -> Browse Packages) and open the .sublime-snippet file of a snippet that doesn't work properly. The one you named in your post would be defined in the file event-on.sublime-snippet.
Find the line
<tabTrigger>.on</tabTrigger>
and remove the . as follows
<tabTrigger>on</tabTrigger>
Save and return to your .js file. Now see if the snippet shows up when you type o. This works for me.
I guess this is a bug in Sublime Text 2 for Windows (maybe Linux, too?), since it obviously works fine on OS X as we see in the video course you've linked.
There was an issue created on GitHub on this specific package and I now commented this info. I guess the only way to get this working is to have snippets that do not start with special characters.
I also filed a bug for Sublime Text on Userecho.
The creator of the video is using SublimeCodeIntel. What you see at 00:50 isn't Sublime Text 2's autocompletion popup, it's SublimeCodeIntel's import autocompletion popup:
Imports autocomplete - Shows autocomplete with the available modules/symbols in real time.
See the Github page for more information.