vi

How do I join two lines in vi?

扶醉桌前 提交于 2019-11-28 02:51:57
I have two lines in a text file like below: S<Switch_ID>_F<File type> _ID<ID number>_T<date+time>_O<Original File name>.DAT I want to append the two lines in vi like below: S<Switch_ID>_F<File type>_ID<ID number>_T<date+time>_O<Original File name>.DAT The second line got deleted and the contents of the second line was appended to the first line. How could I do it using command mode in vi? GJ. Shift + J removes the line change character from the current line, so by pressing "J" at any place in the line you can combine the current line and the next line in the way you want. Maxim Kim Vi or Vim?

Copy and paste content from one file to another file in vi

隐身守侯 提交于 2019-11-28 02:34:27
I am working with two files, I need to copy a few lines from one file and paste into another file. I know how to copy (yy) and paste(p) in the same file. But that doesn't work for different files, how is this done?? Also, is there a way to cut-paste? I have tried googling, but most of the resources only talk about copy-paste. Since you already know how to cut/yank text, here are a few ideas for pasting it back into another file: Edit the first file, yanking the text you want. Then open your second file from within vi ( :e /path/to/other/file ) and paste it Open both files together in a split

Linux 常用命令

早过忘川 提交于 2019-11-28 02:33:34
vi :w 保存文件但不退出vi :w file 将修改另外保存到file中,不退出vi :w! 强制保存,不推出vi :wq 保存文件并退出vi :wq! 强制保存文件,并退出vi :q 不保存文件,退出vi :q! 不保存文件,强制退出vi :e! 放弃所有修改,从上次保存文件开始再编辑 i 进入编辑状态 esc 推出编辑状态,进入命令接收状态 iptables - 防火墙查看与配置 iptables -L -n 查看当前防火墙配置 iptables -F 清除防火墙配置 查看Linux版本 lsb_release -a cat /proc/version ps -ef|grep java 查看进程 kill -9 pid 杀进程 chmod 777 /目录/ -R 授权文件夹和文件夹下的所有文件 rm -rf 目录或文件 删除目录(包括目录中的文件和子目录)或文件 mkdir 文件夹名字 创建文件夹 mkdir -p /acn/ty12345/log 创建多级目录 cp -R /var/lib/mysql/ mysqldata 复制文件(夹)cp -R frompath topath scp -r filepath root@59.195.63.114:/topath/ 跨机器复制 zip -q -r cmcp.zip cmcp 压缩文件夹 查看MySQL的版本 mysql

Any way to delete in vim without overwriting your last yank? [duplicate]

孤街醉人 提交于 2019-11-28 02:33:02
This question already has an answer here: In Vim is there a way to delete without putting text in the register? 21 answers I love vim, but one common gotcha is: yank a line go to where you would like to paste it delete what's there paste your yank, only to discover that it pastes what you just deleted Obviously the workflow is delete first, yank second. But it would be reeeeeaaaaaalllly nice if I didn't have to. Anyone have a trick for this? Does vim have a paste buffer that works well, or is there a .vimrc setting I can change? dash-tom-bang Pass to the _ register, the black hole. To delete a

Find and replace strings in vim on multiple lines

久未见 提交于 2019-11-28 02:32:13
I can do :%s/<search_string>/<replace_string>/g for replacing a string across a file, or :s/<search_string>/<replace_string>/ to replace in current line. How can I select and replace words from selective lines in vim? Example: replace text from lines 6-10 , 14-18 but not from 11-13 . The :&& command repeats the last substitution with the same flags. You can supply the additional range(s) to it (and concatenate as many as you like): :6,10s/<search_string>/<replace_string>/g | 14,18&& If you have many ranges though, I'd rather use a loop: :for range in split('6,10 14,18')| exe range 's/<search

Replace tabs with spaces in vim

巧了我就是萌 提交于 2019-11-28 02:30:50
I would like to convert tab to spaces in gVim. I added the following line to my _vimrc : set tabstop=2 It works to stop at two spaces but it still looks like one tab key is inserted (I tried to use the h key to count spaces afterwards). I'm not sure what should I do to make gVim convert tabs to spaces? IIRC, something like: set tabstop=2 shiftwidth=2 expandtab should do the trick. If you already have tabs, then follow it up with a nice global RE to replace them with double spaces. ʞɔıu Once you've got expandtab on as per the other answers, the extremely convenient way to convert existing files

What is the best way to force yourself to master vi? [closed]

隐身守侯 提交于 2019-11-28 02:30:46
A good while ago, I read an article by the creator of viemu , clearing up a lot of the misconceptions about vi, as well as explaining why it's a good idea (and why it's been very popular for the last 30 years+). The same guy also has a great set of graphical cheat sheets that teach the basics a few bits at a time. I'm convinced. I've been convinced for the past 2 years in fact. But I still really haven't gotten around to force myself to learn vi as my primary editor, the learning curve is just too high. When I get down to work, acceptable but immediate productivity (using my current editor)

Removing BOM characters using Java [duplicate]

╄→гoц情女王★ 提交于 2019-11-28 01:48:48
This question already has an answer here: Byte order mark screws up file reading in Java 8 answers What needs to happen to a string using Java to be an equivalent of vi s :set nobomb Assume that BOM comes from the file I am reading. Java does not handle BOM properly. In fact Java handles a BOM like every other char. Found this: http://www.rgagnon.com/javadetails/java-handle-utf8-file-with-bom.html public static final String UTF8_BOM = "\uFEFF"; private static String removeUTF8BOM(String s) { if (s.startsWith(UTF8_BOM)) { s = s.substring(1); } return s; } May be I would use apache IO instead:

vi/vim 基本使用方法

独自空忆成欢 提交于 2019-11-28 01:45:46
本文介绍了vi (vim)的基本使用方法,但对于普通用户来说基本上够了!i/vim的区别简单点来说,它们都是多模式编辑器,不同的是vim 是vi的升级版本,它不仅兼容vi的所有指令,而且还有一些新的特性在里面。例如语法加亮,可视化操作不仅可以在终端运行,也可以运行于x window、 mac os、 windows。 vi编辑器是所有Unix及Linux系统下标准的编辑器,它的强大不逊色于任何最新的文本编辑器,这里只是简单地介绍一下它的用法和一小部分指令。由于对Unix及 Linux系统的任何版本,vi编辑器是完全相同的,因此您可以在其他任何介绍vi的地方进一步了解它。Vi也是Linux中最基本的文本编辑器,学会它后,您将在Linux的世界里畅行无阻。 [简单地,可以使用上下左右方向箭头和delete,backspace键来进行位置移动和删除,不管是命令模式还是插入模式] 1、vi的基本概念 基本上vi可以分为三种状态,分别是命令模式(command mode)、插入模式(Insert mode)和底行模式(last line mode),各模式的功能区分如下: 1) 命令行模式command mode) 控制屏幕光标的移动,字符、字或行的删除,移动复制某区段及进入Insert mode下,或者到 last line mode。 2) 插入模式(Insert mode)

Software Requirements for Code Creation / Editor with RSI Type Symptoms (unusable fingers)

孤街醉人 提交于 2019-11-28 01:42:17
问题 I do know and have read the appropriate topics section for this site. I have seen various topics about RSI, posture etc closed as being off topic and referred to another site/section. I think however that my question will be worded such that it comes under the "Software Requirements" section as I am looking for input on specific types as well as configuration of software for some very specific medical issues I have. This is not a topic about prevention of RSI, it is just the closest I can put