vi

Vim - delete until (inclusive) character in multiple lines

一个人想着一个人 提交于 2020-12-29 09:04:32
问题 I have this code: def foo(c: Char) = c match { case 'a': 'B' } My cursor is on the space after = . I want to delete everything until, including, the } . How can I do that? Can I do the same where the cursor is anywhere on the first line? Anywhere in the block (and place the cursor after the = )? 回答1: d/}/e does the job. d/} deletes until the } but adding the /e flag moves the cursor on the last char of the match, effectively deleting everything between the cursor and the } , inclusive . Using

Vim - delete until (inclusive) character in multiple lines

笑着哭i 提交于 2020-12-29 09:03:56
问题 I have this code: def foo(c: Char) = c match { case 'a': 'B' } My cursor is on the space after = . I want to delete everything until, including, the } . How can I do that? Can I do the same where the cursor is anywhere on the first line? Anywhere in the block (and place the cursor after the = )? 回答1: d/}/e does the job. d/} deletes until the } but adding the /e flag moves the cursor on the last char of the match, effectively deleting everything between the cursor and the } , inclusive . Using

Linux 文本编辑器vi的快捷操作

核能气质少年 提交于 2020-12-29 07:50:26
Linux中强大的文件编辑器vi的快捷操作 1)、单行复制-yy vi先调到命令模式,将光标移动到将要复制的行,按"yy",就复制了当前行; 2)、多行复制-yny或nyy 其中n代表要复制的行数 vi先调到命令模式,将光标移动到将要复制的多行的首行,按"yny"或"nyy", 就复 制了从当前行开始的n行 3)、粘贴-p vi先调到命令模式,先复制你要粘贴的内容,将光标移动到你想要粘贴的行的前一 行按“p“; 4)、复制粘贴 vi先调到命令模式,然后输入:5,9 co 12 复制第6行到第9行之间的内容到第12行后面 来源 湖外春色http://www.huwhy.cn/article/13-Linux%20%E6%96%87%E6%9C%AC%E7%BC%96%E8%BE%91%E5%99%A8vi%E7%9A%84%E5%BF%AB%E6%8D%B7%E6%93%8D%E4%BD%9C.html 来源: oschina 链接: https://my.oschina.net/u/1470505/blog/405023

Getting the current row number?

萝らか妹 提交于 2020-11-30 03:43:13
问题 Is there any key mapping that outputs the current row number of the line being edited? Or, even better yet, can we do formulas based on the output of the key mapping? I want to get the row number and add 1 to the current text being edited. 回答1: Ctrl + G will tell you the line number and even the column the cursor is in. If you mean output it as text to your document, then not that I know of. 回答2: What do you mean by "output"? You can do: :echo line(".") + 1 To display the current line number

Getting the current row number?

时光总嘲笑我的痴心妄想 提交于 2020-11-30 03:39:06
问题 Is there any key mapping that outputs the current row number of the line being edited? Or, even better yet, can we do formulas based on the output of the key mapping? I want to get the row number and add 1 to the current text being edited. 回答1: Ctrl + G will tell you the line number and even the column the cursor is in. If you mean output it as text to your document, then not that I know of. 回答2: What do you mean by "output"? You can do: :echo line(".") + 1 To display the current line number

Cannot create backup file(add ! to overwrite)

人盡茶涼 提交于 2020-08-22 02:39:50
问题 Need help. I have been editing a text file in vi , and i was able to save the changes before but now i am getting the above error whenever i am typing command to save the file. Please help . 回答1: You can, as vi (or, more likely, vim ) is saying force a write by doing: :w! Alternatively, write the file to an alternative location: :w! /path/to/other/location To check where your backup files are being written (normally): :se backup? backupdir? backupext? Try to touch a file in that directory and

vim: delete all blank space until next non-blank character

拈花ヽ惹草 提交于 2020-05-09 21:08:11
问题 Say I have the following code: <p> Hello </p> And I want to make it <p>Hello</p> I would like to put the cursor in normal mode at the end of line 1, so on the ' > ' and have a command to delete all spaces until the next character. The closest I can think of is the motion d/Hello which deletes everything until Hello but the issue is that it deletes also the character under the cursor (the ' > ') so I end up with <pHello </p> How would you do that? 回答1: One way when you won't need to repeat

vim: delete all blank space until next non-blank character

本小妞迷上赌 提交于 2020-05-09 21:07:37
问题 Say I have the following code: <p> Hello </p> And I want to make it <p>Hello</p> I would like to put the cursor in normal mode at the end of line 1, so on the ' > ' and have a command to delete all spaces until the next character. The closest I can think of is the motion d/Hello which deletes everything until Hello but the issue is that it deletes also the character under the cursor (the ' > ') so I end up with <pHello </p> How would you do that? 回答1: One way when you won't need to repeat

Gvim 退格键(backspace)不能用

倖福魔咒の 提交于 2020-04-07 02:13:17
两个步骤: 1.去掉讨厌的有关vi一致性模式,避免以前版本的一些bug和局限 set nocompatible 2.backspace有几种工作方式,默认是vi兼容的。对新手来说很不习惯。对老vi 不那么熟悉的人也都挺困扰的。可以用 set backspace=indent,eol,start 来解决。 indent: 如果用了:set indent,:set ai 等自动缩进,想用退格键将字段缩进的删掉,必须设置这个选项。否则不响应。 eol:如果插入模式下在行开头,想通过退格键合并两行,需要设置eol。 start:要想删除此次插入前的输入,需设置这个。 来源: oschina 链接: https://my.oschina.net/u/216139/blog/56593

Centos中vim配置遇到问题总结

醉酒当歌 提交于 2020-04-07 02:11:49
1.backspace自由使用 set backspace=indent,eol,start,这条命令告诉Vim在Insert模式下退格键何时可以删除光标之前的字符.选项中以逗号分隔的三项内容分别指定了Vim缩进,断行,以及开始进入Insert模式之前的位置. 2.vimrc配置在root用户下不起作用 vi /etc/profile.d/vim.sh [root@----- ~]$ vi /etc/profile.d/vim.sh if [ -n "$BASH_VERSION" -o -n "$KSH_VERSION" -o -n "$ZSH_VERSION" ]; then [ -x /usr/bin/id ] || return [ `/usr/bin/id -u` -le 100 ] && return # for bash and zsh, only if no alias is already set alias vi >/dev/null 2>&1 || alias vi=vim fi 注释掉第三行[ `/usr/bin/id -u` -le 100 ] && return 来源: oschina 链接: https://my.oschina.net/u/912849/blog/95976