Sign up ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

enter image description here

Look at the image above, it is one line that declares a huge list. Now suppose my cursor is on the first element's 'i' and I press 'j' then the cursor directly goes to the line new_s='' but what I want is the cursor go to the 's' of the word 'she' below 'i'

Is there any way to do this?

share|improve this question

migrated from Nov 2 '12 at 9:11

This question came from our site for professional and enthusiast programmers.

4 Answers 4

up vote 8 down vote accepted

j moves the cursor down one physical line. You can use gj to move down one displayed line.

share|improve this answer

If you type gj the cursor will move one line down, gk brings you one line up. I assume that you are in a normal console window?


share|improve this answer

The existing answers are spot on.

I wanted to add that j/k and gj/gk are strictly equivalent when you are working on non-wrapped text. Thus, the following mappings are as harmless (if you don't :set wrap) as they are useful (if you :set wrap):

nnoremap j gj
nnoremap k gk
share|improve this answer
Vim rookie here. I'll have to look into what nnoremap means :) – Programming Noob Nov 2 '12 at 8:56
It can be called "non-recursive mapping", see this page for an explanation. – romainl Nov 2 '12 at 9:58

I like the script from here: " mapping to make movements operate on 1 screen line in wrap mode

function! ScreenMovement(movement)
  if &wrap && b:gmove == 'yes'
    return "g" . a:movement
    return a:movement
onoremap j ScreenMovement("j")
onoremap k ScreenMovement("k")
onoremap 0 ScreenMovement("0")
onoremap ^ ScreenMovement("^")
onoremap $ ScreenMovement("$")
nnoremap j ScreenMovement("j")
nnoremap k ScreenMovement("k")
nnoremap 0 ScreenMovement("0")
nnoremap ^ ScreenMovement("^")
nnoremap $ ScreenMovement("$")
vnoremap j ScreenMovement("j")
vnoremap k ScreenMovement("k")
vnoremap 0 ScreenMovement("0")
vnoremap ^ ScreenMovement("^")
vnoremap $ ScreenMovement("$")
vnoremap j ScreenMovement("j")
" toggle showbreak
function! TYShowBreak()
  if &showbreak == ''
    set showbreak=>
    set showbreak=
let b:gmove = "yes"
function! TYToggleBreakMove()
  if exists("b:gmove") && b:gmove == "yes"
    let b:gmove = "no"
    let b:gmove = "yes"
nmap ,b TYShowBreak()
nmap ,bb TYToggleBreakMove()

You can then use ,b to display if the line wraps (above example uses '>' character). Then ,bb turns off screen movement if you have wrap set

Additionally I have wrapping set to a binding in my VIMRC as well:

"--- wrap toggle with f2 key---"
function! ToggleWrap()
set wrap!|set wrap?

"F2 toggles wrap
nmap <f2> :call ToggleWrap()<CR>
vmap <F2> <C-C>:call ToggleWrap()<CR>
imap <F2> <C-O>:call ToggleWrap()<CR>i
share|improve this answer

Your Answer


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