vim

Vim - Performing substitution on certain lines only

好久不见. 提交于 2020-01-14 06:22:13
问题 I have found the following in my quest to perform a substitution on even numbered lines only: :g/^/if !(line('.')%2)|s/foo/bar/g|endif Works great. But can someone please explain the need for the | characters in the command section of the :g call? 回答1: The | character is the command separator ; with it, you can concatenate multiple Ex commands in a single line, without adding newlines. See :help :bar. So, your conditional is equivalent to the following: if !(line('.')%2) s/foo/bar/g endif

Replacing HTML text elements with increment variable

折月煮酒 提交于 2020-01-14 06:08:48
问题 In the below HTML part, I want to replace, whenever a text is found, with an incremental variable: <li class="cat-item"> <a href="#" >Beautiful Reclessness</a> </li> <li class="cat-item"> <a href="#" >Comfort vs. Appearance</a> </li> <li class="cat-item"> <a href="#" >Highlights of the Runway</a> <ul class='children'> <li class="cat-item"> <a href="#" >Christian Louboutin Show</a> </li> <li class="cat-item"> <a href="#" >Givenchy F/W 2016</a> </li> <li class="cat-item"> <a href="#" >Spring by

How to read and/or save Python output in VIM

佐手、 提交于 2020-01-14 05:49:20
问题 I'm new to VIM and am using this command to save and run a Python script: :w !python However, I can't move up and down to read the output. The only option I am given is to press enter or enter a command. I tried to yank( :%y+ ) everything, but the actual code is yanked and not the output. I would prefer to be able to read all the output displayed in VIM and even better would be opening a new tab with the output and being able to search and read through all of it. 回答1: You can use redirection

Vim search replace regex + incremental function

不羁的心 提交于 2020-01-14 03:35:14
问题 I'm currently stuck in vim trying to find a search/replace oneliner to replace a number with another + increment for each new iteration = when it finds a new match. I'm working in xml svg code to batch process files Inkscape cannot process the text (plain svg multiline text bug). <tspan x="938.91315" y="783.20563" id="tspan13017" style="font-weight:bold">Text1:</tspan><tspan x="938.91315" y="833.20563" id="tspan13019">Text2</tspan><tspan x="938.91315" y="883.20563" id="tspan13021">✗Text3<

Ubuntu安装vim,把国外源换成阿里源

风格不统一 提交于 2020-01-14 03:18:34
Ubuntu安装vim,把国外源换成阿里源 1,安装vim sudo apt-get install vim。 2,打开sources.list文件, sudo vim /etc/apt/sources.list 注释掉里面的所有代码,把阿里源代码复制进去,退出(Esc键:wq) 阿里源跟换 deb-src http://archive.ubuntu.com/ubuntu xenial main restricted #Added by software-properties deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted multiverse universe #Added by software-properties deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted multiverse universe #Added by software

pod健康检查详解(liveness,readiness,滚动更新)

