What's a quick way to comment/uncomment lines in Navicat query editor? - navicat

In Navicat, how do I enclose a selection in a comment?
Is there a keyboard shortcut for this action?

Ctrl + / - To comment a block of code
Ctrl + Shift + / - To uncomment a block of code

Place -- in front of the line.
Or if you want to comment a block place /* at the beginning and */ at the end of the block.

Navicat For Mysql shortcut keys:
Ctrl+Q - open a query window.
Ctrl+/ - notes or comment in the SQL statement.
Ctrl+Shift+/ - release notes or uncomment the Query.
Ctrl+R - run all query the SQL statement window.
Ctrl+Shift+R - run the SQL selected statement only.
Ctrl+N - open a new query window.
Ctrl+W - close current query window.

Related

VIM move in Insert mode

Why I ask:
I use to enter code for example if(condition){}, in following step:
if(){
}
move cursor back into () to complete condition
move cursor into {} to add task
I have read Traversing text in Insert mode, and I add follow code into my $HOME/.vimrc
" key mapping
inoremap <A-h> <C-o>h
inoremap <A-j> <C-o>j
inoremap <A-k> <C-o>k
inoremap <A-l> <C-o>l
now I can use Alt+h and Alt+l, but the rest of two new map had no effect, then I test: Ctrl+oj and Ctrl+ok, both of them work.
Is there any mistake when I do the key mapping?
How to check if my new mapping is conflicted with other or not?
UPDATE: 2nd/Nov/2016
I buy a new keyboard with cursor key...
Install auto pair
However, I found one interesting thing, when I in Linux, there is ok for all above mapping just except Alt+h, because it conflicted with the ubuntu current open window help menu. I only meet my problem when I use ssh via MobaXerm application.
I have read Traversing text in Insert mode, and I add follow code into
my $HOME/.vimrc
You should carefully read the accepted answer for that answer, specially this part:
The right way is to press Esc, go where you want to do a
small correction, fix it, go back and keep editing. It is effective
because Vim has much more movements than usual character
forward/backward/up/down. After you learn more of them, this will
happen to be more productive.
The answer where you borrowed the mappings also mentions this:
Notwithstanding what Pavel Shved said - that it is probably more
advisable to get used to Escaping Insert mode - here is an example set
of mappings for quick navigation within Insert mode: (...)
Anyway, if you want to understand the problem with the Alt+j and Alt+k, you should first ensure that the mapping is still defined in Vim (they could have been erased or overwritten). You can use :imap to list them; try these:
:imap <A-j>
:imap <A-k>
If your mappings are correctly defined each one will list its target (e.g.: * <C-O>j). In this case you should check if Vim is receiving these combinations correctly; try inserting then in the text (insert mode) by using Ctrl+V (or Ctrl+Q if you mapped that to paste from clipboard) and the Alt combinations. You can get more details at the Vim FAQ "I am not able to create a mapping for the key. What is wrong?".
Edit:
If your issue is mainly related with closing parenthesis, then there are several other options, which I believe that are more practical. I quick internet search returned the following:
SO - Automatic closing brackets for Vim
Vim wiki - Making Parenthesis And Brackets Handling Easier
plugin - Auto Pairs
I also think that you misuse Vim.
I know that the question was about something else but here is my idea of how you should move around in vim.
You have 3 steps:
1. Insert some empty loop / condition
2. Insert a condition
3. Insert a body of the loop / condition
This should represent 3 changes, each separated by leaving the insert mode.
To do it properly you can perform step 1 and then leave insert mode by using either Esc or Ctrl+[ (with the second one- which is also vim default- you do not have to reach for escape key).
Then you should navigate to the place where you want to insert your change using h,j,k or l and follow it by starting insert mode.
There are several ways to start insert mode:
I - start insert mode at the beginning of the line (omitting whitespaces at the beginning)
i - start insert mode before the cursor
a - start insert mode after the cursor
A - start insert mode at the end of the line
s - change the sign under the cursor (can be combined with visual mode)
c - change text from under the cursor until place you have specified with the movement (e.g. ce - change until the end of the word, cl - the same as "s")
C - change everything from cursor until the end of the line
S - replace the whole line
o - start insert mode in the new line below
O - start insert mode in the new line above

How to select multiple places (sublime) in code in Android Studio?

How to select multiple places in code in Android Studio ?
I want to insert the same text in multiple places in my source code. Like a have more than one mouse cursor. I used to do it in VS2012 so easily though not sure how to do it in Android Studio ?
I found how and lets share this cool feature with you. I found three cool features:
For multiple selection just hold alt + shift then select whenever you want to change by mouse click then type some thing you can write at multiple places at the same time.
Another cool feature is column selection. This lets you to click in a great manner and greatly of help especially when you are refactoring.
In most systems it works with holding middleMouseButton and dragging over your code and in others it works by holding alt and selecting code it acts like below:
the third cool feature is sublime selection it finds the same word in code and let you change that or append that easily. you can do that by pressing alt + j on Windows / Linux and ctrl + g in mac. Look how it works:
Also as #Narayana said in comments, Ctrl + Shift + Alt + j selects all occurrences in one shot, for one-shot refactoring.
You can use Alt + Shift and click multiple locations to for multiple cursor.
To select similar occurrences in files use Alt + j.
For more details : Click Here
Multiline Caret (without mouse)
Windows: CTRL + CTRL(Hold) + ↑ / ↓
Mac: ⌘ + ⌘(Hold) + ↑ / ↓
ESC will end multiline mode.
Change Multi-caret Hotkey
To add a custom Keymap, CTRL+SHIFT+A, type keymap and click on the one with Settings as subtext. Search for Clone Caret Above and Clone Caret Below.
I mapped mine to ALT+SHIFT+↑ / ↓.
Bonus
Try holding combinations of CTRL, SHIFT, and arrows for improved selection power.
For both Mac and Windows, just open the Context Menu and click on the "Column selection mode" to enable or disable the behaviour..
On a MacOS you can use:
Tap: Control + Command + G - Select all the same value
Tap: Control + G - Every tap combination select the new same value
Hold: Option + Mouse Click - Select multiline with a mouse
Hold: Option + Shift and Tap: Mouse Click - duplicate cursor for a each tap place
Press Shift + Alt + Insert combination to edit in Column selection mode.
On a mac I like to do ⌥ (option) + shift + mouse click on multiple lines in Android Studio 3.1.3.
Use the following:
ALT + SHIFT
on Mac , hold OPTION + SHIFT then use the mouse to highlight what you want to select
On Windows, you can try a plugin whose name is ConyEdit. It has a great column mode based on regular expression.
I'm using android studio arctic fox and pressing Alt alone and then selecting code is working properly in windows.

Switch automatically between normal and insert mode in vim

I am new to vim and have installed oh-my-vim and learnt these keybindings by googling:
Jump forward by word - w
Jump forward by word - b
Jump to end of sentence - A
Close current file without exiting - bd
Undo is u
Execute shell command with ! (bang)
of these typing Shift + a in Normal mode allows me to jump to end of sentence and also goes into insert mode soon as I start typing after it. I tried out Shift + w and Shift + b and
it also shows similar behaviour of going to insert mode as soon as I start typing after I use that keybinding.
What are the equivalents for these keybindings where I am not using a letter?
Jump to start of sentence - 0
Redo is Ctrl + R
Jump to previous line - ``
Hope I am clear in describing. Thanks!
I'm also a beginner and I am getting used to Vim recently.
Well, regarding your question, to switch from Normal to Insert, you could press:
i to insert (the cursor stays, effectively inserting to the left)
a to append (the cursor jumps after the character you were on)
I to insert from the beginning of the line. This is equivalent to pressing 0 in Normal mode, and then pressing i to enter Insert mode.
A to append to the end of the line. This is equivalent to pressing $ in Normal mode to get to the end of the line, and then pressing a to append in Insert Mode.
For Insert to Normal:
press <Esc> to get to Normal mode.
press <Ctrl-[> to get to Normal mode.
press <Ctrl-O> to temporarily enter Normal mode for one command. Upon execution it will automatically return to Insert mode.
Personally, to shift between Normal mode, I use <Ctrl-[> for consecutive commands in Normal mode and <Ctrl-O> if it's a one time deal. <Esc> is too far for my pinky :)
It's not entirely clear what you are asking. Shift+W and Shift+B do not automatically enter insert mode, instead they go back and forth on WORDS (vs words).
If you want to enter insert mode, just hit i. You could hit wi to insert after a word.
You mention 0, which goes to the beginning of a line. You can hit I (shift+I) to insert at the beginning of a line. Note that this inserts after the initial whitespace on the line, it is the same as hitting ^i. If you want to insert at the very beginning of the line, you'll need to use 0i.

A keyboard shortcut to comment/uncomment the select text in Android Studio

How do I comment out several lines of text selected in the IDE with a control key combination?
I thought that Ctrl + Alt + C was the correct sequence, but that's not working.
To comment/uncomment one line, use: Ctrl + /.
To comment/uncomment a block, use: Ctrl + Shift + /.
MAC QWERTY (US- keyboard layout) without numpad:
Line comment : ⌘ + /
Block comment: ⌘ + ⌥ + /
MAC QWERTZ (e.g. German keyboard layout):
Android Studio Version ≥ 3.2:
Line comment : ⌘ + Numpad /
Block comment: ⌘ + ⌥ + Numpad /
thx #Manuel
Android Studio Version ≤ 3.0:
Line comment : ⌘ + -
Block comment: ⌘ + Shift + -
From menu, Code -> Comment with Line Commment. So simple.
Or, alternatively, add a shortcut as the following:
I had the same problem, usually, you have found the shortcut but it doesn't work because you have not a NumPad.
Actually, the only one issue I found is to set my own shortcut with the one I suppose should works.
First step, find the IDE shortcuts : cmd + shift + A enter shortcuts
Second step : Find Comments Shortcut with the finder
Third step : Set your custom shortcut (I suggest cmd + shift + / or cmd + : )
Now enjoy, it works on a macBook without NumPad
edit : cmd + shift + : has conflicts
Edit : this both works without conflicts
Issue on MacBook
At least in Android Studio 2.2.3 with default key mapping, to comment or uncomment a select text, same hotkeys are used as Toggle. Using the hotkeys changes the state from comment to uncomment, and next time Uncomment to comment on next and vice versa.
1. Comment / uncomment a block of code
Comment sample: /* --- Code block ---- */
Hotkey: Ctrl + Shift + "/"
Using the same key combinations again will "toggle" commenting or uncommenting the selection.
2. Comment / uncomment a line of code
Comment sample: // -- Code ---
Hotkey: Ctrl + "/"
Using the same key combinations again will "toggle" commenting or uncommenting the selection.
Note: Key mapping can be changed to different schemes like eclipse, visual studio... or to the custom hotkeys in File -> Settings -> Keymap
On Mac you need cmd + / to comment and uncomment.
if you are findind keyboard shortcuts for Fix doc comment like this:
/**
* ...
*/
you can do it by useing Live Template(setting - editor - Live Templates - add)
/**
* $comment$
*/
You can also use regions. See https://www.myandroidsolutions.com/2014/06/21/android-studio-intellij-idea-code-regions/
Select a block of code, then press Code > Surround With... (Ctrl + Alt + T) and select "region...endregion Comments" (2).
Windows 10 and Android Studio: Ctrl + / (on small num pad), don't use Ctrl + Shift-7!
Default shortcuts is under Preferences -> Keymap -> Main Menu -> Code menu
Add a shortcut for a single line comment (e.g. Ctrl+ ...)
Add a shortcut for a block comment (e.g. Ctrl+...)
You can use default one or customize it by right click

PhpStorm and IdeaVim - shortcut to complete line?

I'm using the current PHP Storm EAP (138.1505) and IdeaVim 0.35.
Suppose I just want to type:
print_r($foo);
I press i to go into Vim insert mode.
I type p r and I can choose print_r via the autocomplete.
It'll add open and close braces () for me.
I start typing my variable, it'll let me autocomplete that too.
At this stage I have print_r($foo) with my cursor positioned before the closing bracket.
What I'd like now is a single key combination that'll finish the line for me - i.e. add a semi-colon and a carriage return. At the moment I either have to type );[return] by hand as if the autocomplete wasn't there, or for some reason I've got in the habit of doing esc to leave insert mode then A to continue at the end of the line and ;[return][esc]to finish it off, which is even longer.
Any better way?
I don't use PHP Storm. but I do use Intellij + ideavim.
Here I can press Ctrl-Shift-Enter to complete a line. It is a kind of default setting. You can find it under menu: Edit: complete current statement
You may want to give it a try.
You can add this line to ~/.ideavimrc:
imap <C-e> <Esc>A;<CR>
Replace <C-e> with your desired key.

Resources