Wikia

Vim Tips Wiki

Changes: Moving by screen lines instead of file lines

Edit

Back to page

(Move categories to tip template)
(Remove html character entities)
 
Line 15: Line 15:
   
 
<pre>
 
<pre>
:noremap &lt;Up&gt; gk
+
:noremap <Up> gk
:noremap! &lt;Up&gt; &lt;C-O&gt;gk
+
:noremap! <Up> <C-O>gk
:noremap &lt;Down&gt; gj
+
:noremap <Down> gj
:noremap! &lt;Down&gt; &lt;C-O&gt;gj
+
:noremap! <Down> <C-O>gj
 
" the following are optional, to move by file lines using Alt-arrows
 
" the following are optional, to move by file lines using Alt-arrows
:noremap! &lt;M-Up&gt; &lt;Up&gt;
+
:noremap! <M-Up> <Up>
:noremap! &lt;M-Down&gt; &lt;Down&gt;
+
:noremap! <M-Down> <Down>
:noremap &lt;M-Up&gt; k
+
:noremap <M-Up> k
:noremap &lt;M-Down&gt; j
+
:noremap <M-Down> j
 
</pre>
 
</pre>
   

Latest revision as of 23:32, September 29, 2008

Tip 919 Printable Monobook Previous Next

created April 28, 2005 · complexity basic · author Raj Kiran Grandhi · version 5.7


Using 'gj' and 'gk' instead of just 'j' and 'k' allows moving down and up by screen lines instead of file lines. Here are a few nifty mappings for that:

:noremap <Up> gk
:noremap! <Up> <C-O>gk
:noremap <Down> gj
:noremap! <Down> <C-O>gj
" the following are optional, to move by file lines using Alt-arrows
:noremap! <M-Up> <Up>
:noremap! <M-Down> <Down>
:noremap <M-Up> k
:noremap <M-Down> j

CommentsEdit

See:


Around Wikia's network

Random Wiki