I PHPStore when you press ctrl+w it will selection the the content between brackets and the brackets themselves in on step. Is there any config to force it select only content without brackets?
Update: consider the following example:
if(true) {
echo "Hi"; |
echo "Bye";
}
The caret is at the end of the second line. Pressing ctrl+w triple times will select block+brackets.
Related
I am working on a Blazor textarea input. What I want to achieve is whenever user types "#" character, I am going to popup a small window and they can select something from it. Whatever they select, I will insert that text into the textarea, right after where they typed the "#".
I got this HTML:
<textarea rows="10" class="form-control" id="CSTemplate" #bind="original" #oninput="(e => InputHandler(e.Value))" #onkeypress="#(e => KeyWasPressed(e))"></textarea>
And the codes are:
protected void InputHandler(object value)
{
original = value.ToString();
}
private void KeyWasPressed(KeyboardEventArgs args)
{
if (args.Key == "#")
{
showVariables = true;
}
}
protected void AddVariable(string v)
{
original += v + " ";
showVariables = false;
}
This worked very well. The showVariables boolean is how I control the pop-up window and AddVariable function is how I add the selected text back to the textarea.
However, there is one small problem. If I've already typed certain text and then I go back to any previous position and typed "#", menu will still pop-up no problem, but when user selects the text and the insert is of course only appended to the end of the text. I am having trouble trying to get the exact caret position of when the "#" was so I only append the text right after the "#", not to the end of the input.
Thanks a lot!
I did fast demo app, check it https://github.com/Lupusa87/BlazorDisplayMenuAtCaret
I got it - I was able to use JSInterop to obtain the cursor position $('#CSTemplate').prop("selectionStart") and save the value in a variable. Then use this value later in the AddVariable function.
you can set your condition in InputHandler and when you are checking for the # to see if it's inputed you can also get the length to see that if it's just an # or it has some characters before or after it obviously when the length is 1 and value is # it means there is just an # and if length is more than one then ...
I have a question that bothers me for a long time, here some code as below,
if (flag) {
// some code here
}
else | // cursor here
when I press shift + command + enter (on Mac) to complete automatically, it restyled my code as
if (flag) {
// some code here
} else {
|
}
and I just wanna it complete but never effect on my own style, i.e.
if (flag) {
// some code here
}
else {
|
}
is there any settings about this manner for IntelliJ IDEA? thanks in advance:)
It's likely a setting in your code style that had forced this. By default, IntelliJ does not force the else statement to go to a separate line.
Navigate to Settings > Editor > Code Style > Java, select the Wrapping and Braces tab, and tick the "'else' on new line" checkbox. This will then force all of your else statements to be on their own separate line as you wish.
While using AutoHotKey I wanted to setup a rule to swap the left alt and left ctrl. I can do this by doing:
LAlt::LCtrl
LCtrl::LAlt
I then wanted to keep the 'alt tab' functionality bound do those physical keys, thus I tried
LCtrl & Tab::AltTab
In addition to the two uptop, yet it won't work. If I put it like so:
LCtrl & Tab::AltTab
LAlt::LCtrl
LCtrl::LAlt
Then the tab will work, however the ctrl alt swap will be broke. Any suggestions?
The hotkey documentation talks about wildcards
Wildcard: Fire the hotkey even if extra modifiers are being held down. This is often used in conjunction with remapping keys or buttons. For example:
*#c::Run Calc.exe ; Win+C, Shift+Win+C, Ctrl+Win+C, etc. will all trigger this hotkey.
*ScrollLock::Run Notepad ; Pressing Scrolllock will trigger this hotkey even when modifer key(s) are down.
So try this
*tab::
{ if(GetKeyState("LAlt", "P"))
{ Send {LControl up}{Alt down}{tab}
KeyWait, tab
}else
{ send {tab}
}
return
}
~LAlt Up::
{ send {lalt up}
return
}
LAlt::LCtrl
LCtrl::LAlt
I improved this slightly to fix shift tab not working, now you can use Shift+tab as expected where as before you couldn't (was frustrating trying to fix indentation(outdent) when coding) I may improve this more and get Shift+Alt+Tab working
*tab::
{
if(GetKeyState("LAlt", "P")){
Send {LControl up}{Alt down}{tab}
KeyWait, tab
} else if(GetKeyState("LShift", "P")){
Send {LShift down}{tab}
KeyWait, tab
}else
{ send {tab}
}
return
}
~LAlt Up::
{ send {lalt up}
return
}
LAlt::LCtrl
LCtrl::LAlt
Just ran into the same problem myself, was looking for a more straightforward solution. If you swap Alt and Ctrl using SharpKeys (or other registry remapping tool) from there it's a simple:
RCtrl & Tab::AltTab
I want to comment out a block of code in sublime text.
I see it in RailsCasts, but don't think he uses sublime text ... to do the following ...
if (uncommented)
some uncommented example
# if (commented)
# some commented example code
# end
end
Is there a shortcut in sublime text that I can use to insert the block of #'s?
The shortcut to comment out or uncomment the selected text or current line:
Windows: Ctrl+/
Mac: Command ⌘+/
Linux: Ctrl+Shift+/
Alternatively, use the menu: Edit > Comment
For the block comment you may want to use:
Windows: Ctrl+Shift+/
Mac: Command ⌘+Option/Alt+/
You're looking for the toggle_comment command. (Edit > Comment > Toggle Comment)
By default, this command is mapped to:
Ctrl+/ (On Windows and Linux)
Command ⌘+/ (On Mac)
This command also takes a block argument, which allows you to use block comments instead of single lines (e.g. /* ... */ as opposed to // ... in JavaScript). By default, the following key combinations are mapped to toggle block comments:
Ctrl+Shift+/ (On Windows and Linux)
Command ⌘+Alt+/ (On Mac)
With a non-US keyboard layout the default shortcut Ctrl+/ (Win/Linux) does not work.
I managed to change it into Ctrl+1 as per Robert's comment by writing
[
{
"keys": ["ctrl+1"],
"command": "toggle_comment",
"args": { "block": false }
}
,
{ "keys": ["ctrl+shift+1"],
"command": "toggle_comment",
"args": { "block": true }
}
]
to Preferences -> Key Bindings (on the right half, the user keymap).
Note that there should be only one set of brackets ('[]') at the right side; if you had there something already, copy paste this between the brackets and keep only the outermost brackets.
Ctrl-/ will insert // style commenting, for javascript, etc
Ctrl-/ will insert <!-- --> comments for HTML,
Ctrl-/ will insert # comments for Ruby,
..etc
But does not work perfectly on HTML <script> tags.
HTML <script> ..blah.. </script> tags:
Ctrl-/ twice (ie Ctrl-/Ctrl-/) will effectively comment out the line:
The first Ctrl-/ adds // to the beginning of the line,
which comments out the script tag, but adds "//" text to your webpage.
The second Ctrl-/ then surrounds that in
<!-- --> style comments, which accomplishes the task.
Ctrl--Shift-/ does not produce multi-line comments on HTML (or even single line comments), but does
add /* */ style multi-line comments in Javascript, text, and other file formats.
--
[I added as a new answer since I could not add comments.
I included this info because this is the info I was looking for, and this is the only related StackOverflow page from my search results.
I since discovered the / / trick for HTML script tags and decided to share this additional information, since it requires a slight variation of the usual catch-all (and reported above)
/ and Ctrl--Shift-/ method of commenting out one's code in sublime.]
You can toggle the block comment with
Ctrl+Shift+/
Source: http://www.sublimetext.com/forum/viewtopic.php?f=3&t=2967
Just in case someone is using the Portuguese ABNT keyboard layout
The shortcut is
Ctrl + ;
Just an important note. If you have HTML comment and your uncomment doesn't work
(Maybe it's a PHP file), so don't mark all the comment but just put your cursor at the end or at the beginning of the comment (before ) and try again (Ctrl+/).
In mac I did this
type your comment and press command + D to select the text
and then press Alt + Command + / to comment out the selected text.
with my keyboard (logitech) here in Italy I can:
select the portion of text with the mouse and then with [ctrl + ù] comment or uncomment.
select the line and use the same command.
with [ctrl + shift] and using the left and right cursors I select the text. then using the up and down keyboard cursors I move the selected text up or down the page.
(SublimeText)
Greetings
TigerMat90
If you don't have a US keyboard, the conventional Ctrl + / can be used to comment your code in Sublime Text just by changing the Sublime Key map Configuration (the right side file) and changing the character '/' for 'keypad_divide' which is the identifier for the '/' symbol in non US keyboards, as shown in the Sublime Text Official documentation
Writing the following on Preferences > Key Bindings right file should work.
[
{
"keys": ["ctrl+keypad_divide"],
"command": "toggle_comment",
"args": { "block": false }
}
,
{
"keys": ["ctrl+shift+keypad_divide"],
"command": "toggle_comment",
"args": { "block": true }
}
]
I am writing FuncUnit for my application. I am browsing the application in Google Chrome. I have a textbox which is initially hidden. I need to make it visible and then clear the text already present in that textbox. I have the following code which makes the box visible but fails to clear the text in it.
S('#search').visible().clearText();
Can anyone tell what is wrong here?
Try to clear the textbox by typing - Ctrl+A and Delete.
var input = S('input.my-input');
input.type('[ctrl]a[ctrl-up][delete]', function() {
// Continue in test case after the text has been removed
});
Your statement is not accurate. visible() does not turn things visible. It is a wait function which waits for the source element to become visible before proceeding to the next action.
koalix's key sequence works. With the type() command you might need to first click into the text input before clearing it.
Try:
S('#search').visible().click().type('[ctrl]a[ctrl-up][delete]');
You could also try empty quotes <" ">
var input = S('input.my-input');
input.type('', function() {
// remove existing text
});
I don't know if you're still waiting for an answer.
I think you're not using visible() in the correct way.
In FuncUnit (see docs here), among other things, you can distinguish between "actions" and "waits". visible() is a wait, and should be used to wait for an element to become visible, like this:
S('#el').visible( function() {
// do something when element with id="el" becomes visible
});