Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
234 views
in Technique[技术] by (71.8m points)

vim - Horizontal navigation in long lines

How can I do the following:

  1. shift faster to the right, something like zw (analogy to zl but jump on words)
  2. shift only the one long line where is the cursor. The rest of the file will remain in its position

I have .vimrc settings set nowrap. That's because the code looks nicer than wrapped lines. But there is a problem with horizontal navigation.

I noticed that zl (don't confuse l (L) with 1) shortcut which shifts to the right (zh to the left).

question from:https://stackoverflow.com/questions/5989739/horizontal-navigation-in-long-lines

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Did you try :help scroll-horizontal?

You could use a mapping to scroll, for example, 20 characters to the left or to the right:

map <C-L> 20zl " Scroll 20 characters to the right
map <C-H> 20zh " Scroll 20 characters to the left

Without applying a mapping, you could use zL to move the view a half screenwidth to the right and zH to do it to the left.

Regarding the second part of your question: I don't think that this is possible. You could yank the whole line, paste it into a second (scratch) buffer and scroll there. This would work as long as you're just reading the lines. Problems will arise as soon as you want to change something. But it's quite cumbersome...


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...