Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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):

Instead of having this:

\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}
share|improve this question
1  
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
2  
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

1 Answer 1

up vote 5 down vote accepted

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
share|improve this answer
    
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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.