vi tips (continueing updated)

本文介绍Vi编辑器的基本操作,包括三种工作模式、文件的打开与保存、文本的查找与替换等。此外,还介绍了Vi编辑器中的一些高级技巧,如文本块操作、列编辑、文本格式化等。

#three modes(三种模式)

Command mode (命名模式)

    This is the default when you enter vi. In command mode, most letters, or short sequences of letters, that you type will be interpreted as commands, without explicitly pressing Enter . If you press Esc when you're in command mode, your terminal will beep at you. This is a very good way to tell when you're in command mode.

    这是进入vi的默认模式。在该模式下,大多数字母或字母序列,都将作为是命名执行,而不需要按Enter键。如果你按Esc键,系统将发出嘟嘟的声音。这是判断是否进入该模式的一个好方法。

Insert mode (编辑模式)

    In insert mode, whatever you type is inserted in the file at the cursor position. Type a (lowercase letter a, for append),A,i,I,o,O to enter insert mode from command mode; press Esc to end insert mode, and return to command mode.

    在插入(我觉得叫编辑模式贴切)模式,所有的输入都被插入在光标位置,输入a(在光标位置后追加),A(在光标所以行末尾追加),i(在光标位置之前插入),I(在光标所在行行头插入),o(在光标所在行之下插入新空行),O(在光标所在行之上插入新空行)从命名模式进出插入模式。按Esc返回到命名模式。

Line mode (命名行模式)

    Use line mode to enter line oriented commands. To enter line mode from command mode, type a colon ( : ). Your cursor moves to the bottom of the screen, by a colon prompt. Type a line mode command, then press Enter. Any sensible command from the Unix line editor ex will work, and a few are good to know about. 

    用行模式输入面向行的命令。键入冒号(:)进入行模式,光标会移动到屏幕的底部,这里会有一个冒号的提示符。输入一个行命令,然后敲回车键,任何unix编辑器ex的智能命名都可以被执行,其中有一些命名是很有用的。

 

#starting vi and  saving files(开始vi并保存文件)

#start editing filename, create it if necessary

vi filename

开始编辑一个文件,如果文件不存在则创建一个新文件。

#write the file to disk and quit

:wq

保存文件并退出

#quit without saving any changes

:q!

强制退出,不保存。

#write all lines from the entire current file into the file 'newfile', overwriting any existing newfile

:w! newfile

将当前文件整个写入到新文件中,如果新文件存在则将被覆盖。

#write the lines from n to m, inclusive, into the file newfile, overwriting any existing newfile

:n,m w! newfile 

将当前文件的第n到m行,包括n和m行,写入到新文件里,如果文件存在则被覆盖。

 

#Moving the cursor(移动光标)

    Many commands take number prefixes; for example 5w moves to the right by 5 words.

   很多命令都可以以数字作为前缀。例如,5w则向右移动5个words.

Type:To Move To:
hone space to the left (also try left arrow)
jone line down (also try down arrow)
kone line up (also try up arrow)
lone space to the right (also try right arrow)
$end of current line
^beginning of current line
Enterbeginning first word on the next line
Gend of file
:nline n; use :0 to move the beginning of the file
wbeginning of next word; 5w moves to the beginning of the 5th word to the right
eend of next word
bbeginning of previous word
Ctrl-bone page up
Ctrl-fone page down
%the matching (, ), [, ], {, or } 
(Press % with your cursor on one of these characters to move your cursor its mate.)

 

 #searching text(搜索文本)

Type:To:
/stringsearch down for string
?stringsearch up for string
nrepeat last search from present position 

 

#insertind text(插入文本)

 

 

Type: To: 
append starting right of cursor 
append at the end of the current line 
insert starting left of cursor 
insert at beginning of the current line 
open line below cursor, then enter insert mode 
open line above cursor, then enter insert mode 
:r newfile add the contents of the file newfile starting below the current line 

 

#deleting text(删除文本)

 

Type:To:
xdelete single character; 5x deletes 5 characters
dwdelete word; 5dw deletes 5 words
dddelete line; 5dd deletes ... well you get the idea!
cwdelete word, leaves you in insert mode (i.e. change word)
ccchange line -- delete line and start insert mode
schange character -- delete character and start insert mode
Ddelete from cursor to end of line
Cchange from cursor to end of line -- delete and start insert mode
uundo last change
Uundo all changes to current line
Jjoin current line with line that follows (press Enter in insert mode to split line)

#cutting and pasting(剪切和粘贴)

