How to delete selected text in VI editor
I am using putty and vi editor if select 5 lines using mouse and i want to delete those lines how can i do that
Also how can i select the lines from keyboard like in windows i pres shift and move the arrows to select the text. how can i do that in vi
I am using putty and vi editor if select 5 lines using mouse and i want to delete those lines how can i do that
Forget the mouse. To remove 5 lines, either:
Also how can i select the lines from keyboard like in windows i pres shift and move the arrows to select the text. how can i do that in vi
As I said, either use Shift-v to enter linewise selection mode or v to enter characterwise selection mode or Ctrl-v to enter blockwise selection mode. Then move with h, j, k and l.
I suggest spending some time with the VIM Tutor (run vimtutor
) to get more familiar with VIM in a very didactic way.
See also
Do it the vi way.
To delete 5 lines press: 5dd
( 5 delete )
To select ( actually copy them to the clipboard ) you type: 10yy
It is a bit hard to grasp, but very handy to learn when using those remote terminals
Be aware of the learning curves for some editors:
http://unix.rulez.org/~calver/pictures/curves.jpg
If you want to delete using line numbers u can use
:startingline, last line d
example:
:7,20 d
This example will delete line 7 to 20. .
链接地址: http://www.djcxy.com/p/49490.html上一篇: Linux如何在特定时间运行脚本?
下一篇: 如何在VI编辑器中删除选定的文本