|
|
Moving the Cursor in vi
|
|
|
|
Clinically Insane
Join Date: Nov 1999
Status:
Offline
|
|
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!
|
|
|
|
|
|
|
|
Grizzled Veteran
Join Date: Jan 2002
Location: Melbourne, Australia
Status:
Offline
|
|
What you describe is the default behaviour as far as I know. What does your .vimrc/.virc look like?
|
|
|
|
|
|
|
|
|
Fresh-Faced Recruit
Join Date: Jan 2003
Status:
Offline
|
|
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
|
|
|
|
|
|
|
|
|
Clinically Insane
Join Date: Nov 1999
Status:
Offline
|
|
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!
|
|
|
|
|
|
|
|
Junior Member
Join Date: Jan 2003
Status:
Offline
|
|
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.
|
|
|
|
|
|
|
|
|
Clinically Insane
Join Date: Nov 1999
Status:
Offline
|
|
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!
|
|
|
|
|
|
|
|
Mac Elite
Join Date: Oct 2000
Location: Oakland, CA
Status:
Offline
|
|
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
|
|
|
|
|
|
|
|
|
Admin Emeritus
Join Date: Oct 2000
Location: Boston, MA
Status:
Offline
|
|
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 Rules
|
|
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
|
|
|
|
|
|