Type:To:
xptranspose two characters (two commands, x followed by p)
yyyank (i.e. copy) one line into a general buffer (5yy to yank 5 lines)
"ayyyank into the buffer named a
Pput the general buffer back before the current line
"aPput from buffer a before current line
pput the general buffer back after the current line
"apput from buffer a after the current line 

 

    Note: dd and any other delete will save a copy of the deleted string in the same general buffer.Therefor a cut and paste can be done with dd and p, rather than copy with yy and p. But make sure not to overwrite the buffer with some other yank or delete command before you have a chance to paste.

    注意:dd和其他删除命令会保存一份被删除的字符串在同一个普通缓冲区。因此剪切和粘贴可以用dd后再用p命令完成,而不是用yy和p。但是,你需要确认,在你粘贴之前,不能用其他删除或复制的命令。

 

#miscellaneous Commands (其他杂项)

Type:To:
Ctrl-gshow line number of current line
Ctrl-lredraw the entire display
:!shfork a shell; type Ctrl-d to get back to vi
.repeat last text change command at current cursor position

 

 

#Customizing vi: the .exrc file

The .exrc file in your login directory is a collection of vi commands to customize that environment.

.exrc 文件在你登录目录,它是vi命令和自定义环境的一个集合。

:set showmodeshow when you are in insert mode
:set icignore case when searching
:set noicturn ignore case off
:set nuturn on line numbering
:set nonuturn line numbering off

 

#block editing(块操作)

快速处理 '、"、()、[]、{}、<> 等配对标点符号中的文本内容,包括更改、删除、复制等。

  • ci'、ci"、ci(、ci[、ci{、ci< - 分别更改这些配对标点符号中的文本内容
  • di'、di"、di(、di[、di{、di< - 分别删除这些配对标点符号中的文本内容
  • yi'、yi"、yi(、yi[、yi{、yi< - 分别复制这些配对标点符号中的文本内容
  • di(等价于dib,di{等价于diB。
  • 把 i 改成 a 的话,会连配对标点一起操作
  • 写HTML的时候还有vit, vat, dit, dat, cit, cat等等

#row editing(列编辑)

ctrl+v 进入列编辑Visual Block模式

h,j,k,l 移动光标

i 插入 esc确认

d删除 esc确认

 

#example(使用实例)

1.character twiddling(字符颠倒)

     "the"->"teh"

    the 打成了teh

    put the cursor on the cursor on the "e" and type xp.

    把光标放到e上让后输入xp

    The "x" command deletes a character (the "e") and the "p" pastes it after the cursor (which is now placed over the "h".)

    x命令删除一个字符(这是是e),而p命令会把它粘贴在当前光标(这个时候被h代替)之后。

2.interactively replacing one word with another (把一个单词换成另外一个 one by one)

    Suppose you want to replace every occurrence of the word "idiot" with the word "manager". But you want the chance to review each change before you do it.

    Here is what you do:

1.1GGo to the top of the document
2./idiot<enter>Find the first occurrence of the word "idiot"
3.cwmanagerChange the word (cw) to manager.
4.nRepeat the last search (find the next idiot.)
5. .Repeat the last edit (change one word to manager)
(If you do not want to change the word, skip this step.)

    假设把所有的单词idiot置换成manager,但是你又想在每次置换前在重新确认一边。就按以上步骤操作。

3.interactively replacing one word with another (把一个单词换成另外一个 another method)

    Suppose you want to replace every occurrence of the word "idiot" with the word "manager". But you want the chance to review each change before you do it.

    Execute the command:

        :%s//<idiot/>/manager/gc

This command will make the change and pause after each change to give you a chance to confirm it. You can enter "y" to accept the change or "n" to not accept it.  

    假设把所有的单词idiot置换成manager,但是你又想在每次置换前在重新确认一边。就用该命令,这个命令会在做置换的时候提示你是否确认,如果确认则输入y,否则输入n即可。命令的解释如下

   

:Enter command mode
%Perform this command on all lines (% is a synomim for the first to last line.)
sThe short form of the :substitute command.
//<idiot/>/This text specifies the text we are looking for wand want. The /< tells Vim to match a word start and the /> tells Vim to match the end of a word.
/manager/The replacement text
gcThe flags. These are
g
Global -- Change every occurance, not use the first one on each line
c
Confirm -- Ask before making each change

4.moving text using vi style command(移动文字 用vi形势的命令)

   

CommandExplaination
1. Move the cursor to the top of the paragraph you want to move.
2.maPlace a mark named "a" at this location. (Vim will give you no indication that this command has been executed. In other words, the screen will not change.)
3. Move the cursor to the bottom of the paragraph to be moved.
4.d'aDelete to mark "a". This puts the deleted text in a cut buffer.
5. Move the cursor to line where the text is to go. The paragraph will be placed after this one.
6.pPaste the text in below the cursor.

5.moving text using visual block(移动文字 用虚拟块的方式)

CommandExplaination
1. Move the cursor to the top of the paragraph you want to move.
2.vStart visual mode. (If you want to move only full lines, use the V command which starts visual line mode.
3. Move the cursor to the bottom of the paragraph to be moved. The text to be moved will be hightlighted.
4.dPerform a visual delete. In other words delete the highlighted text.
5. Move the cursor to line where the text is to go. The paragraph will be placed after this one.
6.pPaste the text in below the cursor.

6.copy a block of text from one file to another vi style(把文本块从一个文件复制到另外一个文件 vi 方式)

CommandExplaination
1. Edit the file containing the text you want to copy.
2. Go to the top line to be copied.
3.maMark this line as mark "a".
4. Go to the bottom line to be copied
5.y'aYank (y) the text from the current cursor location to the mark "a" ('a)
6.:split second-fileOpen another window containing the second file. (This the file in which the text is to be inserted.)
7. Go to the line where the insert is to occur. The text will be place after this line.
8.pPut the text after the cursor.

7.copy a block of text from one file to another visual block

CommandExplaination
1. Edit the file containing the text to be copied.
2. Go to the top line to be copied.
3.vStart visual mode. If you want to copy a block of full lines, use V to go start Visual Line Mode
4. Go to the bottom line to be copied. The text to be copied will be hightlighted.
5.yYank (y) the text.
6.:split second-fileOpen another window containing the second file. (This the file in which the text is to be inserted.)
7. Go to the line where the insert is to occur. The text will be place after this line.
8.pPut the text after the cursor.

8.sorting a session vi style (分类)

CommandExplaination
1. Move the cursor to the first line to be sorted.
2.maMark the first line as mark a.
3. Move to the bottom of the text to be sorted.
4.!'asortThe ! command tells Vim to run the text through UNIX command. The 'a tell the editor that the text to be worked on starts at the current line and ends at mark a. The command that the text is to go through is sort.

9.sorting a session visual block

CommandExplaination
1. Move the cursor to the first line to be sorted.
2.VEnter visual line mode
3. Move to the bottom of the text to be sorted.
4.!sortThe ! command tells Vim to run the hightlighted text through UNIX command. The command that the text is to go through is sort.

注意:/ spce tab(:set list)的特殊处理

10.formating a text paragraph(设置段落格式)

:set wrapmargin=70

CommandExplaination
1. Move to the top of the paragraph.
2.gq}The "!" command tells Vim to pipe a section of text through a filter. The } tells Vim that the section of text for the pipe command is a single paragraph.
3.fmt -70The UNIX command fmt is a primitive formatter. It performs word-wrapping well enough for text documentation. The -70 tells fmt to format lines for 70 characters per line.

