How can I change that? I don't see any option in the preferences nor do I know of any plugin.
I want to avoid this style:
class Foo
{
private:
void bar();
}
EDIT:
I'm using C++ and my style is like this:
class Foo
{
private: // Half tab (or two spaces)
void bar(); // One tab
}
While I'm used to simply typing two spaces then private: and hit Enter,now I have to type private: hit Enter and navigate back to private to re-indent it. It's kind of a workflow kill.
Found the best way to disable auto unindent on public private and protected keywords, by editing the Indentation Rules.tmPreferences file in Packages/C++. What I did is comment out the line:
| ^ \s* (public|private|protected): \s* $
under the decreaseIndentPattern key.
Since the other answer isn't really complete, here in detail for anyone else:
Install Package Control: https://packagecontrol.io/installation.
Install PackageResourceViewer: https://packagecontrol.io/packages/PackageResourceViewer
Open Command Palette in Sublime Text (Cmd + Shift + P on Mac)
Search for PackageResourceViewer: Open Resource and click Enter
In the new search panel type in C++ and click Enter
In the next panel type in Indentation Rules.tmPreferences and click Enter
In that file search for the line | ^ \s* (public|private|protected): \s* $ and comment it out by writing <!-- in front of the line and --> at the end of the line. There might be two occurences of said line, for me it was enough to comment out the first one.
Note that the public following private now needs to be manually alined with private though. If somebody knows how to fix this please comment.
Related
I am working on an application where user can add comments to certain fields. these comments can also be links. So, as a user I want to be able to click on those links rather than copy pasting them in a new tab.
If a normal web link ([http://|http:]... or [https://|https:]...) occurs in a comment/attribute value, it should be presented as a clickable link.
Multiple links may occur in the same comment/attribute value.
Clicking on a link opens a new browser tab that calls up this link.
This is how the formControl is being managed. I think i can identify multiply links with the help of regex but how do I make them clickable as well?
Thanks for answering and helping in advance.
this.formControl = new FormControl('', [this.params.customValidations(this.params)]);
this.formControl.valueChanges.subscribe(() => {
this.sendStatusToServices();
});
Outside the form editor/input (most likely what you're looking for)
Either before saving the value of the Form Field to the Database, or editing the received body from the database just before presenting to the user, you can use Regex to replace links with anchor tags.
function replaceURLWithHTMLLinks(text) {
var exp = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&##\/%?=~_|!:,.;]*[-A-Z0-9+&##\/%=~_|])/ig;
return text.replace(exp,"<a href='$1'>$1</a>");
}
Rich text editor
If however, you're trying to enable links INSIDE the form input (like WordPress's text editor), that's going to be a bit more difficult. You'll need a <textarea> to enable custom HTML elements. Then you need to detect when the user has typed a URL, so you can call replaceURLWithHTMLLinks(). Honestly, you should just use a package. There's several good one out there.
Angular Rich Text Editor - A WYSIWYG Markdown Editor, by SyncFusion
NgxEditor, by sibiraj-s
typester-editor
Hope this helps
Using a regex approach and a pipe I was able to come up with something like below.
What I'm doing is replacing the links with hyperlink tags using a proper regex.
url replacement regex is taken from here
Supports multiple links within same comment.
Here is the sample pipe code
#Pipe({
name: 'comment'
})
export class CommentPipe implements PipeTransform {
constructor(private sanitizer: DomSanitizer){}
transform(value: any, args?: any): any {
const replacedValue = this.linkify(value);
return this.sanitizer.bypassSecurityTrustHtml(replacedValue)
}
// https://stackoverflow.com/questions/37684/how-to-replace-plain-urls-with-links#21925491
// this method is taken from above answer
linkify(inputText: string) {
var replacedText, replacePattern1, replacePattern2, replacePattern3;
//URLs starting with http://, https://, or ftp://
replacePattern1 = /(\b(https?|ftp):\/\/[-A-Z0-9+&##\/%?=~_|!:,.;]*[-A-Z0-9+&##\/%=~_|])/gim;
replacedText = inputText.replace(replacePattern1, '$1');
//URLs starting with "www." (without // before it, or it'd re-link the ones done above).
replacePattern2 = /(^|[^\/])(www\.[\S]+(\b|$))/gim;
replacedText = replacedText.replace(replacePattern2, '$1$2');
//Change email addresses to mailto:: links.
replacePattern3 = /(([a-zA-Z0-9\-\_\.])+#[a-zA-Z\_]+?(\.[a-zA-Z]{2,6})+)/gim;
replacedText = replacedText.replace(replacePattern3, '$1');
return replacedText;
}
}
Here is the completed stackblitz
If you want links within Input itself you might want to try different approach
I am looking for a way, for Sublime Text, to add the "necessary" format in the editor after selecting the language from the syntax drop-down menu.
For example:
After selecting HTML, I want the editor to immediately add, for example, <!doctype html> <head> <body> <title>, et cetera, et cetera.
Is there a way for me to do this, or do I need to download/add certain plugins?
The emmet plugin might do its job.
This is possible with a simple plugin. You can listen for when the syntax is changed to HTML, check the file is otherwise empty, and if so, insert the HTML snippet.
Tools menu -> Developer -> New Plugin...
Replace the template with the following code:
import sublime
import sublime_plugin
class SyntaxChangeListener(sublime_plugin.EventListener):
def on_post_text_command(self, view, command_name, args):
if view.size() > 0:
return
if command_name == 'set_file_type':
if args['syntax'] == 'Packages/HTML/HTML.sublime-syntax':
view.run_command('insert_snippet', { 'name': 'Packages/HTML/Snippets/html.sublime-snippet' })
Save it, in the folder ST recommends (Packages/User) as something like insert_html_snippet_for_new_files.py - the name itself doesn't matter, as long as the file extension is py.
Open a new tab
Set the syntax to HTML
See the HTML snippet get automatically inserted
So I know autocomplete works great when you start typing a value. For example, the second you type the "c" in text-align:center, the available autocomplete values pop up (such as center, left, right).
However, when I used Dreamweaver, for properties with specific value options like text-align (center, right, left), display (block, inline-block), cursor (pointer, default), etc., the autocomplete popup would show immediately after the property was typed, it did NOT wait until I started typing a value. Right after text-align: was typed out, it would show me the autocomplete popup giving me the options center, right, left.
The value autocomplete should fire right after my property autocomplete fires:
So after I type te...
the autocomplete popup for "te" properties displays text-align, text-decoration, text-shadow etc....
then I press Enter to select text-align...
then immediately after pressing Enter an autocomplete popup should show for the text-align values: center, left, right.
Any idea how this can be accomplished in Sublime Text 3?
You can get ST to show the autocompletion popup again straight after a completion has been inserted using a small plugin and some preferences:
With a CSS file open in ST, open the Preferences menu and select Preferences - Syntax Specific. Add the following to the settings on the right hand side:
"auto_complete_triggers":
[
{
"characters": ": ",
"selector": "source.css meta.property-list.css meta.property-value.css"
},
],
and save it. This will tell ST to show the autocomplete popup automatically in CSS files when typing a : or a space when the syntax expects a property value.
Now, unfortunately, ST doesn't consider an autocompletion to have "typed" anything, so this trigger isn't fired automatically when selecting a property value like text-align from the autocomplete popup, which inserts text-align:. So, to get round that, this is where we need a small plugin. From the Tools menu, choose Developer -> New Plugin...
Select all text and replace with the following and save it, in the folder ST recommends (Packages/User/) as something like show_autocomplete_after_completion.py:
import sublime
import sublime_plugin
class AutoCompleteListener(sublime_plugin.EventListener):
def on_post_text_command(self, view, command_name, args):
if command_name in ('commit_completion', 'insert_best_completion'):
act = view.settings().get('auto_complete_triggers', [])
scope = view.scope_name(view.sel()[0].begin())
char = view.substr(view.sel()[0].begin() - 1)
for trigger in act:
if sublime.score_selector(scope, trigger['selector']) > 0:
if char in trigger['characters']:
view.run_command('auto_complete', { 'insert_best_completion': False })
break
This plugin basically detects when a completion has been inserted (although due to a limitation of the ST API, it can't detect when you click on an entry with the mouse - see https://github.com/SublimeTextIssues/Core/issues/1166), and if the text/character immediately before the caret matches one of the autocompletion triggers defined in the settings, then it will show the autocomplete popup again.
You can try out this package. This package indexes your .less and .scss (or .sass) and caches your mixins, variables, class or id names and autocompletes both on html and css. It autocompletes your less and sass mixins with mixin arguments. It also supports emmet completions and gets your css classes on popup window. -
https://github.com/subhaze/CSS-Extended/
<?php
class Hello
{
public function hello()
{
return "";
}
}
I have function and I need to give comments and write documents for the same, like #param, #return.
How can I do that?
I am very new to PhpStorm.
What you are asking about is called PHPDoc: PSR-5: PHPDoc.
1) Place the caret before the required code construct (class, method, function, and so on), type the opening block comment /**, and press Enter.
2) In the editor context menu, select Generate | Generate PHPDoc blocks and choose the code construct to generate PHPDoc comments for.
3) Press Alt+Insert, then select Generate PHPDoc blocks, and choose the code construct to
generate PHPDoc comments for.
You can check this link for more info.: https://www.jetbrains.com/help/phpstorm/phpdoc-comments.html
Given a view with the following Razor code:
#Url.Action("Index", "Home")
I want to add an Area parameter like so:
#Url.Action("Index", "Home", new { Area = "Manage" })
But when I start typing, this happens:
#Url.Action("Index", "Home", new object{Area = ""Manage"}) // broken double quote
How do I stop Visual Studio from completing the broken double quote so I don't have to play tetris for each link? Could ReSharper be causing this? I can't find the option for it.
If you type your code inside attribute, for example
<a href="#Url.Action("Index", "Home", new { Area = "Manage" })">
then ReSharper can erroneously add a quote, resulting in "Manage"". This should be fixed in the last ReSharper 7.0 EAP releases. In previous versions, try turning off ReSharper | Options -> Environment | Editor -> Auto-insert pair brackets, parenthesis and quotes.
I find that feature quite nifty but if you want it out of your way, then:
1. Go to "Tools" > "Options".
2. Expand the "Text Editor" node.
3. Expand the "HTML" node.
4. Uncheck the "Insert attribute value quotes when typing" field.
If you have ReSharper, then do this:
1. Go to ReSharper -> Options -> Intellisense -> General.
2. Check the Visual Studio option.
This will leave ReSharper out of the intellisense loop.