Redian新闻
>
how to build short cut to insert a text under vi?
avatar
how to build short cut to insert a text under vi?# Linux - Linux 操作系统
s*y
1
2008年10月5日到美国,White Plains,NY,J1签证,单身
只有一份工作,postdoc,一个老板
但是不知道为什么收到两张W2表格。。。里面的钱数还不一样
一份Employer use only 为A6,另一份为T5不知啥意思。。。。
还有一张CHASE寄来的Form 1099-INT什么的,里面还有Interest Income 100$不知是啥
东西。。。也是要报税的吗?怎么报?
基本上是啥都不懂,无从下手,我是在个研究所里,没有人管这个事,周围的人大多情
况不太一样,没法参照,特来请教,谢谢!
avatar
e*e
2
Hi,
I need to frequently insert a line of text during my programming under vim.
Is there anyway to setup a short cut to do this in vim?
For example, if I want to press a key or a key combination to insert "this
is debug trace" under the current cursor, can I setup this in vim?
thanks!
avatar
r*t
3
record a macro.
avatar
e*e
4
can you show me by an example or a link how to record a macro? thanks
avatar
e*n
5
I googled it for you:
under command mode, press q then a.
Vim should display "recording" on left corner.
Then type:
i #enter insertion mode
this is debug trace #this is what you want to put in everytime
q #finish recording.
That's it. You can insert this line anywhere by typing @a.

【在 e***e 的大作中提到】
: can you show me by an example or a link how to record a macro? thanks
avatar
q*d
6
old way - yank
"ayy - yank a line into register a
"ap - put register a
avatar
e*e
7
thanks edn and quid. both are very helpful tips!
avatar
a*i
8
And also remember, the content in X11's clipboard is in register
+. So whatever you highlighted can be copied into your vim/gvim
with "+p.

【在 e***e 的大作中提到】
: thanks edn and quid. both are very helpful tips!
avatar
e*e
9
can this be done for screen?
My enviroment is use screen to open many buffers. Then, I use sqlplus
command line to connect Oracle. The problem is I insert a text frequently
when I type Sql query. So, can this be done in screen too?
I know screen has a copy mode, that allow you to use vi to copy.
ctrl+a , [ will enter this copy mode. and press Esc to exit this mode.
Then, press ctrl+a, ] will past what you have copied in vi mode.
But I do not know if I can use screen to buffer some text, and then
avatar
p*h
10
enter the following line in your .vimrc file.
map v i"this is debug trace"
you will be able to press v and have the text entered.
This is really a beginner's question.
avatar
a*i
11

Easy, use screen's bufferfile command.
bufferfile [exchange-file]
Change the filename used for reading and writing with the paste
buffer. If the optional argument to the "bufferfile" command is omitted,
the default setting ("/tmp/screen-exchange") is reactivated. The following
example will paste the system\u2019s password file into the screen window (
using the paste buffer, where a copy remains):
C-a : bufferfile /etc/passwd
C-a < C-a

【在 e***e 的大作中提到】
: can this be done for screen?
: My enviroment is use screen to open many buffers. Then, I use sqlplus
: command line to connect Oracle. The problem is I insert a text frequently
: when I type Sql query. So, can this be done in screen too?
: I know screen has a copy mode, that allow you to use vi to copy.
: ctrl+a , [ will enter this copy mode. and press Esc to exit this mode.
: Then, press ctrl+a, ] will past what you have copied in vi mode.
: But I do not know if I can use screen to buffer some text, and then

avatar
e*n
12
这样啊,一直没明白那个+是啥意思。

【在 a*****i 的大作中提到】
: And also remember, the content in X11's clipboard is in register
: +. So whatever you highlighted can be copied into your vim/gvim
: with "+p.

avatar
f*g
13
i usually do this way:
注意那个 ^[ 符号是通过先按 Ctrl+V 再按 Esc 键得到的。
avatar
L*1
14
Did I miss the point? It's so simple, you already got a short cut. I've been
using it for almost 20 years:
1. delete the text you want to paste (insert) using x or dd.
For example, if I move the cursor to "d" in "delete", 10x will delete "
delete the", dd will delete the whole line.
2. shift-p to paste it back. Move the cursor to anywhere and do as many
times as you want.
avatar
e*e
15
you miss the point. The point is if you frequently open a new file and want
to add something at random time, your method will not work.
avatar
e*e
16
The buffer file for screen and map for vi work great!
thanks for sharing.
To summarize, for screen do the following :
1. ctrl+a,then press [ to enter copy mode.
2. go to the line you want to copy. Put the curse at the beginning of the
character, then press SPACE once.
3. move the cursor to the ending character, press SPACE once.The block to be
copied will be highlighted.
4. press ESC to exist copy mode. Then press clt+a, then press >. The copied
contend will be written to a default buffer file
5
avatar
e*e
17
Sorry, I missed one step in the above post. here is the complete one:
To summarize, for screen do the following :
1. ctrl+a,then press [ to enter copy mode.
2. go to the line you want to copy. Put the curse at the beginning of the
character, then press SPACE once.
3. move the cursor to the ending character, press SPACE once.The block to be
copied will be highlighted.
4. press ESC to exist copy mode. Then press clt+a, then press >. The copied
contend will be written to a default buffer file
5. So
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。