You are not logged in.
Hi all,
I have began using vim (in the terminal) for editing my LaTeX files. Obviously as I am writing a large amount of text, and how LaTeX treats formatting, each paragraph is a single line in vim. I have figured out line wrapping no problems and amended that in my.vimrc however with each paragraph a long line I am fiing it very hard to navigate around the document. I am unable to jump between lines on the screen using "j" and "k" as it jumps to the end of the actual line, which may be 4 or 5 lines below. While I can jump a few words at a time I was hoping there was a more intuitive and quicker solution. Maybe something that displays a paragraph as multiple lines in vim but does not interfere with the actual file to prevent issues with compiling the LaTeX?
Tanks in advance,
Danny
Last edited by dclarkson77 (2011-09-05 12:40:36)
Offline
You want to navigate using "screen lines" - use 'gk' instead of 'k'; some sample shortcuts
noremap <Up> gk
noremap <Down> gj
Some general links:
http://vim.wikia.com/wiki/Move_cursor_b … n_wrapping
http://vim.runpaint.org/display/working … ong-lines/
There may be a better LaTeX-oriented way via some plugin.
Last edited by karol (2011-09-04 23:13:45)
Offline
karol's got the right idea. But also, did you know that you can split a paragraph up into multiple lines? As long as there isn't a blank line, it's considered to be on the same paragraph. So typically at around column 80, I'll just create a new line. I have a line going down column 80 to indicate when I'm getting close.
Offline
karol's got the right idea. But also, did you know that you can split a paragraph up into multiple lines? As long as there isn't a blank line, it's considered to be on the same paragraph. So typically at around column 80, I'll just create a new line. I have a line going down column 80 to indicate when I'm getting close.
You mean a general way to fold text to a certain width? Try 'fold' - it uses 80 chars by default so 'fold foo' should work.
Edit:
Sorry, I'm sleepy, now I see that wasn't really a question ;P
Still, 'fold' may be helpful so you don't have to manually cut it at 80 chars (on some old documents you weren't creating with this "rules") or hack a script to do so.
Last edited by karol (2011-09-05 01:20:58)
Offline
Put those two options in your .vimrc, though the first one you most likely already have there:
set wrap
set linebreak
:: Registered Linux User No. 223384
:: github
:: infinality-bundle+fonts: good looking fonts made easy
Offline
karol's got the right idea. But also, did you know that you can split a paragraph up into multiple lines? As long as there isn't a blank line, it's considered to be on the same paragraph. So typically at around column 80, I'll just create a new line. I have a line going down column 80 to indicate when I'm getting close.
However---should you ever want to use version control with LaTeX, wrapping lines like this might become an issue: A one-word change that results in a re-wrap of the paragraph can mess up the diff display of your version control system. There's two ways around that: 1. Use a word-based diff such as wdiff, or 2. write one sentence per line.
Just thought I'd point that out.
Offline
Put those two options in your .vimrc, though the first one you most likely already have there:
set wrap set linebreak
On top of those two lines, I set this as well:
set textwidth=0
Offline
On top of those two lines, I set this as well:
set textwidth=0
To help with pasting or ...?
Offline
skottish wrote:On top of those two lines, I set this as well:
set textwidth=0
To help with pasting or ...?
:: Registered Linux User No. 223384
:: github
:: infinality-bundle+fonts: good looking fonts made easy
Offline
@bohoomil
I was asking about
'textwidth' 'tw' number (default 0)
local to buffer
{not in Vi}
Maximum width of text that is being inserted. A longer line will be
broken after white space to get this width. A zero value disables
this. 'textwidth' is set to 0 when the 'paste' option is set. When
'textwidth' is zero, 'wrapmargin' may be used. See also
'formatoptions' and |ins-textwidth|.
When 'formatexpr' is set it will be used to break the line.
NOTE: This option is set to 0 when 'compatible' is set.
(emphasis mine)
I think I got it backwards ;P
Offline
Hi all,
thanks for the comprehensive replies! I knew it would be a simple solution. @karol, the links are very helpful and what I am currently using at the moment (I really need to work on a few documents). @bohoomil, sounds a (maybe) simpler solution but as @Runiq points out seems there is a bit more to it. When I get a chance I will try it out and report back.
Once again thanks all for your help!
Danny
Offline
@karol: Sorry, my receptors must have fallen asleep before I actually did. ; )
:: Registered Linux User No. 223384
:: github
:: infinality-bundle+fonts: good looking fonts made easy
Offline
@karol: Sorry, my receptors must have fallen asleep before I actually did. ; )
No problem. Nighty-night ;P
Offline
A little sidenote: :h text-objects , you are going to love those.
Evil #archlinux@libera.chat channel op and general support dude.
. files on github, Screenshots, Random pics and the rest
Offline
A little sidenote: :h text-objects , you are going to love those.
This…
…is the best thing since sliced bread.
Offline