4

I want to change the auto-completion of itemize from

\begin{itemize}
content ...
\end{itemize}

to

\begin{itemize}
  \item content...
  \item content...
  \item content...
\end{itemize}

However, I tried to find the latex-document.cwl, latex-mathsymbols.cwl, and tex.cwl (which are the defaults autocomplete files) with no luck.

So, how can I make TeXStudio to change the autocomplete behavior of this specific macro?

2 Answers 2

5

Here's a potential solution using user macros.

From the menu, select Macros -> Edit macros. Add a new macro called "Itemize selection" and paste the following for the macro code:

%SCRIPT
sel=cursor.selectedText().split('\n')
out="\\begin{itemize}\n"
for (line in sel){
    out += '\t\\item ' + sel[line] + '\n'
}
out += "\\end{itemize}"

cursor.replaceSelectedText(out)

Now click OK to save. Select the text in the editor that you wish to put into an itemize environment and select "Itemize selection" from the Macros menu.

Here's the result on some text.

First sentence.
Second sentence.
Third sentence.

to give

\begin{itemize}
    \item First sentence.
    \item Second sentence.
    \item Third sentence.
\end{itemize}
4

When you type \begin{itemize} the completion options are shown under the environments completion scheme, not under itemize completion. Hence you will get

\begin{itemize}
content ...
\end{itemize}

Here itemize is treated as an environment.

If you want itemize completion with \item use the menu \begin{itemize} available under, LaTeXList Environments. you will get

\begin{itemize}
\item 
\end{itemize}

Currently no short cut is been assigned to this, but you may create one (your own). (If any clarifications are needed in this feel free to ask). It is advisable not to put too many \items in the auto completion. You can put them by cntrl + shift + I as and when needed.

5
  • I understand that is the default behaviour, as it is an environment. However, I would like to change such behaviour to do what the menu you describe is doing. Furthermore, I would like to know how to do it, so I can tweak any other environments as needed.
    – adn
    Mar 7, 2014 at 13:01
  • @adn It is the default behaviour. But if you change it, other environments will be affected too. Hence it may be considered a limitation. Best is to define a shortcut foritemize and live happily.
    – user11232
    Mar 7, 2014 at 13:03
  • I don't want to change the behavior for all environments, but change it for each specific one. Is that possible?
    – adn
    Mar 7, 2014 at 13:18
  • 1
    @adn With present version, I don't think it is possible :( May be a good candidate for feature request.
    – user11232
    Mar 7, 2014 at 13:22
  • The <kbd> cntrl</kbd> + <kbd>shift</kbd> + <kbd> I</kbd> was perfect for my problem Jan 30, 2018 at 0:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .