-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
803 lines (663 loc) · 41 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
<!DOCTYPE html>
<html>
<head><meta name="generator" content="Hexo 3.8.0">
<meta charset="utf-8">
<title>Notebook</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta property="og:type" content="website">
<meta property="og:title" content="Notebook">
<meta property="og:url" content="http://DoloresHe.github.io/index.html">
<meta property="og:site_name" content="Notebook">
<meta property="og:locale" content="default">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Notebook">
<link rel="alternate" href="/atom.xml" title="Notebook" type="application/atom+xml">
<link rel="icon" href="/favicon.png">
<link href="//fonts.googleapis.com/css?family=Source+Code+Pro" rel="stylesheet" type="text/css">
<link rel="stylesheet" href="/css/style.css">
</head>
</html>
<body>
<div id="container">
<div id="wrap">
<header id="header">
<div id="banner"></div>
<div id="header-outer" class="outer">
<div id="header-title" class="inner">
<h1 id="logo-wrap">
<a href="/" id="logo">Notebook</a>
</h1>
</div>
<div id="header-inner" class="inner">
<nav id="main-nav">
<a id="main-nav-toggle" class="nav-icon"></a>
<a class="main-nav-link" href="/">Home</a>
<a class="main-nav-link" href="/archives">Archives</a>
</nav>
<nav id="sub-nav">
<a id="nav-rss-link" class="nav-icon" href="/atom.xml" title="RSS Feed"></a>
<a id="nav-search-btn" class="nav-icon" title="Search"></a>
</nav>
<div id="search-form-wrap">
<form action="//google.com/search" method="get" accept-charset="UTF-8" class="search-form"><input type="search" name="q" class="search-form-input" placeholder="Search"><button type="submit" class="search-form-submit"></button><input type="hidden" name="sitesearch" value="http://DoloresHe.github.io"></form>
</div>
</div>
</div>
</header>
<div class="outer">
<section id="main">
<article id="post-unix_shell" class="article article-type-post" itemscope="" itemprop="blogPost">
<div class="article-meta">
<a href="/2019/01/31/unix_shell/" class="article-date">
<time datetime="2019-01-31T07:51:26.813Z" itemprop="datePublished">2019-01-31</time>
</a>
</div>
<div class="article-inner">
<header class="article-header">
<h1 itemprop="name">
<a class="article-title" href="/2019/01/31/unix_shell/">Unix shell 命令</a>
</h1>
</header>
<div class="article-entry" itemprop="articleBody">
<h3 id="第一章"><a href="#第一章" class="headerlink" title="第一章"></a>第一章</h3><p>列出目录下所有文件<br><code>$ ls</code><br>-l 获取文件的所有信息</p>
<p>查看联机手册<br><code>$ man l ls</code></p>
<p>编译c语言源文件<br><code>$ cc myls.c</code></p>
<p>获取时间<br><code>$ date</code></p>
<p>目前有那些用户登入系统<br><code>$ who</code></p>
<p>当前所处的目录(print working directory)<br><code>$ pwd</code></p>
<p>测量一个_命令_的运行时间<br><code>$ time</code></p>
<p>文件结束符<br><code>$ ^D</code></p>
<h3 id="第二章"><a href="#第二章" class="headerlink" title="第二章"></a>第二章</h3><p><strong>格式化文本信息</strong><br><code>$ awk</code></p>
<h3 id="第三章"><a href="#第三章" class="headerlink" title="第三章"></a>第三章</h3><p>用于连接文件并打印到标准输出设备上。<br><code>$ cat</code></p>
<p>观察实质内容<br><code>$ od</code></p>
<p>查看文件所占磁盘块大小命令<br><code>$ du</code></p>
<h3 id="第四章"><a href="#第四章" class="headerlink" title="第四章"></a>第四章</h3><p>查看屏蔽字,指定当前用户在新建文件和目录时的默认权限<br><code>$ umask</code></p>
<p>变更文件或目录的权限 change mod(mod不知道是否为简写)改变文件权限<br><code>$ chmod</code></p>
<p>改变文件或者目录的所有者 change own改变所有者<br><code>$ chown</code></p>
<p>成为超级用户<br><code>$ su</code></p>
</div>
<footer class="article-footer">
<a data-url="http://DoloresHe.github.io/2019/01/31/unix_shell/" data-id="cjrkbxlvq0003nctkq36pqkhz" class="article-share-link">Share</a>
</footer>
</div>
</article>
<article id="post-linux" class="article article-type-post" itemscope="" itemprop="blogPost">
<div class="article-meta">
<a href="/2019/01/30/linux/" class="article-date">
<time datetime="2019-01-30T07:35:24.682Z" itemprop="datePublished">2019-01-30</time>
</a>
</div>
<div class="article-inner">
<header class="article-header">
<h1 itemprop="name">
<a class="article-title" href="/2019/01/30/linux/">Unix</a>
</h1>
</header>
<div class="article-entry" itemprop="articleBody">
<h2 id="unix高级编程-笔记"><a href="#unix高级编程-笔记" class="headerlink" title="unix高级编程 笔记"></a>unix高级编程 笔记</h2><h3 id="第一章"><a href="#第一章" class="headerlink" title="第一章"></a>第一章</h3><p>对unix基本概念和术语的介绍</p>
<hr>
<p>代码部分还需多加实践</p>
<p>标准输入,标准输出和标准错误 重定向</p>
<p>强调代码中出错处理</p>
<p>系统调用和库函数的区别<br>系统调用:系统(unix)提供的调用内核的接口<br>库函数:编程语言/编译器中,使用系统调用的函数</p>
<p>习题中关于perror和strerror(对于c语言的不熟悉)</p>
<h3 id="第二章"><a href="#第二章" class="headerlink" title="第二章"></a>第二章</h3><p>unix标准和实现</p>
<hr>
<p>标准:unix编程标准 接口规范<br>实现:具体的函数接口</p>
<p>有很多的不同的unix系统,但是unix编程需要统一的标准和实现 可移植性</p>
<p><strong>awk命令</strong></p>
<p>编译时限制<br>运行时限制<br>(数,极限数,边界数)<br><a href="http://www.cppblog.com/Onway/archive/2012/03/26/169063.html" target="_blank" rel="noopener">http://www.cppblog.com/Onway/archive/2012/03/26/169063.html</a></p>
<p>选项<br>是否支持某项功能</p>
<p>功能测试宏<br>定义头文件版本</p>
<h3 id="第三章"><a href="#第三章" class="headerlink" title="第三章"></a>第三章</h3><p>文件io函数</p>
<hr>
<p>文件描述符</p>
<p>int openat(int dirfd, const char *pathname, int flags, mode_t mode);<br>函数openat的第一个参数是目录的文件描述符</p>
<p>文件偏移量</p>
<p>有空洞的文件(类似于bug吗)<br>文件空洞不占用任何磁盘空间<br><a href="https://blog.csdn.net/clamercoder/article/details/38361815" target="_blank" rel="noopener">https://blog.csdn.net/clamercoder/article/details/38361815</a></p>
<p>预读<br>数据结构:B及<em>B+树</em>(普遍运用在<strong>数据库</strong>和<strong>文件系统</strong>。)<br>(vs 红黑树 )</p>
<p>B树,B+树,红黑树的比较<br><a href="https://blog.csdn.net/qq_36183935/article/details/81095212" target="_blank" rel="noopener">https://blog.csdn.net/qq_36183935/article/details/81095212</a></p>
<p>进程表-文件表-v节点</p>
<p>避免文件操作冲突:原子操作</p>
<p>buffered and unbuffered</p>
<p>ext4文件系统(关于文件系统)</p>
<h3 id="第四章"><a href="#第四章" class="headerlink" title="第四章"></a>第四章</h3><p>文件属性</p>
<hr>
<p>文件类型:普通文件,目录文件,块特殊文件,字符特殊文件,FIFO,套接字(socket),符号链接</p>
<p>lstat和stat函数 检测符号链接</p>
<p>访问权限<br>删除/创建:对所在目录有写和执行权限</p>
<p>执行权限S <strong>强制位</strong><br><strong>设置使文件在执行阶段具有文件所有者的权限,相当于临时拥有文件所有者的身份</strong></p>
<p>黏着位<br>使一个目录既能够让任何用户写入文档,又不让用户删除这个目录下他人的文档,t权限就是能起到这个作用。t权限一般只用在目录上,用在文档上起不到什么作用。</p>
</div>
<footer class="article-footer">
<a data-url="http://DoloresHe.github.io/2019/01/30/linux/" data-id="cjrkbxlvo0002nctki5wqa9jk" class="article-share-link">Share</a>
</footer>
</div>
</article>
<article id="post-git" class="article article-type-post" itemscope="" itemprop="blogPost">
<div class="article-meta">
<a href="/2018/12/21/git/" class="article-date">
<time datetime="2018-12-21T14:09:42.000Z" itemprop="datePublished">2018-12-21</time>
</a>
</div>
<div class="article-inner">
<header class="article-header">
<h1 itemprop="name">
<a class="article-title" href="/2018/12/21/git/">git</a>
</h1>
</header>
<div class="article-entry" itemprop="articleBody">
<h2 id="版本控制"><a href="#版本控制" class="headerlink" title="版本控制"></a>版本控制</h2><p>分布式版本控制系统</p>
<p><img src="https://git-scm.com/book/en/v2/images/snapshots.png" alt="Git "></p>
<p>本地操作</p>
<p>存储前校验</p>
<h3 id="git的三种状态"><a href="#git的三种状态" class="headerlink" title="git的三种状态"></a>git的三种状态</h3><ul>
<li>已提交(committed)</li>
<li>已修改(modified)</li>
<li>已暂存(staged)<br><br><br><img src="https://git-scm.com/book/en/v2/images/areas.png" alt="工作目录、暂存区域以及 Git 仓库."></li>
</ul>
<p><br><br>基本的 Git 工作流程如下:<br></p>
<ol>
<li>在工作目录中修改文件。<br></li>
<li>暂存文件,将文件的快照放入暂存区域。<br></li>
<li>提交更新,找到暂存区域的文件,将快照永久性存储到 Git 仓库目录。<br><br></li>
</ol>
<h2 id="命令行操作"><a href="#命令行操作" class="headerlink" title="命令行操作"></a>命令行操作</h2><h3 id="配置git环境"><a href="#配置git环境" class="headerlink" title="配置git环境"></a>配置git环境</h3><ul>
<li>git config<br>检查配置信息<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">git config --list</span><br></pre></td></tr></table></figure>
</li>
</ul>
<p><br></p>
<ul>
<li><p>用户信息配置</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">$ git config --global user.name "John Doe"</span><br><span class="line">$ git config --global user.email johndoe@example.com</span><br></pre></td></tr></table></figure>
</li>
<li><p>help</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">git help -a</span><br></pre></td></tr></table></figure>
</li>
</ul>
<h2 id="git基础学习"><a href="#git基础学习" class="headerlink" title="git基础学习"></a>git基础学习</h2><h3 id="获取git仓库"><a href="#获取git仓库" class="headerlink" title="获取git仓库"></a>获取git仓库</h3><ul>
<li><p>新建</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">git init</span><br><span class="line">git add *</span><br><span class="line">git commit -m 'xxx'</span><br></pre></td></tr></table></figure>
</li>
<li><p>克隆</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">git clone [url]</span><br></pre></td></tr></table></figure>
</li>
</ul>
<h3 id="更新"><a href="#更新" class="headerlink" title="更新"></a>更新</h3><h4 id="查看当前文件状态"><a href="#查看当前文件状态" class="headerlink" title="查看当前文件状态"></a>查看当前文件状态</h4><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">git status</span><br></pre></td></tr></table></figure>
<h4 id="跟踪新文件"><a href="#跟踪新文件" class="headerlink" title="跟踪新文件"></a>跟踪新文件</h4><p>添加内容到下一次提交中<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">git add</span><br></pre></td></tr></table></figure></p>
<h4 id="暂存已修改文件"><a href="#暂存已修改文件" class="headerlink" title="暂存已修改文件"></a>暂存已修改文件</h4><p>修改已被跟踪未提交的文件<br>如果提交,<font color="#dd0000"><strong>提交版本为最后一次add的版本</strong></font></p>
<h4 id="状态简览"><a href="#状态简览" class="headerlink" title="状态简览"></a>状态简览</h4><ul>
<li>新添加的未跟踪文件前面有 <code>??</code> 标记</li>
<li>新添加到暂存区中的文件前面有 <code>A</code> 标记</li>
<li>修改过的文件前面有 <code>M</code> 标记</li>
</ul>
<h4 id="忽略文件"><a href="#忽略文件" class="headerlink" title="忽略文件"></a>忽略文件</h4><p>创建一个名为 <code>.gitignore</code> 的文件,列出要忽略的文件模式。</p>
<h4 id="查看已暂存和未暂存的修改"><a href="#查看已暂存和未暂存的修改" class="headerlink" title="查看已暂存和未暂存的修改"></a>查看已暂存和未暂存的修改</h4><p>要查看尚未暂存的文件更新了哪些部分<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">git diff</span><br></pre></td></tr></table></figure></p>
<p>查看已暂存的将要添加到下次提交里的内容更新了哪些部分<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">git diff --staged</span><br></pre></td></tr></table></figure></p>
<h4 id="提交更新"><a href="#提交更新" class="headerlink" title="提交更新"></a>提交更新</h4><p>每次准备提交前,<strong>先用 <code>git status</code> 看下</strong>,是不是都已暂存起来了, 然后再运行提交命令 <code>git commit</code><br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">git commit -m "XXX"</span><br></pre></td></tr></table></figure></p>
<h4 id="跳过使用暂存区域"><a href="#跳过使用暂存区域" class="headerlink" title="跳过使用暂存区域"></a>跳过使用暂存区域</h4><p><code>git commit -a</code></p>
<h4 id="移除文件"><a href="#移除文件" class="headerlink" title="移除文件"></a>移除文件</h4><ul>
<li><p>从已跟踪文件清单中移除(确切地说,是从暂存区域移除),然后提交<br><code>git rm</code></p>
</li>
<li><p>删除之前修改过并且已经放到暂存区域的文件<br><code>git rm -f</code></p>
</li>
<li><p>把文件从 Git 仓库中删除(亦即从暂存区域移除),但仍然希望保留在当前工作目录中<br><code>console git rm --cached</code></p>
</li>
</ul>
<h4 id="移动文件"><a href="#移动文件" class="headerlink" title="移动文件"></a>移动文件</h4><p>重命名<br><code>git mv (filename1) (filename2)</code></p>
<h3 id="查看提交历史"><a href="#查看提交历史" class="headerlink" title="查看提交历史"></a>查看提交历史</h3><p><code>git log</code><br>参数:</p>
<ul>
<li>-2 仅显示最近两次提交</li>
<li>-p 用来显示每次提交的内容差异</li>
<li>-stat 在每次提交的下面列出所有被修改过的文件、有多少文件被修改了以及被修改过的文件的哪些行被移除或是添加</li>
<li>-pretty 指定使用不同于默认格式的方式展示提交历史</li>
<li>-format 定制要显示的记录格式</li>
</ul>
<figure class="highlight console"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">git log --pretty=format:"%h - %an, %ar : %s"</span><br><span class="line">console</span><br><span class="line">git log --pretty=oneline</span><br></pre></td></tr></table></figure>
<p>更多参数请查看<a href="https://git-scm.com/book/zh/v2/Git-%E5%9F%BA%E7%A1%80-%E6%9F%A5%E7%9C%8B%E6%8F%90%E4%BA%A4%E5%8E%86%E5%8F%B2" target="_blank" rel="noopener">git文档</a></p>
<h3 id="撤销操作"><a href="#撤销操作" class="headerlink" title="撤销操作"></a>撤销操作</h3><p>重新提交<br><code>git commit -amend</code></p>
<p>取消暂存的文件<br><code>git reset HEAD <file>...</code></p>
<p>撤销对文件的修改<br><code>git checkout -- <file></code></p>
<h3 id="远程仓库的使用"><a href="#远程仓库的使用" class="headerlink" title="远程仓库的使用"></a>远程仓库的使用</h3><ul>
<li><p>查看<br><code>git remote</code></p>
</li>
<li><p>添加<br><code>git remote add <shortname> <url></code></p>
</li>
<li><p>从远程仓库中抓取与拉取<br><code>git fetch [remote-name]</code></p>
</li>
<li><p>推送到远程仓库<br><code>git push [remote-name] [branch-name]</code></p>
</li>
<li><p>查看远程仓库<br><code>git remote show [remote-name]</code></p>
</li>
<li><p>远程仓库的移除与重命名<br>移除<br><code>git remote rm</code></p>
</li>
</ul>
<p>重命名<br><code>git remote rename</code></p>
<h3 id="打标签"><a href="#打标签" class="headerlink" title="打标签"></a>打标签</h3><ul>
<li><p>列出标签<br><code>git tag</code></p>
<ul>
<li>创建标签<br>附注标签<br><code>git tag -a v1.4 -m 'my version 1.4'</code></li>
</ul>
</li>
</ul>
<p>轻量标签<br> <code>git tag v1.4-lw</code></p>
<h3 id="git别名"><a href="#git别名" class="headerlink" title="git别名"></a>git别名</h3><p>参考<br><figure class="highlight console"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">$</span> git config --global alias.co checkout</span><br><span class="line"><span class="meta">$</span> git config --global alias.br branch</span><br><span class="line"><span class="meta">$</span> git config --global alias.ci commit</span><br><span class="line"><span class="meta">$</span> git config --global alias.st status</span><br></pre></td></tr></table></figure></p>
</div>
<footer class="article-footer">
<a data-url="http://DoloresHe.github.io/2018/12/21/git/" data-id="cjrkbxlvd0000nctka863rmnn" class="article-share-link">Share</a>
</footer>
</div>
</article>
<article id="post-vim" class="article article-type-post" itemscope="" itemprop="blogPost">
<div class="article-meta">
<a href="/2018/12/19/vim/" class="article-date">
<time datetime="2018-12-19T01:19:23.367Z" itemprop="datePublished">2018-12-19</time>
</a>
</div>
<div class="article-inner">
<header class="article-header">
<h1 itemprop="name">
<a class="article-title" href="/2018/12/19/vim/">Vim</a>
</h1>
</header>
<div class="article-entry" itemprop="articleBody">
<h1 id="vim"><a href="#vim" class="headerlink" title="vim"></a>vim</h1><p>关于vim的详细的指令自学手册<br>参考教程见最后链接</p>
<h2 id="基本模式"><a href="#基本模式" class="headerlink" title="基本模式"></a>基本模式</h2><p>Vim具有6种基本模式和5种派生模式,我们这里只简单介绍下6种基本模式:</p>
<h3 id="普通模式-Normal-mode"><a href="#普通模式-Normal-mode" class="headerlink" title="普通模式(Normal mode)"></a>普通模式(Normal mode)</h3><p>在普通模式中,用的编辑器命令,比如移动光标,删除文本等等。这也是Vim启动后的默认模式。这正好和许多新用户期待的操作方式相反(大多数编辑器默认模式为插入模式)。</p>
<h3 id="插入模式-Insert-mode"><a href="#插入模式-Insert-mode" class="headerlink" title="插入模式(Insert mode)"></a>插入模式(Insert mode)</h3><p>在这个模式中,大多数按键都会向文本缓冲中插入文本。大多数新用户希望文本编辑器编辑过程中一直保持这个模式。<br>在插入模式中,可以按ESC键回到普通模式。</p>
<h3 id="可视模式-Visual-mode"><a href="#可视模式-Visual-mode" class="headerlink" title="可视模式(Visual mode)"></a>可视模式(Visual mode)</h3><p>这个模式与普通模式比较相似。但是移动命令会扩大高亮的文本区域。高亮区域可以是字符、行或者是一块文本。当执行一个非移动命令时,命令会被执行到这块高亮的区域上。Vim的”文本对象”也能和移动命令一样用在这个模式中。</p>
<h3 id="选择模式-Select-mode"><a href="#选择模式-Select-mode" class="headerlink" title="选择模式(Select mode)"></a>选择模式(Select mode)</h3><p>这个模式和无模式编辑器的行为比较相似(Windows标准文本控件的方式)。这个模式中,可以用鼠标或者光标键高亮选择文本,不过输入任何字符的话,Vim会用这个字符替换选择的高亮文本块,并且自动进入插入模式。</p>
<h3 id="命令行模式-Command-line-mode"><a href="#命令行模式-Command-line-mode" class="headerlink" title="命令行模式(Command line mode)"></a>命令行模式(Command line mode)</h3><p>在命令行模式中可以输入会被解释成并执行的文本。例如执行命令(:键),搜索(/和?键)或者过滤命令(!键)。在命令执行之后,Vim返回到命令行模式之前的模式,通常是普通模式。</p>
<h3 id="Ex模式-Ex-mode"><a href="#Ex模式-Ex-mode" class="headerlink" title="Ex模式(Ex mode)"></a>Ex模式(Ex mode)</h3><p>这和命令行模式比较相似,在使用:visual命令离开Ex模式前,可以一次执行多条命令。</p>
<p>这其中我们常用到就是普通模式、插入模式和命令行模式,本课程也只涉及这三个常用模式的内容</p>
<h2 id="游标移动"><a href="#游标移动" class="headerlink" title="游标移动"></a>游标移动</h2><table>
<thead>
<tr>
<th>按键</th>
<th>说明</th>
</tr>
</thead>
<tbody>
<tr>
<td>h</td>
<td>左</td>
</tr>
<tr>
<td>l</td>
<td>右(小写L)</td>
</tr>
<tr>
<td>j</td>
<td>下</td>
</tr>
<tr>
<td>k</td>
<td>上</td>
</tr>
<tr>
<td>w</td>
<td>移动到下一个单词</td>
</tr>
<tr>
<td>b</td>
<td>移动到上一个单词</td>
</tr>
</tbody>
</table>
<hr>
<h2 id="进入插入模式"><a href="#进入插入模式" class="headerlink" title="进入插入模式"></a>进入插入模式</h2><p>在普通模式下使用下面的键将进入插入模式,并可以从相应的位置开始输入</p>
<table>
<thead>
<tr>
<th>命令</th>
<th>说明</th>
</tr>
</thead>
<tbody>
<tr>
<td>i</td>
<td>在当前光标处进行编辑</td>
</tr>
<tr>
<td>I</td>
<td>在行首插入</td>
</tr>
<tr>
<td>A</td>
<td>在行末插入</td>
</tr>
<tr>
<td>a</td>
<td>在光标后插入编辑</td>
</tr>
<tr>
<td>o</td>
<td>在当前行后插入一个新行</td>
</tr>
<tr>
<td>O</td>
<td>在当前行前插入一个新行</td>
</tr>
<tr>
<td>cw</td>
<td>替换从光标所在位置后到一个单词结尾的字符</td>
</tr>
</tbody>
</table>
<hr>
<h2 id="退出vim的几个方式"><a href="#退出vim的几个方式" class="headerlink" title="退出vim的几个方式"></a>退出vim的几个方式</h2><table>
<thead>
<tr>
<th>命令</th>
<th>说明</th>
</tr>
</thead>
<tbody>
<tr>
<td>:q!</td>
<td>强制退出,不保存</td>
</tr>
<tr>
<td>:q</td>
<td>退出</td>
</tr>
<tr>
<td>:wq!</td>
<td>强制保存并退出</td>
</tr>
<tr>
<td>:w <文件路径></td>
<td>另存为</td>
</tr>
<tr>
<td>:saveas 文件路径</td>
<td>另存为</td>
</tr>
<tr>
<td>:x</td>
<td>保存并退出</td>
</tr>
<tr>
<td>:wq</td>
<td>保存并退出</td>
</tr>
</tbody>
</table>
<p>普通模式下输入Shift+zz即可保存退出vim</p>
<h2 id="删除操作"><a href="#删除操作" class="headerlink" title="删除操作"></a>删除操作</h2><table>
<thead>
<tr>
<th>命令</th>
<th>说明</th>
</tr>
</thead>
<tbody>
<tr>
<td>x</td>
<td>删除游标所在的字符</td>
</tr>
<tr>
<td>X</td>
<td>删除游标所在前一个字符</td>
</tr>
<tr>
<td>Delete</td>
<td>同x</td>
</tr>
<tr>
<td>dd</td>
<td>删除整行</td>
</tr>
<tr>
<td>dw</td>
<td>删除一个单词(不适用中文)</td>
</tr>
<tr>
<td>d$或D</td>
<td>删除至行尾</td>
</tr>
<tr>
<td>d^</td>
<td>删除至行首</td>
</tr>
<tr>
<td>dG</td>
<td>删除到文档结尾处</td>
</tr>
<tr>
<td>d1G</td>
<td>删至文档首部</td>
</tr>
</tbody>
</table>
<p>除此之外,你还可以在命令之前加上数字,表示一次删除多行,如:<br>2dd表示一次删除2行</p>
<h2 id="重复命令"><a href="#重复命令" class="headerlink" title="重复命令"></a>重复命令</h2><h3 id="重复上一次命令"><a href="#重复上一次命令" class="headerlink" title="重复上一次命令"></a>重复上一次命令</h3><p>.(小数点)</p>
<h3 id="执行指定次数"><a href="#执行指定次数" class="headerlink" title="执行指定次数"></a>执行指定次数</h3><p>N <command></p>
<h2 id="游标快速跳转"><a href="#游标快速跳转" class="headerlink" title="游标快速跳转"></a>游标快速跳转</h2><h3 id="行间跳转"><a href="#行间跳转" class="headerlink" title="行间跳转"></a>行间跳转</h3><table>
<thead>
<tr>
<th>命令</th>
<th>说明</th>
</tr>
</thead>
<tbody>
<tr>
<td>nG(n Shift+g)</td>
<td>游标移动到第 n 行(如果默认没有显示行号,请先进入命令模式,输入:set nu以显示行号)</td>
</tr>
<tr>
<td>gg</td>
<td>游标移动到到第一行</td>
</tr>
<tr>
<td>G(Shift+g)</td>
<td>到最后一行</td>
</tr>
</tbody>
</table>
<p>可以使用 Ctrl+o 快速回到上一次(跳转前)光标所在位置</p>
<h3 id="行内跳转"><a href="#行内跳转" class="headerlink" title="行内跳转"></a>行内跳转</h3><p>普通模式下使用下列命令在行内按照单词为单位进行跳转</p>
<table>
<thead>
<tr>
<th>命令</th>
<th>说明</th>
</tr>
</thead>
<tbody>
<tr>
<td>w</td>
<td>到下一个单词的开头</td>
</tr>
<tr>
<td>e</td>
<td>到当前单词的结尾</td>
</tr>
<tr>
<td>b</td>
<td>到前一个单词的开头</td>
</tr>
<tr>
<td>ge</td>
<td>到前一个单词的结尾</td>
</tr>
<tr>
<td>0或^</td>
<td>到行头</td>
</tr>
<tr>
<td>$</td>
<td>到行尾</td>
</tr>
<tr>
<td>f<字母></td>
<td>向后搜索<字母>并跳转到第一个匹配的位置(非常实用)</td>
</tr>
<tr>
<td>F<字母></td>
<td>向前搜索<字母>并跳转到第一个匹配的位置</td>
</tr>
<tr>
<td>t<字母></td>
<td>向后搜索<字母>并跳转到第一个匹配位置之前的一个字母(不常用)</td>
</tr>
<tr>
<td>T<字母></td>
<td>向前搜索<字母>并跳转到第一个匹配位置之后的一个字母(不常用)</td>
</tr>
</tbody>
</table>
<h2 id="复制粘贴"><a href="#复制粘贴" class="headerlink" title="复制粘贴"></a>复制粘贴</h2><h3 id="复制"><a href="#复制" class="headerlink" title="复制"></a>复制</h3><p>普通模式中使用y复制</p>
<p>普通模式中,yy复制游标所在的整行(3yy表示复制3行)<br>普通模式中,y^ 复制至行首,或y0。不含光标所在处字符。<br>普通模式中,y$ 复制至行尾。含光标所在处字符。<br>普通模式中,yw 复制一个单词。<br>普通模式中,y2w 复制两个单词。<br>普通模式中,yG 复制至文本末。<br>普通模式中,y1G 复制至文本开头。<br>普通模式中使用 p 粘贴</p>
<p>普通模式中,p(小写)代表粘贴至光标后(下)<br>普通模式中,P(大写)代表粘贴至光标前(上)</p>
<h3 id="剪切粘贴"><a href="#剪切粘贴" class="headerlink" title="剪切粘贴"></a>剪切粘贴</h3><p>ddp</p>
<h2 id="字符的替换及撤销-Undo操作"><a href="#字符的替换及撤销-Undo操作" class="headerlink" title="字符的替换及撤销(Undo操作)"></a>字符的替换及撤销(Undo操作)</h2><h3 id="替换和撤销-Undo-命令"><a href="#替换和撤销-Undo-命令" class="headerlink" title="替换和撤销(Undo)命令"></a>替换和撤销(Undo)命令</h3><p>替换和Undo命令都是针对普通模式下的操作</p>
<table>
<thead>
<tr>
<th>命令</th>
<th>说明</th>
</tr>
</thead>
<tbody>
<tr>
<td>r+<待替换字母></td>
<td>将游标所在字母替换为指定字母</td>
</tr>
<tr>
<td>R</td>
<td>连续替换,直到按下Esc</td>
</tr>
<tr>
<td>cc</td>
<td>替换整行,即删除游标所在行,并进入插入模式</td>
</tr>
<tr>
<td>cw</td>
<td>替换一个单词,即删除一个单词,并进入插入模式</td>
</tr>
<tr>
<td>C(大写)</td>
<td>替换游标以后至行末</td>
</tr>
<tr>
<td>~</td>
<td>反转游标所在字母大小写</td>
</tr>
<tr>
<td>u{n}</td>
<td>撤销一次或n次操作</td>
</tr>
<tr>
<td>U(大写)</td>
<td>撤销当前行的所有修改</td>
</tr>
<tr>
<td>Ctrl+r</td>
<td>redo,即撤销undo的操作</td>
</tr>
</tbody>
</table>
<h2 id="缩进"><a href="#缩进" class="headerlink" title="缩进"></a>缩进</h2><h3 id="快速缩进"><a href="#快速缩进" class="headerlink" title="快速缩进"></a>快速缩进</h3><p>普通模式下输入15G,跳转到15行<br>普通模式下输入>> 整行将向右缩进(使用,用于格式化代码超爽)<br>普通模式下输入<< 整行向左回退<br>普通模式下输入:进入命令行模式下对shiftwidth值进行设置可以控制缩进和回退的字符数<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">:set shiftwidth=10</span><br></pre></td></tr></table></figure></p>
<h3 id="调整文本格式"><a href="#调整文本格式" class="headerlink" title="调整文本格式"></a>调整文本格式</h3><p>命令行模式下输入:ce(center)命令使本行内容居中<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">:ce</span><br></pre></td></tr></table></figure></p>
<p>命令行模式下输入:ri(right)命令使本行文本靠右<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">:ri</span><br></pre></td></tr></table></figure></p>
<p>命令行模式下输入:le(left)命令使本行内容靠左<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">:le</span><br></pre></td></tr></table></figure></p>
<h2 id="查找"><a href="#查找" class="headerlink" title="查找"></a>查找</h2><p>普通模式下输入 / 然后键入需要查找的字符串 按回车后就会进行查找。 ? 与/ 功能相同,只不过 ? 是向上而 / 是向下查找。 进入查找之后,输入n 和 N 可以继续查找。 n是查找下一个内容,N查找上一个内容。</p>
<h2 id="多文件编辑"><a href="#多文件编辑" class="headerlink" title="多文件编辑"></a>多文件编辑</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">vim 1.txt 2.txt</span><br></pre></td></tr></table></figure>
<p>命令行模式下输入 :n 编辑 2.txt 文件,可以加 ! 即 :n! 强制切换,之前一个文件的输入没有保存,仅仅切换到另一个文件<br>命令行模式下输入 :N 编辑 1.txt 文件,可以加 ! 即 :N! 强制切换,之前文件内的输入没有保存,仅仅是切换到另一个文件</p>
<h3 id="进入vim后打开新文件"><a href="#进入vim后打开新文件" class="headerlink" title="进入vim后打开新文件"></a>进入vim后打开新文件</h3><p>命令行模式下输入:e 3.txt 打开新文件3.txt<br>命令行模式下输入:e# 回到前一个文件<br>命令行模式下输入:ls可以列出以前编辑过的文档<br>命令行模式下输入:b 2.txt(或者编号)可以直接进入文件2.txt编辑<br>命令行模式下输入:bd 2.txt(或者编号)可以删除以前编辑过的列表中的文件项目<br>命令行模式下输入:e! 4.txt,新打开文件4.txt,放弃正在编辑的文件<br>命令行模式下输入:f 显示正在编辑的文件名<br>命令行模式下输入:f new.txt,改变正在编辑的文件名字为new.txt</p>
<h2 id="恢复文件"><a href="#恢复文件" class="headerlink" title="恢复文件"></a>恢复文件</h2><p>如果因为断电等原因造成文档没有保存,可以采用恢复方式,vim -r进入文档后,输入:ewcover 1.txt来恢复</p>
<h2 id="可视模式"><a href="#可视模式" class="headerlink" title="可视模式"></a>可视模式</h2><p>在普通模式下输入 v(小写),进入字符选择模式,就可以移动光标,光标走过的地方就会选取。再次按下v后就会取消选取。<br>在普通模式下输入 Shift+v(小写),进入行选择模式,按下V之后就会把整行选取,您可以上下移动光标选更多的行,同样,再按一次 Shift+v 就可以取消选取。<br>在普通模式下输入 Ctrl+v(小写),这是区域选择模式,可以进行矩形区域选择,再按一次 Ctrl+v 取消选取。<br>在可视模式下输入 d 删除选取区域内容<br>在可视模式下输入y复制选取区域内容</p>
<h2 id="视窗操作"><a href="#视窗操作" class="headerlink" title="视窗操作"></a>视窗操作</h2><p>命令行模式下输入:sp 1.txt 打开新的水平分屏视窗来编辑1.txt<br>命令行模式下输入:vsp 2.txt 打开新的垂直分屏视窗来编辑2.txt</p>
<p>普通模式下Ctrl+w s 将当前窗口分割成两个水平的窗口<br>普通模式下Ctrl+w v 将当前窗口分割成两个垂直的窗口<br>普通模式下Ctrl+w q 即 :q 结束分割出来的视窗。如果在新视窗中有输入需要使用强制符!即:q!<br>普通模式下Ctrl+w o 打开一个视窗并且隐藏之前的所有视窗<br>普通模式下Ctrl+w j 移至下面视窗<br>普通模式下Ctrl+w k 移至上面视窗<br>普通模式下Ctrl+w h 移至左边视窗<br>普通模式下Ctrl+w l 移至右边视窗<br>普通模式下Ctrl+w J 将当前视窗移至下面<br>普通模式下Ctrl+w K 将当前视窗移至上面<br>普通模式下Ctrl+w H 将当前视窗移至左边<br>普通模式下Ctrl+w L 将当前视窗移至右边<br>普通模式下Ctrl+w - 减小视窗的高度<br>普通模式下Ctrl+w + 增加视窗的高度</p>
<h2 id="文档加密"><a href="#文档加密" class="headerlink" title="文档加密"></a>文档加密</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">vim -x file1</span><br></pre></td></tr></table></figure>
<h2 id="执行外部命令"><a href="#执行外部命令" class="headerlink" title="执行外部命令"></a>执行外部命令</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">:!</span><br></pre></td></tr></table></figure>
<h2 id="帮助系统"><a href="#帮助系统" class="headerlink" title="帮助系统"></a>帮助系统</h2><p>F1</p>
<h2 id="功能设定"><a href="#功能设定" class="headerlink" title="功能设定"></a>功能设定</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">set nu(设定行数)</span><br></pre></td></tr></table></figure>
<p>参考:<a href="https://www.shiyanlou.com/courses/2" target="_blank" rel="noopener">实验楼 vim编辑器</a></p>
</div>
<footer class="article-footer">
<a data-url="http://DoloresHe.github.io/2018/12/19/vim/" data-id="cjrkbxlvr0004nctk0jdzzb4u" class="article-share-link">Share</a>
</footer>
</div>
</article>
<article id="post-hello-world" class="article article-type-post" itemscope="" itemprop="blogPost">
<div class="article-meta">
<a href="/2018/12/19/hello-world/" class="article-date">
<time datetime="2018-12-19T01:10:21.492Z" itemprop="datePublished">2018-12-19</time>
</a>
</div>
<div class="article-inner">
<header class="article-header">
<h1 itemprop="name">
<a class="article-title" href="/2018/12/19/hello-world/">Hello World</a>
</h1>
</header>
<div class="article-entry" itemprop="articleBody">
<p>Welcome to <a href="https://hexo.io/" target="_blank" rel="noopener">Hexo</a>! This is your very first post. Check <a href="https://hexo.io/docs/" target="_blank" rel="noopener">documentation</a> for more info. If you get any problems when using Hexo, you can find the answer in <a href="https://hexo.io/docs/troubleshooting.html" target="_blank" rel="noopener">troubleshooting</a> or you can ask me on <a href="https://github.com/hexojs/hexo/issues" target="_blank" rel="noopener">GitHub</a>.</p>
<h2 id="Quick-Start"><a href="#Quick-Start" class="headerlink" title="Quick Start"></a>Quick Start</h2><h3 id="Create-a-new-post"><a href="#Create-a-new-post" class="headerlink" title="Create a new post"></a>Create a new post</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ hexo new <span class="string">"My New Post"</span></span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/writing.html" target="_blank" rel="noopener">Writing</a></p>
<h3 id="Run-server"><a href="#Run-server" class="headerlink" title="Run server"></a>Run server</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ hexo server</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/server.html" target="_blank" rel="noopener">Server</a></p>
<h3 id="Generate-static-files"><a href="#Generate-static-files" class="headerlink" title="Generate static files"></a>Generate static files</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ hexo generate</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/generating.html" target="_blank" rel="noopener">Generating</a></p>
<h3 id="Deploy-to-remote-sites"><a href="#Deploy-to-remote-sites" class="headerlink" title="Deploy to remote sites"></a>Deploy to remote sites</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ hexo deploy</span><br></pre></td></tr></table></figure>
<p>More info: <a href="https://hexo.io/docs/deployment.html" target="_blank" rel="noopener">Deployment</a></p>
</div>
<footer class="article-footer">
<a data-url="http://DoloresHe.github.io/2018/12/19/hello-world/" data-id="cjrkbxlvm0001nctkk9l7rivb" class="article-share-link">Share</a>
</footer>
</div>
</article>
</section>
<aside id="sidebar">
<div class="widget-wrap">
<h3 class="widget-title">Archives</h3>
<div class="widget">
<ul class="archive-list"><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/01/">January 2019</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2018/12/">December 2018</a></li></ul>
</div>
</div>
<div class="widget-wrap">
<h3 class="widget-title">Recent Posts</h3>
<div class="widget">
<ul>
<li>
<a href="/2019/01/31/unix_shell/">Unix shell 命令</a>
</li>
<li>
<a href="/2019/01/30/linux/">Unix</a>
</li>
<li>
<a href="/2018/12/21/git/">git</a>
</li>
<li>
<a href="/2018/12/19/vim/">Vim</a>
</li>
<li>
<a href="/2018/12/19/hello-world/">Hello World</a>
</li>
</ul>
</div>
</div>
</aside>
</div>
<footer id="footer">
<div class="outer">
<div id="footer-info" class="inner">
© 2019 John Doe<br>
Powered by <a href="http://hexo.io/" target="_blank">Hexo</a>
</div>
</div>
</footer>
</div>
<nav id="mobile-nav">
<a href="/" class="mobile-nav-link">Home</a>
<a href="/archives" class="mobile-nav-link">Archives</a>
</nav>
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<link rel="stylesheet" href="/fancybox/jquery.fancybox.css">
<script src="/fancybox/jquery.fancybox.pack.js"></script>
<script src="/js/script.js"></script>
</div>
</body>
</html>