Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > macOS > Moving the Cursor in vi

Moving the Cursor in vi
Thread Tools
Millennium
Clinically Insane
Join Date: Nov 1999
Status: Offline
Reply With Quote
Jul 14, 2006, 01:47 PM
 
Somehow, I've managed to get one of my vi installations handling cursor movement in a way I don't want it to do. Moving the cursor up or down goes to the next physical line of the file, rather than respecting the window's soft-wrapping settings and going down one line as the window displays it. The latter is more common in GUI text editors, and unless I'm mistaken all of the GUI versions of vim do it by default, but somehow I've managed to turn it off and I don't know how to turn it back on.

I've been through the options window multiple times, but if the answer to my question is there then I must not have understood the docs. Any ideas on how I can get my desired cursor behavior back?
You are in Soviet Russia. It is dark. Grue is likely to be eaten by YOU!
     
WJMoore
Grizzled Veteran
Join Date: Jan 2002
Location: Melbourne, Australia
Status: Offline
Reply With Quote
Jul 15, 2006, 09:22 AM
 
What you describe is the default behaviour as far as I know. What does your .vimrc/.virc look like?
     
JasonPro
Fresh-Faced Recruit
Join Date: Jan 2003
Status: Offline
Reply With Quote
Jul 21, 2006, 05:33 AM
 
Not a real solution, but...

set nowrap

if you don't mind your text not wrapping... personally I don't like wrapping text. 

-- 
Jason Protheroe
     
Millennium  (op)
Clinically Insane
Join Date: Nov 1999
Status: Offline
Reply With Quote
Jul 24, 2006, 02:21 PM
 
Sorry it took so long to get back; here's the .vimrc (_vimrc, actually) for my Windows box:
Code:
" Windows stuff set nocompatible source $VIMRUNTIME/vimrc_example.vim source $VIMRUNTIME/mswin.vim behave mswin " Formatting set tabstop=4 set shiftwidth=4 set backspace=2 set expandtab " Other universal stuff set ruler set incsearch syntax on " Colors highlight Comment guifg=darkred guibg=NONE highlight Statement guifg=lightblue guibg=NONE highlight Constant guifg=darkgreen guibg=NONE highlight PreProc guifg=blue guibg=NONE " Encoding if has("multi_byte") set encoding=utf-8 setglobal fileencoding=utf-8 set termencoding=iso-8859-15 set fileencodings=iso-8859-15,iso-8859-1,utf-8 else echoerr "Sorry, this version of gvim was not compiled with +multi_byte" endif
It's still showing the behavior I mentioned. In addition, I notice that the syntax highlighting overrides I specified are not being used: the GUI still insists on using its own colors. I can add echo statements to the _gvimrc file, however, to verify that it is in fact being run.
You are in Soviet Russia. It is dark. Grue is likely to be eaten by YOU!
     
Tritium
Junior Member
Join Date: Jan 2003
Status: Offline
Reply With Quote
Jul 25, 2006, 11:52 AM
 
The closest thing I could find to what you want is to use 'gk' or 'gj'to move the cursor up and down - I have never in my life used vim and had it do what you're asking, but I tested and those work.
     
Millennium  (op)
Clinically Insane
Join Date: Nov 1999
Status: Offline
Reply With Quote
Jul 25, 2006, 11:57 AM
 
Originally Posted by Tritium
The closest thing I could find to what you want is to use 'gk' or 'gj'to move the cursor up and down - I have never in my life used vim and had it do what you're asking, but I tested and those work.
Thanks for the tip. Maybe the keys are being rebound?
You are in Soviet Russia. It is dark. Grue is likely to be eaten by YOU!
     
exca1ibur
Mac Elite
Join Date: Oct 2000
Location: Oakland, CA
Status: Offline
Reply With Quote
Jul 26, 2006, 12:12 AM
 
This may help. I use as my reference time to time. I am working on a widget with all the commands as well so I can have a reference that is F12 away.

VI Commands
     
parallax
Admin Emeritus
Join Date: Oct 2000
Location: Boston, MA
Status: Offline
Reply With Quote
Aug 21, 2006, 11:56 AM
 
Personally, I like having this setting in terminal vim as well, so my .vimrc contains

Code:
nnoremap j gj nnoremap k gk nnoremap gk k nnoremap gj j
This switches the functionality of gj/k with j/k

Code:
vnoremap j gj vnoremap k gk nnoremap <Down> gj nnoremap <Up> gk vnoremap <Down> gj vnoremap <Up> gk inoremap <Down> <C-o>gj inoremap <Up> <C-o>gk
And this makes the behavior consistent when dealing with Up/Down keys as well as in all modes.
"Against stupidity, the gods themselves contend in vain" (Schiller)
     
   
 
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 03:39 PM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,