Shell vim defaulting to Insert or Command mode


 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers Shell vim defaulting to Insert or Command mode
# 1  
Old 01-22-2018
Shell vim defaulting to Insert or Command mode

On a daily basis I need to SSH into several different RHEL servers using Putty.

On some of the servers, if I up arrow to get a previous command, it automatically starts in Input Mode, so if I press up arrow, then 'x' it will type the letter x at the end of the command line. On other servers, it automatically starts in Command Mode, so if press up arrow, then 'x' it deletes the first character of the command.

I'm trying to understand how this default behavior is controlled. I've looked through the .bashrc, .bash_profile, .vimrc files and don't think I see where this is being set.

I prefer the second way since I spent many years working on AIX and that's the way it worked, but the biggest thing is I'd like is to make it consistent.

It seems like there must be a simple answer, but I must be using the wrong search terms trying to find it. Thanks in advance.
# 2  
Old 01-22-2018
The vim (and vi) utility always starts in command mode. One might guess that the default terminal setting (i.e. TERM=terminal_type) differs on some of your servers and the escape sequence being generated for the up-arrow key on your terminal is being interpreted differently as a result. My guess would be that the escape sequence for that key includes an "a" or "i" or other vim command that puts you in insert mode when TERM is set to something like "dumb" or to a terminal type that does not match whatever terminal type Putty is emulating.
This User Gave Thanks to Don Cragun For This Post:
# 3  
Old 01-22-2018
For the behavior on the command line, see the discussion of vi-mode versus emacs-mode
This User Gave Thanks to MadeInGermany For This Post:
# 4  
Old 01-22-2018
Thank you, that seems to be it. Specifically
Code:
set -o vi

makes it work the way I want it to. I appreciate the info!
# 5  
Old 01-22-2018
You can set that in ~/.profile, if you're using ksh (i.e. not ~/.bashrc or ~/.bash_profile (~=your home directory))

And, obviously, if you prefer using Vi to "emacs" when your shell is Bash, you can set it in your Bash profile also Smilie
This User Gave Thanks to Scott For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Vi / vim - Insert a external command response

I would like to execute and external command and insert it into a particular area of the file I am editing. Note that I have the ORIGINAL AT&T vi training doc dated 1987. Doesnt explain it. As an example, in a vi editor I have I would like the result : After executing the following... (1 Reply)
Discussion started by: popeye
1 Replies

2. Shell Programming and Scripting

vim command for a search

how can i search each line for ROCT and ROCT1.ROCT1 will be always 1 line after ROCT. Both the patterns will be found at the end of the line (in alternate lines) <pattern file> (rising edge-triggered flip-flop clocked by ROCT) Endpoint:... (2 Replies)
Discussion started by: dll_fpga
2 Replies

3. Shell Programming and Scripting

Insert shell command into first line of output file

How can I insert the command executed on the shell into the first line of my output file? For example if I execute; zcat *.gz |grep “User5501” > users.out How can I make my users.out look like; zcat *.gz |grep “User5501” > users.out User5501 PA User5501 UA User5501 ZA... (3 Replies)
Discussion started by: lewk
3 Replies

4. Solaris

Very Importan - Vim Settings - Error while opening a File using vim

I downloaded vim.7.2 and compiled the vim source . Added the vim binary path to PATH (Because iam not the root of the box) when i load the file using vim it throws me an error Error detected while processing /home2/e3003091/.vimrc: line 2: E185: Cannot find color scheme darkblue line... (0 Replies)
Discussion started by: girija
0 Replies

5. Shell Programming and Scripting

Calling vim shell script

Hi All, I was looking to open a file using vim within shell script. Can someone please suggest a way/syntax for this? Thanks in advance. (5 Replies)
Discussion started by: jal_capri
5 Replies

6. UNIX for Dummies Questions & Answers

vi/vim insert behaviors

While using vi or vim on different boxes, I experience different behaviors when I'm inserting (i) or writing on a new line (o). On the Linux box, I can insert and delete with my backspacekey while in the insert mode. It acts a little more like pico,nedit, etc. On the SunOS box, it's a headache... (3 Replies)
Discussion started by: mrwatkin
3 Replies

7. UNIX for Dummies Questions & Answers

unable to insert '#' char for a file in vi mode

Hi all, I am very new to this forum and also new to UNIX. I am working on HP-UX machine. I noticed that for some of the users I am unable to insert the # character in a file in vi mode. May I know y am I having the problem and how can I resolve this Thanks, Maroli (1 Reply)
Discussion started by: maroli
1 Replies

8. UNIX for Dummies Questions & Answers

Insert line break in vi's command mode

Hi, When working in vi, the CTRL+j command for merging lines is very convenient. Is there an equivalent for splitting them (inserting a line break)? I often find myself pressing "i" + "return" + "esc", which I find a bit lengthy. Thanks in advance! (3 Replies)
Discussion started by: Skogsmulle
3 Replies

9. Shell Programming and Scripting

insert escape charactor within VIM

Hi, I need to send "^[" command to the buffer. I tried to use insert within VIM and press 'ctrl' key and then '^' and '[' key. but it didn't work. Does anyone know how to do it? Thanks a lot! Julie (2 Replies)
Discussion started by: cin2000
2 Replies

10. Shell Programming and Scripting

script to run shell command and insert results to existing xml file

Hi. Thanks for any help with this. I'm not new to programming but I am new to shell programming. I need a script that will 1. execute 'df -k' and return the volume names with specific text 2. surround each line of the above results in opening and closing xml tags 3. insert the results of step... (5 Replies)
Discussion started by: littlejon
5 Replies
Login or Register to Ask a Question