I don't recommend this -- it does not look well and breaks the tradition of LaTeX commands.
The code is taken from egreg's answer at Using end-of-line delimiter in plain Tex macro (upvoted of course ;-))
There's actually nothing to gain from this and distracts from (proof)reading codes.
Especially \li is not really useful short version \item anyway.
The endline character has usually the catcode 5, so this is converted to a space or \par token (depending on the state) first before further processing the input. In order to make TeX recognize the end of line the catcode has to be changed, to 12 ('other'), in a group, so use
\def\chap{\begingroup\catcode`\^^M=12 \xchap}
{\catcode`\^^M=12 %
\gdef\xchap#1^^M{\chapter{#1}\endgroup}%
}
to read the content until the end of the line and let the temporary macro \xchap to the display of \chapter{...} etc. (the same for \sec and \subsec.)
Of course, such approaches will break \chap[foo]{foo bar}, i.e. the short version of the chapter title meant for ToC and page headings are not available any longer.
\documentclass[12pt]{report}
\def\chap{\begingroup\catcode`\^^M=12 \xchap}
{\catcode`\^^M=12 %
\gdef\xchap#1^^M{\chapter{#1}\endgroup}%
}
\def\sec{\begingroup\catcode`\^^M=12 \xsec}
{\catcode`\^^M=12 %
\gdef\xsec#1^^M{\section{#1}\endgroup}%
}
\def\subsec{\begingroup\catcode`\^^M=12 \xsubsec}
{\catcode`\^^M=12 %
\gdef\xsubsec#1^^M{\subsection{#1}\endgroup}%
}
\begin{document}
\chap My First Chapter
\sec My First Section
\subsec My First Section
\begin{itemize}
\item lkdsjfaljsfad
\item lkdsjfaljsfad
\item lkdsjfaljsfad
\end{itemize}
\end{document}
However, this is code golfing, in my point of view.
{}in macro arguments? ;-) – Jun 25 '17 at 11:57markdownpackage could be interesting for you – samcarter_is_at_topanswers.xyz Jun 25 '17 at 12:33\outer\def\beginsection#1\parand a blanck line is used as delimiter – touhami Jun 25 '17 at 12:44