Problem to map VIM cursor moving in InsertMode


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Problem to map VIM cursor moving in InsertMode
# 1  
Old 03-17-2011
Problem to map VIM cursor moving in InsertMode

Hi all

What I want?

I want in Insert mode, press Alt-hjkl move cursor, and then back to insert mode.

I know ctrl-o, hjkl can do the job. but everytime I want to move, i have to press ctrl-o, or I have to count how many hjkl I will do, do a C-O (n)hjkl.

What I tried (example only with 'j')
Code:
imap <A-j> <down>i
imap <A-j> <esc>ja
imap <A-j> <c-o>j

none of them worked. moving cursor is ok, but cannot bring me back to insertMode.

I am not good at vim script or vim config, can anyone give me a hint, how can I do the mapping?

thanks in advance.
# 2  
Old 03-18-2011
--- oops deleted ---
# 3  
Old 03-18-2011
problem solved.

in fact, gvim works in any case. the mapping cannot bring me back to insert mode only in tty/console.

I used keycode mapping, and it worked both with and without gui.

PHP Code:

set timeout
set timeoutlen
=1000
"set ttimeout 
set ttimeoutlen=50
if !has("
gui_running")
    set <F14>=<ESC>h
    set <F13>=<ESC>j
    set <F15>=<ESC>k
    set <F16>=<ESC>l
    inoremap <F14> <left>
    inoremap <F13> <down>
    inoremap <F15> <up>
    inoremap <F16> <right>
else
    inoremap <A-h> <left>
    inoremap <A-j> <down>
    inoremap <A-k> <up>
    inoremap <A-l> <right>
endif 

Last edited by sk1418; 03-18-2011 at 09:12 PM..
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX Desktop Questions & Answers

Boot problem after updates, Ubuntu, black screen and cursor

I hope this is the correct forum, please forgive a newbie. Hi all, New to linux, ubuntu, and this forum. I have enjoyed ubuntu for the past few months, but after my last update installation ubuntu would boot to a black screen and blinking cursor. If I let it sit for a while it would give the... (0 Replies)
Discussion started by: nutoubuntu
0 Replies

2. UNIX for Dummies Questions & Answers

Vim Match problem

Goodmorning, I've some problem in using regular expression in a VIM syntax configuration file. I've need to match a string as <<< some to match >>> so that it matches only some to match . With standard regular expression i know that for this goal works fine the regex: (?<=<{3}).*(?=>{3}) ... (4 Replies)
Discussion started by: keltron
4 Replies

3. UNIX for Dummies Questions & Answers

Why "map! <C-q> :q <CR> " does not work in vim.

Hello, I input :map! <C-q> :q <CR> in command line mode, then return to normal mode, and press ctrl-q, but vim does not quit. Why? Thanks! (0 Replies)
Discussion started by: 915086731
0 Replies

4. Shell Programming and Scripting

hash map Illegal division by zero problem

Hi Everyone, a.txt line1;a;33 line1;c;22 line1;b;0 line1;a;55 a.pl #!/usr/bin/perl use strict; use warnings; my @sorted=(); my @tmp; my $FA; my @F; (0 Replies)
Discussion started by: jimmy_y
0 Replies

5. Programming

Problem FETCHing Long data type using CURSOR

Currently my Pro*c program is fetching a cloumn which is defined as LONG in oracle db. The data in the column is around 65k. But when I am FETCHing it to a varchar variable, I am only getting 22751 bytes of data using cursor. Is there any limitation on the data which is fetched by a cursor in... (2 Replies)
Discussion started by: manbt
2 Replies

6. Shell Programming and Scripting

ksh - moving cursor position

hi all, am trying to modify a ksh script to group server names together depending on the cluster they sit in. currently the script does a find . -name '*.pid' to find all running servers and prints out their pids and names. current output looks something like this : serverA ... (1 Reply)
Discussion started by: cesarNZ
1 Replies

7. Shell Programming and Scripting

moving cursor up and other things

Hi guys, this is how my script looks like so far: height=$(($(tput lines) -2)) echo 'Owner Group Other Filename' echo '----- ----- ----- --------' echo cd $directory path=$(pwd) levels=0 level=$(($(echo $path | tr '/' ' ' | wc -w) +1)) for dir in / $(echo $path |... (2 Replies)
Discussion started by: darkhider
2 Replies

8. OS X (Apple)

Emacs set-cursor-color in iTerm problem

Hi I'm trying to customise emacs to work within iTerm (I've aliased emacs = emacs -nw so it runs inside my shell) but I can't get the 'set-cursor-color' to work. I have the following in my .emacs file: (set-cursor-color "LightSkyBlue") ... (0 Replies)
Discussion started by: pepperjacl
0 Replies

9. Shell Programming and Scripting

Vim problem

Can someone explain me why sometimes the cursor can not be moved to needed position? for example: mysql -u root db -sBe "ALTER TABLE $i ENGINE=$ENGINE"; echo -e "${GG}OK${BB}"; In this line I can not go to position after $i, why? This is not first time I see such issue. "INSERT" pressed :) (0 Replies)
Discussion started by: mirusnet
0 Replies

10. Programming

Format Problem with vim

Hi, there. Everyone had a great Thanksgiving? I have a slice format problem when I am using vim to edit c++ source code. I don't know how to discribe the problem exactly. You see, usually when I use the command "vi hello.cpp" to write a code, it will have the format like this: #include... (4 Replies)
Discussion started by: HOUSCOUS
4 Replies
Login or Register to Ask a Question