[Tex/LaTex] Kile: How to insert repeated code snippet and make keyboard shortcut in kile for LaTeX

code-snippetskilemacros

To insert figures in LaTeX document I use this code repeatedly:

%%%%%%%%%%%%%%%%%%%%%%%%%%% figure environment start %%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{figure}[hb!]
\centering
\includegraphics [scale=0.35]{images/fig1.eps}
\caption{mycaption.}
\label{fig:fig1}
\end{figure}
%%%%%%%%%%%%%%%%%%%%%%%%%%%% figure environment end %%%%%%%%%%%%%%%%%%%%%%%%%%%%

Is there any way i can make macro of this code block and create a keyboard shortcut such as CTRL+Shift+f that automatically insert this code.

Or, could we write a snippet and so that i can insert this code block in KILE text editor.
I know how to make template in kile but what I need is shortcut key that inserts this piece of code automatically.

Maybe I can create a simple text file somewhere in kile directory and use it. But I don't know how to do this.

Any suggestions will be greatly appreciated!
Related links:

Best Answer

Start selecting the desired text in a Kile document:

highlighted text

Keeping the text selected, choose Tools > Create Snippet from the menu to bring up the snippet creation dialogue:

create snippet

This allows you to specify the keyboard shortcut and other options of your choice.

Alternatively, choose Tools > Snippets... to create a snippet without basing it on text in the current document. In this case, you can just type the text from scratch into the dialogue box.

Tools > Snippets... also allows you to edit and manage existing snippets.

Related Question