LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-18-2012, 11:08 AM   #1
viki.ahmad
LQ Newbie
 
Registered: Apr 2012
Posts: 2

Rep: Reputation: Disabled
vim mapping keys problem


hi all, i have problem with mapping keys in vim. i have map a key
map! :write :wq!
in my ~/.vimrc. the key map will save the changes and exit. But in my case it only save the changes but dont exit from the vim editor. any clue whats wrong with this key map. i am using RHEL 6.3. your reply will be appreciated.
 
Old 11-18-2012, 11:14 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390
Quote:
Originally Posted by viki.ahmad View Post
hi all, i have problem with mapping keys in vim. i have map a key
map! :write :wq!
Try this:
Code:
map ! :wq! <CR>

Last edited by druuna; 11-18-2012 at 11:21 AM.
 
1 members found this post helpful.
Old 11-20-2012, 08:41 AM   #3
viki.ahmad
LQ Newbie
 
Registered: Apr 2012
Posts: 2

Original Poster
Rep: Reputation: Disabled
map ! :wq! <CR>

thanx druuna it works but what was wrong with mine? with mine when i ':write', it saves any changes made but doesn't exit from editor.
 
Old 11-20-2012, 09:52 AM   #4
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390
Quote:
Originally Posted by viki.ahmad View Post
map ! :wq! <CR>

thanx druuna it works but what was wrong with mine? with mine when i ':write', it saves any changes made but doesn't exit from editor.
w is short for write, so your command is redundant. The reason why it only writes in your case is that write is executed, the wq! (force write and quit) waits for a return. The <CR> takes care of the return.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting 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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
mapping in vim baikonur Programming 1 12-06-2011 02:21 PM
Problem re-mapping non-standard keys to modifier keys tias42 Linux - General 4 04-09-2011 06:03 AM
Using mapping in VIM to add HTML? gaikokujinkyofusho Linux - Newbie 3 05-05-2009 12:57 AM
mapping custom keys TomalakBORG Linux - General 8 04-24-2005 04:27 PM
mapping keyboard keys fedetxf Linux - Newbie 1 03-23-2004 09:49 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:45 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration