Vim Tips Wiki
m (Move through wrapped lines. moved to Move through wrapped lines: Page moved by JohnBot to improve title)
m (fix typos)
 
(3 intermediate revisions by one other user not shown)
Line 1: Line 1:
 
{{review}}
 
{{review}}
  +
{{TipImported
{{Tip
 
 
|id=308
 
|id=308
  +
|previous=306
|title=Move through wrapped lines.
 
  +
|next=309
|created=August 12, 2002 1:34
+
|created=August 12, 2002
 
|complexity=intermediate
 
|complexity=intermediate
 
|author=Little Dragon
 
|author=Little Dragon
 
|version=5.7
 
|version=5.7
 
|rating=155/58
 
|rating=155/58
  +
|category1=
|text=
 
  +
|category2=
If you don't like the fact that when you press Up and Down on a wrapped line, you get to the next phisical line instead of the next line on the screen, you can do something like this:
 
 
 
 
imap <silent> <Down> <C-o>gj
 
 
imap <silent> <Up> <C-o>gk
 
 
 
 
nmap <silent> <Down> gj
 
 
nmap <silent> <Up> gk
 
 
 
 
}}
 
}}
 
If you don't like the fact that when you press Up and Down on a wrapped line, you get to the next physical line instead of the next line on the screen, you can do something like this:
   
  +
<pre>
== Comments ==
 
 
imap <silent> <Down> <C-o>gj
just make sure that you don't do something odd like I did and copy the spaces at the end of the code :S.
 
 
imap <silent> <Up> <C-o>gk
 
nmap <silent> <Down> gj
 
nmap <silent> <Up> gk
  +
</pre>
   
 
==Comments==
'''Anonymous'''
 
 
Or you can just jump into paste mode.
, March 9, 2003 16:55
 
----
 
or you can just jump into paste mode.
 
   
in paste mode you will be able to navigate from line to line without the cursor jumping around *and* you won't have the long text wrap if you put a space in, which usually is not a desired effect.
+
In paste mode you will be able to navigate from line to line without the cursor jumping around *and* you won't have the long text wrap if you put a space in, which usually is not a desired effect.
   
  +
<pre>
:set paste
+
:set paste
 
or
 
:set pastetoggle=<F9> (or whatever keybinding you want) in your .vimrc
  +
</pre>
   
or
 
 
:set pastetoggle=&lt;F9&gt; (or whatever keybinding you want) in your .vimrc
 
 
'''Anonymous'''
 
, March 5, 2004 15:53
 
 
----
 
----
My current settings are:
+
My current settings are:
   
  +
<pre>
map &lt;silent&gt; &lt;up&gt; gk
 
imap &lt;silent&gt; &lt;up&gt; &lt;C-o&gt;gk
+
map <silent> <Up> gk
map &lt;silent&gt; &lt;down&gt; gj
+
imap <silent> <Up> <C-o>gk
imap &lt;silent&gt; &lt;down&gt; &lt;C-o&gt;gj
+
map <silent> <Down> gj
  +
imap <silent> <Down> <C-o>gj
map &lt;silent&gt; &lt;home&gt; g&lt;home&gt;
 
imap &lt;silent&gt; &lt;home&gt; &lt;C-o&gt;g&lt;home&gt;
+
map <silent> <home> g<home>
  +
imap <silent> <home> <C-o>g<home>
map &lt;silent&gt; &lt;end&gt; g&lt;end&gt;
 
  +
map <silent> <End> g<End>
imap &lt;silent&gt; &lt;end&gt; &lt;C-o&gt;g&lt;end&gt;
 
  +
imap <silent> <End> <C-o>g<End>
   
setlocal linebreak
+
setlocal linebreak
setlocal nolist
+
setlocal nolist
setlocal display+=lastline
+
setlocal display+=lastline
  +
</pre>
   
But i'm still trying to find a way to avoid "jumps" when i'm scrolling and a wrapped line enters or exits the screen...
+
But I'm still trying to find a way to avoid "jumps" when I'm scrolling and a wrapped line enters or exits the screen...
   
PS: See also [[VimTip38]]
+
See also [[VimTip38]].
 
'''Anonymous'''
 
, August 14, 2004 17:19
 
----
 
I have the same problem in long line cases.
 
That is, can vim scroll in screen lines instead of physical lines
 
when one long line is about to scroll out of window (up or down)?
 
   
lei.wang--AT--computer.org
 
, August 25, 2004 0:59
 
 
----
 
----
<!-- parsed by vimtips.py in 0.460624 seconds-->
 

Latest revision as of 09:03, 30 March 2011

Tip 308 Printable Monobook Previous Next

created August 12, 2002 · complexity intermediate · author Little Dragon · version 5.7


If you don't like the fact that when you press Up and Down on a wrapped line, you get to the next physical line instead of the next line on the screen, you can do something like this:

imap <silent> <Down> <C-o>gj
imap <silent> <Up> <C-o>gk
nmap <silent> <Down> gj
nmap <silent> <Up> gk

Comments[]

Or you can just jump into paste mode.

In paste mode you will be able to navigate from line to line without the cursor jumping around *and* you won't have the long text wrap if you put a space in, which usually is not a desired effect.

:set paste
or
:set pastetoggle=<F9> (or whatever keybinding you want) in your .vimrc

My current settings are:

map <silent> <Up> gk
imap <silent> <Up> <C-o>gk
map <silent> <Down> gj
imap <silent> <Down> <C-o>gj
map <silent> <home> g<home>
imap <silent> <home> <C-o>g<home>
map <silent> <End> g<End>
imap <silent> <End> <C-o>g<End>

setlocal linebreak
setlocal nolist
setlocal display+=lastline

But I'm still trying to find a way to avoid "jumps" when I'm scrolling and a wrapped line enters or exits the screen...

See also VimTip38.