LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
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 06-23-2011, 11:38 PM   #1
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442

Rep: Reputation: 76
vim: to input a single character and continue in command mode: what key?


Hi:

What's said.

I increase my knowledge in vim in two ways. Little hints about doing this or that and scattered studies using the vim help files. Please do not believe I always rely on the first one.
 
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 06-24-2011, 12:31 AM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
I honestly don't think that exists by default; you may be able to
code something like that up, and bind it to some obscure key-combo.

What's the actual objective?


Cheers,
Tink
~
~
:wq!
 
Old 06-24-2011, 12:44 AM   #3
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442

Original Poster
Rep: Reputation: 76
Hi, and thanks.

I understand. In the language of some old editors, that would be called a macro.

I may be revising a text, and find I wrote 'wote' instead of 'wrote'. In cases like these, such a command would be nice. Now, to construct a key binding combo is beyond the elementary state of vim knowledge on my part.

Still, knowing it's not a default command, has been of grate help.

Last edited by stf92; 06-24-2011 at 12:47 AM.
 
Old 06-24-2011, 02:18 AM   #4
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,008

Rep: Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193
I am not sure how it can be much easier than (using example):
Code:
i -> r -> ESC
Surely any macro launched by a key combination will need to include the letter you wish to add so letter plus a
key stroke before and after seems pretty minimal to me?
 
Old 06-24-2011, 03:39 AM   #5
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442

Original Poster
Rep: Reputation: 76
So, 'r' is an arbitrary letter in your scheme? If so, it certainly looks like minimal, given that launching the macro needs two keys.

I wonder how does vim implement the 'r' command (replace one character). It has to be coded into the program, at first sight. But if the key bindings were definable by the user?
 
Old 06-24-2011, 03:46 AM   #6
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,008

Rep: Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193
Yes 'r' is arbitrary letter. You can create your own macros ... just type 'vim macros' into google and you should get plenty of responses.
 
Old 06-24-2011, 03:57 AM   #7
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442

Original Poster
Rep: Reputation: 76
Thank you very much. I'll mark SOLVED.
 
Old 06-24-2011, 05:06 PM   #8
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
I guess I was thrown off by "continue in command mode". I assumed
you were currently in command mode, e.g. composing a search & replace,
wanted to change a letter in text and carry on typing your command.

Sorry about that.



Cheers,
Tink
 
Old 06-24-2011, 05:49 PM   #9
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
Quote:
Originally Posted by Tinkster View Post
I assumed
you were currently in command mode, e.g. composing a search & replace,
wanted to change a letter in text and carry on typing your command.
"Command Mode" does not mean that you are entering a ":" command.
 
Old 06-24-2011, 06:44 PM   #10
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Quote:
Originally Posted by MTK358 View Post
"Command Mode" does not mean that you are entering a ":" command.
The mode where you're not entering commands is called "Normal mode".
To be in "command mode", you do press :


Cheers,
Tink
 
1 members found this post helpful.
Old 06-24-2011, 08:05 PM   #11
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442

Original Poster
Rep: Reputation: 76
Quote:
Originally Posted by Tinkster View Post
The mode where you're not entering commands is called "Normal mode".
To be in "command mode", you do press :
I'm sorry if I misled somebody. There is a "typo" in the thread title. It says: vim: to input a single character and continue in command mode: what key? It should say: vim: to input a single character and continue in normal mode: what key?

To avoid any cofussion: the mode I currently am in is that in which typing 'I' will set you in insert mode and typing ':' will set you in command mode. But I guess now it's too late for me. The impetus has been lost. Anyway, most of you seem to have interpreted post #1 in the way it was intended by me and, so, it would remain true that three keystrokes would be the minimal count. Thanks a lot.
 
Old 06-24-2011, 08:33 PM   #12
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
No worries, and looking at MTK358's misinterpretation I understand
that others got what you meant, not what you said. ;}

Anyway, you may find the read of these interesting:
http://vim.wikia.com/wiki/Insert_a_single_character
http://vim.wikia.com/wiki/Insert_one_character_only



Cheers,
Tink
 
2 members found this post helpful.
Old 06-24-2011, 08:45 PM   #13
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442

Original Poster
Rep: Reputation: 76
Most kind of you, Tinkster.
 
  


Reply



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
[SOLVED] Multiple input into seq command from pipe / single column unique numbers geehog Programming 4 05-14-2011 12:18 AM
Vim: bringing the cursor to 1st char in current line (command mode). stf92 Linux - Newbie 16 12-05-2010 07:52 AM
Backspace Key deletes section not single character onthefritz Red Hat 4 06-24-2010 01:43 PM
Perl - Press Any Key To Continue nobody123 Linux - Newbie 4 04-06-2009 06:52 PM
How can I change display mode from character mode to graph mode wuzhong Linux - Hardware 1 08-08-2004 09:36 AM

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

All times are GMT -5. The time now is 06:14 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
Open Source Consulting | Domain Registration