How do I insert a tab character in Iterm?

若如初见. 提交于 2019-12-08 14:52:30

问题


Simply put, I know you can do ctrl+v+tab to insert a physically real tab character in a bash statement. But how do I do the same for iTerm?


回答1:


The answer was to hit control+v, then tab afterwards, not all together! Hope this helps someone.




回答2:


It's not iTerm, but your shell that affects how you''re able to insert a tab.

First, make sure you're in BASH shell: Type the following command:

$ echo $RANDOM $BASH_VERSINFO
23714 3

The first is a random number, and the second should be the BASH Version number. If you get a blank line or just a random number, you're not in the BASH shell, and that's probably one of your issues.

Another thing is to execute this command:

$ set -o
allexport       off
braceexpand     on
emacs           on
errexit         off
errtrace        off
[...]
privileged      off
verbose         off
vi              off
trace           off

The two lines of interest is the emacs and the vi lines. One of those should be on. If they're both off, you can't do the Ctrl-V-Tab to insert a tab character.

When the vi mode is on, it should be Ctrl-V-Tab like you said. With emacs mode on, it is either Ctrl-V-tab, or possibly Ctrl-Q-tab.

However, this isn't an iTerm thing, this is your shell that's doing it.




回答3:


If by a "physically real tab character" you mean sending the tab hex code (0x09) to the shell, then you can do this in iTerm by pressing Ctrl + Tab (⌃ ⇥).

This is the default setting, although you can change it (as well as add other hex code values to send) in iTerm > Preferences > Profiles > Keys.




回答4:


I'm not certain why you're comparing a "bash statement" with iTerm. You write bash scripts in iTerm. Which means, assuming you're writing your scripts in iTerm, you're already doing what you want.

I'll assume you mean scripting in vi vs command line. The way I get literal characters on the command line is by using vi editing mode. Do set -o vi. Then you can use ctrl+v followed by tab in the manner that you're used to.

IMO, using vi editing mode comes with a slew of other pluses like searching your history, faster navigation, etc. So you could just add it to your .bashrc if you wanted and use it all the time.



来源:https://stackoverflow.com/questions/10627989/how-do-i-insert-a-tab-character-in-iterm

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!