In TeXstudio, to create a new code snippet and associate it with a keyboard shortcut, you can create a Macro and then assign a Shortcut to it.
To do this:
1. Go to the "Macros
" menu and choose "Edit Macros
"
2. In the "Edit Macros
" dialog, click on the "Add
" button, in the lower left corner of the dialog
3. Give the "Macro" a Name, fill the "Abbreviation
" text field with $..$
and put your LaTeX code in the "`LaTeX Content" text area with your LaTeX code in this method leave the "Type" radio button with the default value of "Normal"), as illustrated below:
EDIT: As an alternative method, in this "Step 3", (Step of the "Edit Macros
" dialog) - and since the idea is to "create" a new environment (in this case, bmatrix) - you may choose the "Environment
" radio button, in the "Type
" option, instead of the default value of "Normal
". If you do that, make sure that %bmatrix
(yes, that percentage sign before bmatrix
is supposed to be there) is the content in the "LaTeX Content"
text area (and clear the content of the "Abbreviation" text field). The advantage of this alternative method, as I see it, is that the cursor will be "correctly" placed inside the environment when the Macro is activated. Here's a screenshot for this step with this alternative method:
4. Click in the "OK" button to close the dialog
5. Go to the "Options
" Menu and choose the "Configure TeXstudio...
" command (first command of the Options Menu)
6. In the "Configure TeXstudio...
" dialog, choose "Shortcuts" in the vertical navigation in the left side, and expand the "Menus" -> "Macros" option in the right hand side, to reveal your Macros, including your newly added "3: My Bmatrix Macro" like shown here:
7. Double click the "Current Shortcut
" column and press the "Ctrl+Shift+B" key combination. This will change the value of the column to "Ctrl+Shift+B
"
You'll probably get a warning dialog box saying that the Keyboard shortcut "Ctrl+Shift+B" is already assigned to the command "Unnamed Bookmark". Click on the "Yes
" button to accept the replacement of the Keyboard Shortcut.
8. Click on the "OK
" button on the "Configure TeXstudio...
" dialog to close it.
That's it! :-) Pressing Ctrl+Shift+B
in your documents will insert the code for the bmatrix
environment, from now on.
TeXstudio has a strange behavior with auto-completion: it does auto-suggestion and completion at the same time. It is frustrating to me as well but you can press ESC button at the end of typing to prevent TeXstudio from auto-completing the phrase.
Another solution would be to use TeXMaker (program that TeXstudio was forked from) and create User Tags (menu User
->User Tags
->Edit tags
). Define \phantom as a tag that you can insert by pressing e.g. Shift+F1 (for first user tag).
Best Answer
You need to disable
insert arguments
Go to Options > Configure TexStudio > Make sure that Advanced Options is checked > Completion > Uncheck
Insert arguments