Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to autocomplete at the KornShell command line with the vi editor

Tags:

shell

vi

unix

ksh

aix

In the KornShell (ksh) on AIX UNIX Version 5.3 with the editor mode set to vi using:

set -o vi

What are the key-strokes at the shell command line to autocomplete a file or directory name?

like image 419
David Avatar asked Sep 17 '08 08:09

David


People also ask

How do you autocomplete a command in Linux?

Command auto-completion is available when using the CLI shell. You can set up CLI command auto-completion in your operating system using the kollacli command command. This command generates a script you can save to the operating system. Copy and paste the output to a file, for example a file named /etc/bash_completion.

Which keystroke can be used to autocomplete a command?

Using autocomplete is as simple as pressing the [TAB] and the active command line options will fill-in.

Which key should you use for autocompletion in the Linux CLI?

When at the MS-DOS, Windows command line or a Linux or Unix shell, typing in long file names or directories can become a burden. Use the Tab to autocomplete the names of directories and files while in the command line.


2 Answers

ESC\ works fine on AIX4.2 at least. One thing I noticed is that it only autocompletes to the unique part of the file name.

So if you have the files x.txt, x171go and x171stop, the following will happen:

Press keys:           Command line is:
x                     x
<ESC>\                x
1                     x1
<ESC>\                x171
g<ESC>\               x171go
like image 50
paxdiablo Avatar answered Sep 28 '22 11:09

paxdiablo


Extending the other answers: <ESC>* will list all matching files on the command line. Then you can use the standard vi editing commands to remove the ones you don't care about. So to add to the above table:

<ESC><shift-8>             x.txt x171 x171go

Then use backspace to go get rid of the last two, or hit <ESC> again and use the h or b to go backwards and dw to delete the ones you don't want.

like image 24
Brian Deterling Avatar answered Sep 28 '22 11:09

Brian Deterling