11.find a procedure in  c program

    generate a table of contents of all the C program files in your current working directory, use the command:

    $ctags *.c

    then if you want to edit the procedure write_file use the command:

    $vi -t write_file

    Now suppose as you are looking at the write_file procedure that it calls setup_data and you need to look at that procedure. To jump to that function, position the cursor at the beginning of the word setup_data and press Ctrl+]. This tells Vim to jump to the definition of this procedure. This repositioning will occur even if Vim has to change files to do so.

12.drawing a comment box(画一个注释框 利用类似alias别名的方法)

 

I like to put a big comment box at the top of each of my procedures. For example:

	/*******************************************************
	 * Program -- Solve it -- Solves the worlds problems.  *
	 *     All of them.  At once.  This will be a great    *
	 *   program when I finish it.                         *
	 *******************************************************/

Drawing these boxes like this is tedious at best. But Vim has a nice feature called abbreviations that makes things easier.

First, you need to create a Vim initialization file called ~/.vimrc. (At first this may look like a ex initialization file. It is. The Vim command is actually a mode of the ex editor.)

The ~/.vimrc file need to contain the lines:

        :ab #b /************************************************
        :ab #e ************************************************/

These command define a set of Vim abbreviations. What's a Vim abbreviation? Its a word that stands for another word. When Vim see the abbreviation, it will expand it to the full word. In this case we've defined an abbreviation called #b that expands to the beginning line of a comment box. The #e abbreviation does the same thing.