独自空忆成欢 提交于 2020-01-14 02:21:16
环境介绍 主机 IP地址 服务 master 192.168.1.21 k8s+httpd+nginx node01 192.168.1.22 k8s node02 192.168.1.23 k8s 基于[ https://blog.51cto.com/14320361/2464655 ]() 的实验继续进行 一、Pod的liveness和readiness探针   Kubelet使用liveness probe(存活探针)来确定何时重启容器。例如,当应用程序处于运行状态但无法做进一步操作,liveness探针将捕获到deadlock,重启处于该状态下的容器,使应用程序在存在bug的情况下依然能够继续运行下去   Kubelet使用readiness probe(就绪探针)来确定容器是否已经就绪可以接受流量。只有当Pod中的容器都处于就绪状态时kubelet才会认定该Pod处于就绪状态。该信号的作用是控制哪些Pod应该作为service的后端。如果Pod处于非就绪状态,那么它们将会被从service的load balancer中移除。 Probe支持以下三种检查方法: <1>exec-命令 在用户容器内执行一次命令,如果命令执行的退出码为0,则认为应用程序正常运行,其他任务应用程序运行不正常。 livenessProbe: exec: command: - cat - /home

Nginx:Rewrite跳转设置及使用场景

孤街浪徒 提交于 2020-01-14 02:06:22
一:Rewrite跳转理论知识: 1,Rewrite实用场景 Nginx跳转需求的实现方式 ​ 使用rewrite进行匹配跳转 ​ 使用if匹配全局变量后跳转 ​ 使用location匹配再跳转 rewrite放在server{}, if{}, location{} 段中 对域名或参数字符串 ​ 使用if全局变量匹配 ​ 使用proxy_pass反向代理 2,Rewrite命令 语法: rewrite < regex > < replacement > [flag]; < regex >:正则 < replacement > : 跳转后的内容 [flag] :rewrite支持的flag标记,可写可不写 flag标记说明: 标记 说明 last 相当于Apache的[L]标记,表示完成rewrite break 本条规则匹配完成即终止,不再匹配后面的任何规则 redirect 返回302临时重定向,浏览器地址会显示跳转后的URL地址,爬虫不会更新url permanent 返回301永久重定向,浏览器地址栏会显示跳转后的URL地址,爬虫更新url last和break比较: last break 使用场景 一般写在 server 和 if 中 一般使用在location中 URL匹配 不终止重写后的url匹配 终止重写后的ur|匹配 3,常用的正则表达式元字符 字符 说 明 ^

Linux Vim编辑器使用入门(二)

有些话、适合烂在心里 提交于 2020-01-14 01:44:22
普通模式下光标移动命令 1. 上下左右移动 h 左移一个字符 j 下移一行(文本中的下一行) k 上移一行(文本中的上一行) l 右移一个字符 注:上述四个命令也可用键盘中的上下左右键代替 2. 快速移动的命令 PageDown(或Ctr+F) 下翻一屏 PageUp(或Ctr+B) 下翻一屏 G 移到缓冲区的最后一行 num G 移动到缓冲区的第num行(如:20 G,光标直接定位到第20行,Debug时最常用) gg 移到缓冲区的第一行 普通模式下编辑数据命令 在插入模式下,你可以向缓冲区中插入数据。然而有时将数据输入到缓冲区后,你需要在对其进行添加或删除。在普通模式下,Vim编辑器提供了一些命令来直接编辑缓冲区的数据。 x 删除当前光标所在位置的字符 dd 删除当前光标所在行 dw 删除当前光标所在位置的单词 d$ 当初当前光标所在位置至行尾的内容 J 删除当前光标所在行行尾的换行符(拼接行) u 撤销前一编辑命令 a 在当前光标处追加数据 A 在当前光标所在行行尾追加数据 r char 用char替换当前光标所在位置的单个字符 R text 用text覆盖当前光标所在位置,直到按下ESC键 注:有些编辑命令允许使用数字修饰符来指定重复该命令多少次。比如命令 5dd 会删除从光标所在行开始的5行 普通模式下复制和粘贴 剪切粘贴 :vim在删除数据时

Dealing with \r \n ^M ^@ in text files using vim

南笙酒味 提交于 2020-01-13 19:14:32
问题 When I save lines of data in excel files as tab delimited .txt files, and then open those files in VIM, I see that what was once a multi-line file in excel is now a single line file in VIM. The "lines" can be separated in VIM using some substitution commands: %s/^M/\r\n/g After this, the "lines" are now separated by an ^@ . I deal with it using another substitution command: %s/^@//g My questions are: Why do my multi-line txt excel files open as a single line in VI? What is ^@ ? Is there a

Dealing with \r \n ^M ^@ in text files using vim

帅比萌擦擦* 提交于 2020-01-13 19:14:21
问题 When I save lines of data in excel files as tab delimited .txt files, and then open those files in VIM, I see that what was once a multi-line file in excel is now a single line file in VIM. The "lines" can be separated in VIM using some substitution commands: %s/^M/\r\n/g After this, the "lines" are now separated by an ^@ . I deal with it using another substitution command: %s/^@//g My questions are: Why do my multi-line txt excel files open as a single line in VI? What is ^@ ? Is there a