vi

How do touch typists navigate in vi?

喜你入骨 提交于 2019-12-04 02:20:56
I'm learning vi, as I appreciate the vast possibilities of the editor, and have to use a plain-text editor for my current project. In many tutorials I have read that it is recommended to use the keys "h", "j", "k" and "l" instead of the arrow keys, for the sake of speed. However, as a touch typist, my fingers are normally in the default position of a, s, d, f (left hand) and j, k, l and ö (right hand [german keyboard]). Navigating in vi requires effectively to place the right hand in the default position of h, j, k and l. This makes writing text correctly hard, as I notice constantly that I

Opening a file stored in HDFS to edit in VI

爷,独闯天下 提交于 2019-12-04 02:19:37
I would like to edit a text file directly in HDFS using VI without having to copy it to local, edit it and then copy it back from local. Is this possible? Edit: This used to be possible in Cloudera's Hue UI but is no longer the case. Ashrith There are couple of options that you could try, which allows you to mount HDFS to your local machine and then you could use your local system commands like cp, rm, cat, mv, mkdir, rmdir, more, etc. But neither of them supports random write operations but supports append operations. NFS Gateway Hadoop Fuse NFS Gateway uses NFS V3 and support appending to

Possible to change length of tab depending on file extension? [duplicate]

偶尔善良 提交于 2019-12-04 02:17:04
Possible Duplicate: Changing Vim indentation behavior by file type Hello. So, I switch between '2' and '4' spaces for tabs very often. Usually I use 2 spaces for a tab for HTML files and 4 spaces for a tab for programming. Is there anyway to configure VIM, so it will automatically adjust depending on the file extension? Also, how come VIM indents 8 spaces sometimes, like after I enter an open brace? I have it set to 4 spaces. Thanks. set sw=4 ts=4 sts=4 " Defaults: four spaces per tab " autocmd FileType html :setlocal sw=2 ts=2 sts=2 " Two spaces for HTML files " Here are three different

Automatic “fancy” comment insertion with Vim

孤者浪人 提交于 2019-12-04 02:01:58
问题 I like to have comments like this in my C code: /******************************************************** * Blah ********************************************************/ But I get tired of typing all those asterisks, and copy/pasting can also get annoying. I was wondering if I could possibly create a macro with Vim so that if I press (for example) CTRL+L , it'll automatically insert that structure in my code and align the cursor in the middle (where the actual comment is written). Any advice

How to detect vi (not vim) in .vimrc?

扶醉桌前 提交于 2019-12-04 00:29:49
I carry a vimrc to all the machines that I work on and it naturally contains options that are not present in old vi. If I accidentally start a vi session on a machine where vi is not an alias to vim and/or vim is not installed, vi reads vimrc and throws a bunch of annoying errors to let me know that option such and such are unsupported. I know I can just always type "vim" instead of "vi" and set the EDITOR variable to vim (for visudo etc...), but is there a line I can add to the top of the vimrc that will exit the script early if the file is read by vi? If vi is not actually a link to vim, it

服务器 vim模式下报错E37: No write since last change (add ! to override)

你离开我真会死。 提交于 2019-12-03 23:03:49
故障现象: 使用vim修改文件报错,系统提示如下: E37: No write since last change (add ! to override) 故障原因: 文件为只读文件,无法修改。 解决办法: 使用命令:w!强制存盘即可,在vim模式下,键入以下命令: :w!(强制写入) :q! (强制保存) 存盘后在使用vim命令检查是否保存,如未保存,编辑后重复以上操作。 或者报出linux中vi保存文件时的“Can't open file for writing” E212: Can't open file for writing Press ENTER or type command to continue 出现这个错误的原因可能有两个: 一是当前用户的权限不足,二是此文件可能正被其他程序或用户使用。 这里的错误原因是前者,解决方案是在使用vi命令打开文件时,前面加上sudo来临时提供管理员权限,即使用命令“sudo vi grub.cfg”打开编辑文件。由此看来,sudo命令是很有用的,当我们执行某种操作系统提示诸如“operation not permitted”等权限不足信息时,我们很多时候都可以在命令前面加上sudo来解决权限不足问题 解决权限问题 用sudo命令 sudo vim 文件   用以上命令,可以对文件进行 写入 保存(可以使用命令 :wq ) 来源:

vim/vi的使用(Ubuntu12.04)

