# How to automatically truncate the length of a line in vim-latex?

Is there a way of automatically beginning a new line after reaching a particular length of a line in order to make navigation through a document easier in vim-latex?

Example (text from http://en.wikipedia.org/wiki/Giraffe):

\documentclass[letter,12pt]{article}
\usepackage[pdftex]{graphicx}
\usepackage{sidecap}

\begin{document}
\begin{SCfigure}
\centering
\includegraphics[width=0.55\textwidth]{Giraffa_camelopardalis_angolensis}
\caption{The giraffe (\emph{Giraffa camelopardalis}) is an African even-toed ungulate mammal, the tallest of all land-living animal species. Males can be 4.8 to 5.5~metres tall and weigh up to 1,360~kilograms. The record-sized bull was 5.87~m tall and weighed approximately 2,000~kg. Females are generally slightly shorter and weigh less than the males do.}
\end{SCfigure}
\end{document}


Getting this while typing:

\documentclass[letter,12pt]{article}
\usepackage[pdftex]{graphicx}
\usepackage{sidecap}

\begin{document}
\begin{SCfigure}
\centering
\includegraphics[width=0.55\textwidth]{Giraffa_camelopardalis_angolensis}
\caption{The giraffe (\emph{Giraffa camelopardalis}) is an African even-toed
ungulate mammal, the tallest of all land-living animal species. Males can be
4.8 to 5.5~metres tall and weigh up to 1,360~kilograms. The record-sized bull
was 5.87~m tall and weighed approximately 2,000~kg. Females are generally
slightly shorter and weigh less than the males do.}
\end{SCfigure}
\end{document}

-
Go to the specific line and press gqap. If you want to reformat the complete text, just select it in visual mode (ggVG<ESC>) and then do a gqap –  Daniel Apr 3 '12 at 11:04
This is actually a Vim question and belongs more on stackoverflow.com or superusers.com. Try to set textwidth=80 and ensure that formatoptions includes at least t. You best do this in the user config file (~/.vimrc under Linux). Existing lines can be broken my marking them and pressing <ESC>gw. –  Martin Scharrer Apr 3 '12 at 11:23
And please stop forcing the output driver (pdftex) on graphicx and other packages. This is no longer required and should be avoided. –  Martin Scharrer Apr 3 '12 at 11:24

If you want long lines to be wrapped while typing, use:

:set textwidth=72


or any other value.

In the .vimrc file:

autocmd FileType tex    set textwidth=72

-
I'd vote for writing set textwidth=79 to ~/.vim/ftplugin/tex.vim, saves you the autocmd FileType tex part and is more extensible if you like to add more tex specific options at a later point. –  exic Oct 16 '12 at 15:11