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"
]
}
Related
If there's only one tab on an editor in VS Code, the default behavior is to close the editor right then and there.
Personally, and I think many others agree with me, this behavior is very annoying since the programmer would rather preserve the layout he or she created for the project's workspace.
How do I change this behavior?
I've found discussions on this topic, but all of the solutions do not seem to be the ideal one of simply leaving the editor open but empty. Most of them simply delete the related shortcuts, which seems to me like cutting your arm off just because you broke it.
Anyway, here are some useful links:
Superuser StackExchange: How to prevent VScode from closing editor when pressing ctrl+w with no tabs open?
Issue #54492: Remove CtrlCmd+W keybinding to close window when no editors are opened
The behavior of the shortcut ctrl+w is as-designed closing the application
Actually, VSCode 1.57 (May 2021) will change that:
Removed Cmd+W / Ctrl+W as keybinding to close window when no editor is opened
We have gotten feedback that users are frustrated when the window suddenly closes after having closed the last editor via rapid Cmd+W / Ctrl+W usages.
A quick poll in the team also revealed that many had the keybinding for closing a window unassigned, so we went ahead and removed Cmd+W / Ctrl+W as keybinding to close window when no editor is opened.
You can easily bring the keybinding back by configuring it as follows:
{
"key": "cmd+w", // use "ctrl+w" on windows
"command": "workbench.action.closeWindow",
"when": "!editorIsOpen && !multipleEditorGroups"
}
Note: on all platforms there is a dedicated assigned keybinding to close the window:
macOS: Cmd+Shift+W
Linux: Alt+F4
Windows: Alt+F4
If what you are looking for is to preserve empty groups as well as empty editor windows, there is an option in the preferences that gets you almost all of the way:
"workbench.editor.closeEmptyGroups": false
This has the effect that an editor group will stay open even if the last tab within it is closed.
but all of the solutions do not seem to be the ideal one of simply leaving the editor open but empty
Reddit has an answer providing you the ideal solution of leaving the editor open, but empty: close all tabs but leave editors open.
In brief, they suggest to use in rapid succession the "close all editors" and the "three column editor layout".
They suggest to create a macro like:
"macros": {
"closeAllTabs": [
"workbench.action.closeAllEditors",
"workbench.action.editorLayoutThreeColumns"
]
}
then bind it to a key combination. macrosRe is advised.
The behavior of the shortcut ctrl+w is as-designed closing the application, see #49023. It is advisable to remove the shortcut and cut the arm, since it is design to work like that. However, for version 1.43.1 a new comment was posted this year on a thread you linked. You might want to have a look at it as well.
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.
I wanted to know if there is a mac key binding that would work to show context menu while on the sidebar. I don't want to have to right click all the time to get the context menu and would prefer to have the key binding.
Add a key mapping. Sublime Text > Preferences > Key Bindings-User. For example you could use Ctrl+h (not assigned), syntax is below.
[
{ "keys": ["ctrl+h"], "command": "context_menu" }
]
Add a keybinding by:
Ctrl + Shift + P (or Cmd+Shift+P on OSX), then type: Preferences: Key Bindings,
Then assign Ctrl + ' (as an example, you can use any key binding) using the following syntax:
[
{ "keys": ["ctrl+'"], "command": "context_menu" }
]
This is more of a MAC related question, than sublime text related. As I don't own a MAC myself, I can only give you some advice:
Question is, what are you trying to achieve with right clicking? There are loads of useful keyboard shortcuts, which basically do the same thing and either exist by default, or can be easily set in the key bindings file manually (if you don't know how, have a look here).
For quick file switching and navigation, I highly recommend you getting used to "Goto Anything" (Command+P). Getting yourself used to this is the hardest part, but once you got used to, you don't want to turn back.
For file and folder creation there are useful plugins which work on command line basis and by far more efficient than clicking, scrolling, searching... just saying.
I also highly recommend these excellent sublime text tutorials by jeffrey way.
I have some HTML I'd like to fix:
<label>Name<label>
As you can see, this isn't closed. When I attempt to close the element, I get:
<label>Name</label>label>
Which then requires manual fixing.
How can I make Sublime autocomplete work, or disbale it? Note I already have:
"auto_complete": false
In my user preferences.
This is not auto_complete as I know as auto_complete is triggered on tab and other key presses.
What you seek is auto_close_tags, setting it to false will not bother you anymore with this autocompletion, as to fixing this - I don't have such problems in ST3, so consider simply updating.
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.