情到浓时终转凉″ 提交于 2019-12-03 21:56:05
1.多行注释: 1. 首先按esc进入命令行模式下,按住Ctrl + v,进入 virtual 模式; 2. 在按住 Ctrl + v 的同时按下方向键或者h/j/k/l,松开 Ctrl + v 进入选择模式,然后使用上下键选择需要注释的多行; 3. 按下键盘(大写i)“I”键,进入插入模式; 4. 然后输入注释符(“//”、“#”等); 5. 最后按下“Esc”键。 2.删除多行注释: 1. 首先按esc进入命令行模式下,按住Ctrl + v,进入 virtual 模式; 2. 在按住 Ctrl + v 的同时按下方向键或者h/j/k/l, 松开 Ctrl + v 进入选择模式 ,然后使用上下左右键选择需要取消注释的符号“ // ”、“#”等; 3. 最后按下“x”或者“d”. 3.执行、导入: r:将文件导入到vi当前光标处。 格式:r path(要导入文件的路径) !:执行命令。格式:! date 或!ls r和!可以配合使用:例如:r !date将当前系统时间追加到当前vi文件光标的下一行。 4.map的使用: map ctrl+v+(快捷键) 要执行的指令集(键入 ctrl+v后显示"^" ) ctrl+v 相当于提取快捷键的指令,后面紧跟即将要设置的快捷键(例如ctrl+c、 ctrl+z,需要注意的是esc等特殊的功能键在map的输入之前也需要 添加Ctrl+v

vi 编辑器,gcc 编译器的使用

六月ゝ 毕业季﹏ 提交于 2019-12-03 21:53:56
vi 编辑器 是我们在linux下经常使用的文本编辑器,这个东西也是专门为程序员准备的,基本上每个Unix和Linux系统都为我们提供了这个软件,我们可以使用vi来编写我们的代码。 在vi编辑器下所有操作都必须通过键盘和特定的快捷键组合来完成,刚开始学习的新手会感觉不太容易,但是这个东西很重要,我们先来学习如何使用它,掌握了这个东西去面试的时候也算是一门技能。 而vim是vi的增强版,新增加了很多功能。 在shell下输入命令vi 文件名,例如:vi first.c,就开始编辑first.c文件了。vi编辑器有三种模式,它们分别为 命令模式,底行命令模式和编辑模式, 各个模式的转换如下。 命令模式( 按i进入编辑模式。按":"进入底行命令模式 )。当我们vi first.c的时候一进入就是命令模式,在这个模式下,我们可以执行如下的操作。 x:删除一个字符 dd:删除光标所在行 ndd:删除n行 p:粘贴光标下行,就是把复制的内容粘贴到光标所在行的下一行。 yy:复制光标所在行 nyy:复制n行 u:恢复上一次操作 编辑模式( 按Esc回到命令模式,然后再按下:就到了底行命令模式 )。在命令模式的时候我们按下i键就进入了这个模式,这个时候就可以编辑文字了。我们输入的每个字符都会写上去,不像命令模式那样字符代表的是一种命令。 底行命令模式 :支持如下的一些常用命令

【Linux常见命令】vi,vim命令

▼魔方 西西 提交于 2019-12-03 21:03:47
- i 进入编辑模式 - dd 在命令模式下删除行 - yy 命令模式下,复制,然后另起一行, - p 命令模式下,粘贴 - esc 进入命令模式 - :wq 保存并退出 - :set nu 命令行模式下,设置显示行号 - :ser nonu 命令行模式下,设置取消显示行号 - shift+g 跳转到最后一行开头 - o 进入编辑模式,同时定位到下一行 所有的 Unix Like 系统都会内建 vi 文书编辑器,其他的文书编辑器则不一定会存在。 但是目前我们使用比较多的是 vim 编辑器。 vim 具有程序编辑的能力,可以主动的以字体颜色辨别语法的正确性,方便程序设计。 Vi/VIM的三种模式: 命令模式(Command mode) 输入模式(Insert mode) 底线命令模式(Last line mode) 进入VI: vi file 打开/新建文件,光标置于第1行行首 vi file +n 打开文件,光标置于第n行行首 vi file + 打开文件,光标置于最后一行行首 vi file +/pattern 将表表置于第一个与pattern匹配的字符串处 vi -r file 在使用vi时发生系统崩溃,恢复 vi file ... file 打开多个文件,依次进行编辑 编辑模式: i,I 插入光标前 a,A 插入光标后 o,O 插入新的一行 r,R 替换 r

How can I prepend text in the middle of the line to multiple lines in Vim?

百般思念 提交于 2019-12-03 17:55:46
问题 Say I have ten lines and I want to prepend text to some word that occurs in those lines? It does not have to be at the beginning of the line. From: sdfsd foo sdfsd sfsd foo fsdf sdfsdf foo sdfsdf to: sdfsd bar(foo sdfsd sfsd bar(foo fsdf sdfsdf bar(foo sdfsdf Is it also possible to not only prepend the bar( but actually surround foo with bar(foo) ? I would also like a quick way to append // comments to multiple lines (C-style comments). I use Vim/GVim 7.2. 回答1: Go to the first foo , press