So to create a comment box enter #b<enter>. The screen looks like:

        /************************************************

Enter the comments, including the beginning and ending "*" characters. Finally end the comment by typing #e<enter>. This causes the ending comment to be entered.

13.reading a man page(察看命令帮助文档)

    $man subject | ul -i | vim -

14.remving carriage returns from MS-DOS file (删除windows自带的^M)

    To remove the ^M characters from a MS-DOS file, enter the command:

    :1,$s/{ctrl+v}{ctrl+M}//{Enter}

15.trimming the blank of an end line(删除每行结尾的空格或tab)

    :1,$s/[ <tab>]*$//

16.change "first,last" to "last first"

    :1,$s//([^,]*/), /(.*$/)//2 /1/

   

    The figure below shows the relationship between the /( /) enclosed strings and the /1, /2 markers.

	:1,$s//([^,]*/), /(.*$/)//2 /1/
	      ^^     ^^  ^^   ^^^ ^  ^            
	      ||     ||  ||   ||| |  +-----  String matched by 
	      ||     ||  ||   ||| |          first /( /)
	      ||     ||  ||   ||| +--------- String matched by
	      ||     ||  ||   |||            second /( /)
	      ||     ||  ||   ||+----------- Slash separating 
	      ||     ||  ||   ||             old/new strings
	      ||     ||  ++---++------------ Second /( /) 
	      ++-----++--------------------- First /( /)

The next figure breaks out the various parts of the regular expressions used in this example.

	:1,$s//([^,]*/), /(.*$/)//2 /1/
		^^^^^  ^^  ^^^
		|||||  ||  ||+--- The end of the line
		|||||  ||  |+---- Repeated 0 or more time
		|||||  ||  +----- Any character
		|||||  ||  +++--- Any character, repeated,
		|||||  ||             followed by EOL
		|||||  |+-------- The character space
		|||||  +--------- The character comma
		||||+------------ Repeated 0 or more times
		|||+------------- Closes the [] expression
		||+-------------- The character comma
		|+--------------- Match anything except the
		|                 next character
		+---------------- Starts a set of matches
		++++------------- Match anything but comma
		    +------------ Repeated 0 or more times
		       +--------- Followed by comma

 

17.how to edit all the file contains one word (如何批量编辑所有包含某单词的文件)

    $ vim `fgrep -l indentation_level *.c`

    ` is the backtick (`是反)

 

    another method:

    start vi

    :grep >word< >file-list<

    This finds the first location of word in the given files and positions the cursor on that line. You can use the command :cn to find the next occurance.

