entering tab in vi without using tab key

entering tab in vi without using tab key

Post by seannakas.. » Fri, 12 May 2006 10:45:42



is there a way of entering a tab in vi w/o using the tab key?

the reason is because i configured my editor to insert spaces instead
of tabs when i press the tab key.  but sometimes i'd like to actually
insert a tab.  how do i do this?  i tried <ctrl-i> but that still
inserts spaces.

ideally it would be nice if there was a general way of entering
characters by ascii values that way i could enter other characters as
well like carriage return.

 
 
 

entering tab in vi without using tab key

Post by Stephane CHAZELA » Fri, 12 May 2006 16:13:46



Quote:> is there a way of entering a tab in vi w/o using the tab key?

> the reason is because i configured my editor to insert spaces instead
> of tabs when i press the tab key.  but sometimes i'd like to actually
> insert a tab.  how do i do this?  i tried <ctrl-i> but that still
> inserts spaces.

<Ctrl-V><Tab> ?

Quote:> ideally it would be nice if there was a general way of entering
> characters by ascii values that way i could enter other characters as
> well like carriage return.

With Vim: <Ctrl-V>009 or <Ctrl-V>o011 or <Ctrl-V>x09.

See :h i_CTRL-V_digit

--
Stphane

 
 
 

entering tab in vi without using tab key

Post by Michael Paol » Sun, 14 May 2006 15:31:04



> is there a way of entering a tab in vi w/o using the tab key?

> the reason is because i configured my editor to insert spaces instead
> of tabs when i press the tab key.  but sometimes i'd like to actually
> insert a tab.  how do i do this?  i tried <ctrl-i> but that still
> inserts spaces.

> ideally it would be nice if there was a general way of entering
> characters by ascii values that way i could enter other characters as
> well like carriage return.

Hmmmmmm... sounds like you have a version/implementation of vi(1)
other than ye olde classic UNIX vi(1), or nvi(1).  Perhaps you're
using vim(1) - it is provided as or for the default for vi(1) on at
least some LINUX distributions.  Or perhaps you did this tab --> space
configuration via some other means?

Nevertheless, for vi(1), or some approximation thereof, any and/or all
of these may be useful and effective (I show control characters as
preceded by ^):

In insert mode, use
^V^I
For ^I, above, you can try the TAB key, and you can also try using the
control and I keys.  You can also try ^I using the control and I keys
without the ^V first.

You can read in the output of a command, e.g. (precise syntax may vary
depending on your echo) from command mode:
:.r !echo -e '\011'
That should give you a line after the current line with a single tab
on it.  Once you've got the tab there, you can always yank it into a
named buffer, e.g. place the cursor on the line that ends with that
tab, then from command mode, enter:
"ty$
That will yank that character (the tab) into named buffer t.
Then, any time you want to place a tab, from command mode, do:
"tp
to place it after the cursor, or
"tP
to place it before the cursor.

This approach can be generalized for dealing with most arbitrary ASCII
characters within vi(1).  It may not support non-ASCII characters, and
it may not support the ASCII null character, and it won't support
newline, but it should handle all other ASCII characters.

Followup-to: set because it seemed fitting

 
 
 

1. Script GURUs - a tab is a tab is a tab

I have ascii files created by various people I want to run something
that will look for tabs and based on the tab length convert tabs to the
right number of spaces, however the above people use various tab
lengths and do their indenting a little differently. Does someone out
there have a solution to this type of situation?????


you might have a solution.

Thanks in advance

Jim

2. CTX Monitor Spec

3. Mapping <Tab> key in vi or vim

4. Minicom

5. autoindent without tabs in vi

6. mkmf for linux?

7. `vi' without `stty crt -tabs' gets crazy (Help!)

8. Unable to Kill Users

9. how to distinguish enter key and key pad enter key?

10. SUMMARY: how to distinguish enter key and key pad enter key?

11. replacing tabs with emulated tabs

12. tab versus tab

13. command completion using Tab key?