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 "
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 "
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.