标题SpringBoot智能在线预约挂号系统研究AI更换标题第1章引言介绍智能在线预约挂号系统的研究背景、意义、国内外研究现状及论文创新点。1.1研究背景与意义阐述智能在线预约挂号系统对提升医疗服务效率的重要性。1.2国内外研究现状分析国内外智能在线预约挂号系统的研究与应用情况。1.3研究方法及创新点概述本文采用的技术路线、研究方法及主要创新点。第2章相关理论总结智能在线预约挂号系统相关理论,包括系统架构、开发技术等。2.1系统架构设计理论介绍系统架构设计的基本原则和常用方法。2.2SpringBoot开发框架理论阐述SpringBoot框架的特点、优势及其在系统开发中的应用。2.3数据库设计与管理理论介绍数据库设计原则、数据模型及数据库管理系统。2.4网络安全与数据保护理论讨论网络安全威胁、数据保护技术及其在系统中的应用。第3章SpringBoot智能在线预约挂号系统设计详细介绍系统的设计方案,包括功能模块划分、数据库设计等。3.1系统功能模块设计划分系统功能模块,如用户管理、挂号管理、医生排班等。3.2数据库设计与实现设计数据库表结构,确定字段类型、主键及外键关系。3.3用户界面设计设计用户友好的界面,提升用户体验。3.4系统安全设计阐述系统安全策略,包括用户认证、数据加密等。第4章系统实现与测试介绍系统的实现过程,包括编码、测试及优化等。4.1系统编码实现采用SpringBoot框架进行系统编码实现。4.2系统测试方法介绍系统测试的方法、步骤及测试用例设计。4.3系统性能测试与分析对系统进行性能测试,分析测试结果并提出优化建议。4.4系统优化与改进根据测试结果对系统进行优化和改进,提升系统性能。第5章研究结果呈现系统实现后的效果,包括功能实现、性能提升等。5.1系统功能实现效果展示系统各功能模块的实现效果,如挂号成功界面等。5.2系统性能提升效果对比优化前后的系统性能
在金融行业中,对信用风险的判断是核心环节之一,其结果对机构的信贷政策和风险控制策略有直接影响。本文将围绕如何借助机器学习方法,尤其是Sklearn工具包,建立用于判断信用状况的预测系统。文中将涵盖逻辑回归、支持向量机等常见方法,并通过实际操作流程进行说明。 一、机器学习基本概念 机器学习属于人工智能的子领域,其基本理念是通过数据自动学习规律,而非依赖人工设定规则。在信贷分析中,该技术可用于挖掘历史数据中的潜在规律,进而对未来的信用表现进行预测。 二、Sklearn工具包概述 Sklearn(Scikit-learn)是Python语言中广泛使用的机器学习模块,提供多种数据处理和建模功能。它简化了数据清洗、特征提取、模型构建、验证与优化等流程,是数据科学项目中的常用工具。 三、逻辑回归模型 逻辑回归是一种常用于分类任务的线性模型,特别适用于二类问题。在信用评估中,该模型可用于判断借款人是否可能违约。其通过逻辑函数将输出映射为0到1之间的概率值,从而表示违约的可能性。 四、支持向量机模型 支持向量机是一种用于监督学习的算法,适用于数据维度高、样本量小的情况。在信用分析中,该方法能够通过寻找最佳分割面,区分违约与非违约客户。通过选用不同核函数,可应对复杂的非线性关系,提升预测精度。 五、数据预处理步骤 在建模前,需对原始数据进行清理与转换,包括处理缺失值、识别异常点、标准化数值、筛选有效特征等。对于信用评分,常见的输入变量包括收入水平、负债比例、信用历史记录、职业稳定性等。预处理有助于减少噪声干扰,增强模型的适应性。 六、模型构建与验证 借助Sklearn,可以将数据集划分为训练集和测试集,并通过交叉验证调整参数以提升模型性能。常用评估指标包括准确率、召回率、F1值以及AUC-ROC曲线。在处理不平衡数据时,更应关注模型的召回率与特异性。 七、集成学习方法 为提升模型预测能力,可采用集成策略,如结合多个模型的预测结果。这有助于降低单一模型的偏差与方差,增强整体预测的稳定性与准确性。 综上,基于机器学习的信用评估系统可通过Sklearn中的多种算法,结合合理的数据处理与模型优化,实现对借款人信用状况的精准判断。在实际应用中,需持续调整模型以适应市场变化,保障预测结果的长期有效性。 资源来源于网络分享,仅用于学习交流使用,请勿用于商业,如有侵权请联系我删除!
Foodpanda 的全面记录,包含 6000 条精心整理的记录,涵盖了从客户人口统计信息到订单、支付、评价和配送细节的各个方面。它为数据分析师和研究人员提供了一个丰富的资源,可用于深入分析和洞察 Foodpanda 的业务运营和客户行为。 数据集内容客户人口统计信息:数据集详细记录了客户的年龄、性别、收入水平、地理位置等基本信息。这些信息有助于了解不同客户群体的特征,为精准营销和客户细分提供数据支持。 订单信息:每条记录都包含了订单的日期、时间、金额以及购买的商品或服务。通过分析这些数据,可以发现客户的购买习惯和偏好,例如哪些时间段是订单高峰期,哪些菜品最受欢迎。 支付信息:数据集中还包含了支付方式、支付状态和支付金额等信息。这些数据可以帮助分析不同支付方式的使用频率,以及支付成功率等关键指标。 评价信息:客户对订单、服务或产品的评分和评论也被记录在数据集中。这些评价数据对于情感分析和客户满意度研究至关重要,能够帮助 Foodpanda 了解客户的真实反馈,从而改进服务质量。 配送细节:数据集还详细记录了配送时间、配送地址和配送状态等信息。通过分析这些数据,可以优化配送路线和时间,提高客户满意度。 数据集的应用场景:客户行为分析:通过分析客户的购买习惯、偏好和评价,可以更好地了解客户需求,从而提供更个性化的服务。 客户流失预测:利用数据集中的客户行为和评价数据,可以构建模型预测哪些客户可能会流失,以便提前采取措施挽留。 客户细分:根据客户的人口统计信息和购买行为,可以将客户划分为不同的群体,为每个群体提供定制化的服务和营销策略。 销售趋势分析:通过分析订单数据,可以发现销售的增长或下降趋势,为业务决策提供依据。 情感洞察:通过分析客户的评价和评论,可以了解客户对产品或服务的情感倾向,及时发现潜在问题并加以改进。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值