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

%%%%%%%%%%%%%%%%%%%%%%%%%%% figure environment start %%%%%%%%%%%%%%%%%%%%%%%%%%%
\includegraphics [scale=0.35]{images/fig1.eps}
%%%%%%%%%%%%%%%%%%%%%%%%%%%% 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:

  • Welcome! Since you already saw the questions concerning snippets, could you explain the problem? Why can't you just define the snippet and assign it a shortcut? That works fine for me. – cfr Apr 12 '16 at 19:38

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.

  • Thanks a lot! A small followup question, if i open a blank tex file in kile, can i insert previously defined templates into it. I know if i want a new template we can use those from kile but i don't know how to insert old templates into a new blank file? – Poudel Apr 13 '16 at 13:57
  • Why don't you just select the relevant template rather than a blank one when you create the new file? – cfr Apr 13 '16 at 18:02

Your Answer

