vim

作者: akemin | 来源:发表于2018-09-20 18:12 被阅读0次

<?xml version="1.0" encoding="utf-8"?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">

<head>

<!-- 2018-09-20 Thu 11:01 -->

<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />

<meta name="viewport" content="width=device-width, initial-scale=1" />

<title>&lrm;</title>

<meta name="generator" content="Org mode" />

<style type="text/css">

<!--/*--><![CDATA[/*><!--*/

  .title  { text-align: center;

            margin-bottom: .2em; }

  .subtitle { text-align: center;

              font-size: medium;

              font-weight: bold;

              margin-top:0; }

  .todo  { font-family: monospace; color: red; }

  .done  { font-family: monospace; color: green; }

  .priority { font-family: monospace; color: orange; }

  .tag    { background-color: #eee; font-family: monospace;

            padding: 2px; font-size: 80%; font-weight: normal; }

  .timestamp { color: #bebebe; }

  .timestamp-kwd { color: #5f9ea0; }

  .org-right  { margin-left: auto; margin-right: 0px;  text-align: right; }

  .org-left  { margin-left: 0px;  margin-right: auto; text-align: left; }

  .org-center { margin-left: auto; margin-right: auto; text-align: center; }

  .underline { text-decoration: underline; }

  #postamble p, #preamble p { font-size: 90%; margin: .2em; }

  p.verse { margin-left: 3%; }

  pre {

    border: 1px solid #ccc;

    box-shadow: 3px 3px 3px #eee;

    padding: 8pt;

    font-family: monospace;

    overflow: auto;

    margin: 1.2em;

  }

  pre.src {

    position: relative;

    overflow: visible;

    padding-top: 1.2em;

  }

  pre.src:before {

    display: none;

    position: absolute;

    background-color: white;

    top: -10px;

    right: 10px;

    padding: 3px;

    border: 1px solid black;

  }

  pre.src:hover:before { display: inline;}

  /* Languages per Org manual */

  pre.src-asymptote:before { content: 'Asymptote'; }

  pre.src-awk:before { content: 'Awk'; }

  pre.src-C:before { content: 'C'; }

  /* pre.src-C++ doesn't work in CSS */

  pre.src-clojure:before { content: 'Clojure'; }

  pre.src-css:before { content: 'CSS'; }

  pre.src-D:before { content: 'D'; }

  pre.src-ditaa:before { content: 'ditaa'; }

  pre.src-dot:before { content: 'Graphviz'; }

  pre.src-calc:before { content: 'Emacs Calc'; }

  pre.src-emacs-lisp:before { content: 'Emacs Lisp'; }

  pre.src-fortran:before { content: 'Fortran'; }

  pre.src-gnuplot:before { content: 'gnuplot'; }

  pre.src-haskell:before { content: 'Haskell'; }

  pre.src-hledger:before { content: 'hledger'; }

  pre.src-java:before { content: 'Java'; }

  pre.src-js:before { content: 'Javascript'; }

  pre.src-latex:before { content: 'LaTeX'; }

  pre.src-ledger:before { content: 'Ledger'; }

  pre.src-lisp:before { content: 'Lisp'; }

  pre.src-lilypond:before { content: 'Lilypond'; }

  pre.src-lua:before { content: 'Lua'; }

  pre.src-matlab:before { content: 'MATLAB'; }

  pre.src-mscgen:before { content: 'Mscgen'; }

  pre.src-ocaml:before { content: 'Objective Caml'; }

  pre.src-octave:before { content: 'Octave'; }

  pre.src-org:before { content: 'Org mode'; }

  pre.src-oz:before { content: 'OZ'; }

  pre.src-plantuml:before { content: 'Plantuml'; }

  pre.src-processing:before { content: 'Processing.js'; }

  pre.src-python:before { content: 'Python'; }

  pre.src-R:before { content: 'R'; }

  pre.src-ruby:before { content: 'Ruby'; }

  pre.src-sass:before { content: 'Sass'; }

  pre.src-scheme:before { content: 'Scheme'; }

  pre.src-screen:before { content: 'Gnu Screen'; }

  pre.src-sed:before { content: 'Sed'; }

  pre.src-sh:before { content: 'shell'; }

  pre.src-sql:before { content: 'SQL'; }

  pre.src-sqlite:before { content: 'SQLite'; }

  /* additional languages in org.el's org-babel-load-languages alist */

  pre.src-forth:before { content: 'Forth'; }

  pre.src-io:before { content: 'IO'; }

  pre.src-J:before { content: 'J'; }

  pre.src-makefile:before { content: 'Makefile'; }

  pre.src-maxima:before { content: 'Maxima'; }

  pre.src-perl:before { content: 'Perl'; }

  pre.src-picolisp:before { content: 'Pico Lisp'; }

  pre.src-scala:before { content: 'Scala'; }

  pre.src-shell:before { content: 'Shell Script'; }

  pre.src-ebnf2ps:before { content: 'ebfn2ps'; }

  /* additional language identifiers per "defun org-babel-execute"

      in ob-*.el */

  pre.src-cpp:before  { content: 'C++'; }

  pre.src-abc:before  { content: 'ABC'; }

  pre.src-coq:before  { content: 'Coq'; }

  pre.src-groovy:before  { content: 'Groovy'; }

  /* additional language identifiers from org-babel-shell-names in

    ob-shell.el: ob-shell is the only babel language using a lambda to put

    the execution function name together. */

  pre.src-bash:before  { content: 'bash'; }

  pre.src-csh:before  { content: 'csh'; }

  pre.src-ash:before  { content: 'ash'; }

  pre.src-dash:before  { content: 'dash'; }

  pre.src-ksh:before  { content: 'ksh'; }

  pre.src-mksh:before  { content: 'mksh'; }

  pre.src-posh:before  { content: 'posh'; }

  /* Additional Emacs modes also supported by the LaTeX listings package */

  pre.src-ada:before { content: 'Ada'; }

  pre.src-asm:before { content: 'Assembler'; }

  pre.src-caml:before { content: 'Caml'; }

  pre.src-delphi:before { content: 'Delphi'; }

  pre.src-html:before { content: 'HTML'; }

  pre.src-idl:before { content: 'IDL'; }

  pre.src-mercury:before { content: 'Mercury'; }

  pre.src-metapost:before { content: 'MetaPost'; }

  pre.src-modula-2:before { content: 'Modula-2'; }

  pre.src-pascal:before { content: 'Pascal'; }

  pre.src-ps:before { content: 'PostScript'; }

  pre.src-prolog:before { content: 'Prolog'; }

  pre.src-simula:before { content: 'Simula'; }

  pre.src-tcl:before { content: 'tcl'; }

  pre.src-tex:before { content: 'TeX'; }

  pre.src-plain-tex:before { content: 'Plain TeX'; }

  pre.src-verilog:before { content: 'Verilog'; }

  pre.src-vhdl:before { content: 'VHDL'; }

  pre.src-xml:before { content: 'XML'; }

  pre.src-nxml:before { content: 'XML'; }

  /* add a generic configuration mode; LaTeX export needs an additional

    (add-to-list 'org-latex-listings-langs '(conf " ")) in .emacs */

  pre.src-conf:before { content: 'Configuration File'; }

  table { border-collapse:collapse; }

  caption.t-above { caption-side: top; }

  caption.t-bottom { caption-side: bottom; }

  td, th { vertical-align:top;  }

  th.org-right  { text-align: center;  }

  th.org-left  { text-align: center;  }

  th.org-center { text-align: center; }

  td.org-right  { text-align: right;  }

  td.org-left  { text-align: left;  }

  td.org-center { text-align: center; }

  dt { font-weight: bold; }

  .footpara { display: inline; }

  .footdef  { margin-bottom: 1em; }

  .figure { padding: 1em; }

  .figure p { text-align: center; }

  .inlinetask {

    padding: 10px;

    border: 2px solid gray;

    margin: 10px;

    background: #ffffcc;

  }

  #org-div-home-and-up

  { text-align: right; font-size: 70%; white-space: nowrap; }

  textarea { overflow-x: auto; }

  .linenr { font-size: smaller }

  .code-highlighted { background-color: #ffff00; }

  .org-info-js_info-navigation { border-style: none; }

  #org-info-js_console-label

    { font-size: 10px; font-weight: bold; white-space: nowrap; }

  .org-info-js_search-highlight

    { background-color: #ffff00; color: #000000; font-weight: bold; }

  .org-svg { width: 90%; }

  /*]]>*/-->

</style>

<link rel="stylesheet" type="text/css" href="http://www.pirilampo.org/styles/bigblow/css/htmlize.css"/>

<link rel="stylesheet" type="text/css" href="http://www.pirilampo.org/styles/bigblow/css/bigblow.css"/>

<link rel="stylesheet" type="text/css" href="http://www.pirilampo.org/styles/bigblow/css/hideshow.css"/>

<script type="text/javascript" src="http://www.pirilampo.org/styles/bigblow/js/jquery-1.11.0.min.js"></script>

<script type="text/javascript" src="http://www.pirilampo.org/styles/bigblow/js/jquery-ui-1.10.2.min.js"></script>

<script type="text/javascript" src="http://www.pirilampo.org/styles/bigblow/js/jquery.localscroll-min.js"></script>

<script type="text/javascript" src="http://www.pirilampo.org/styles/bigblow/js/jquery.scrollTo-1.4.3.1-min.js"></script>

<script type="text/javascript" src="http://www.pirilampo.org/styles/bigblow/js/jquery.zclip.min.js"></script>

<script type="text/javascript" src="http://www.pirilampo.org/styles/bigblow/js/bigblow.js"></script>

<script type="text/javascript" src="http://www.pirilampo.org/styles/bigblow/js/hideshow.js"></script>

<script type="text/javascript" src="http://www.pirilampo.org/styles/lib/js/jquery.stickytableheaders.min.js"></script>

<script type="text/javascript">

/*

@licstart  The following is the entire license notice for the

JavaScript code in this tag.

Copyright (C) 2012-2017 Free Software Foundation, Inc.

The JavaScript code in this tag is free software: you can

redistribute it and/or modify it under the terms of the GNU

General Public License (GNU GPL) as published by the Free Software

Foundation, either version 3 of the License, or (at your option)

any later version.  The code is distributed WITHOUT ANY WARRANTY;

without even the implied warranty of MERCHANTABILITY or FITNESS

FOR A PARTICULAR PURPOSE.  See the GNU GPL for more details.

As additional permission under GNU GPL version 3 section 7, you

may distribute non-source (e.g., minimized or compacted) forms of

that code without the copy of the GNU GPL normally required by

section 4, provided you include this license notice and a URL

through which recipients can access the Corresponding Source.

@licend  The above is the entire license notice

for the JavaScript code in this tag.

*/

<!--/*--><![CDATA[/*><!--*/

function CodeHighlightOn(elem, id)

{

  var target = document.getElementById(id);

  if(null != target) {

    elem.cacheClassElem = elem.className;

    elem.cacheClassTarget = target.className;

    target.className = "code-highlighted";

    elem.className  = "code-highlighted";

  }

}

function CodeHighlightOff(elem, id)

{

  var target = document.getElementById(id);

  if(elem.cacheClassElem)

    elem.className = elem.cacheClassElem;

  if(elem.cacheClassTarget)

    target.className = elem.cacheClassTarget;

}

/*]]>*///-->

</script>

<script type="text/x-mathjax-config">

    MathJax.Hub.Config({

        displayAlign: "center",

        displayIndent: "0em",

        "HTML-CSS": { scale: 100,

                        linebreaks: { automatic: "false" },

                        webFont: "TeX"

                      },

        SVG: {scale: 100,

              linebreaks: { automatic: "false" },

              font: "TeX"},

        NativeMML: {scale: 100},

        TeX: { equationNumbers: {autoNumber: "AMS"},

              MultLineWidth: "85%",

              TagSide: "right",

              TagIndent: ".8em"

            }

});

</script>

<script type="text/javascript"

        src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS_HTML"></script>

</head>

<body>

<div id="content">

<div id="table-of-contents">

<h2>Table of Contents</h2>

<div id="text-table-of-contents">

<ul>

<li><a href="#org36c0efd">1. vi</a>

<ul>

<li><a href="#org8640934">1.1. Cutting and Pasting Text</a></li>

<li><a href="#org9d035f7">1.2. Modal</a></li>

<li><a href="#orgbb5584f">1.3. Why use vim?</a></li>

<li><a href="#org18706cc">1.4. The Modes</a></li>

<li><a href="#org2a26f8e">1.5. command mode</a></li>

<li><a href="#org8af21d2">1.6. Deleting</a></li>

</ul>

</li>

<li><a href="#orga7a2863">2. Reference</a></li>

</ul>

</div>

</div>

<div id="outline-container-org36c0efd" class="outline-2">

<h2 id="org36c0efd"><span class="section-number-2">1</span> vi</h2>

<div class="outline-text-2" id="text-1">

<p>

<a href="https://www.cs.colostate.edu/helpdocs/vi.html">https://www.cs.colostate.edu/helpdocs/vi.html</a>

</p>

</div>

<div id="outline-container-org8640934" class="outline-3">

<h3 id="org8640934"><span class="section-number-3">1.1</span> Cutting and Pasting Text</h3>

<div class="outline-text-3" id="text-1-1">

<p>

yy copy (yank, cut) the current line into the buffer

Nyy or yNy #copy (yank, cut) the next N lines, including the current line, into the buffer

p put (paste) the line(s) in the buffer into the text after the current line

</p>

<p>

Vim is an text editor.

</p>

</div>

</div>

<div id="outline-container-org9d035f7" class="outline-3">

<h3 id="org9d035f7"><span class="section-number-3">1.2</span> Modal</h3>

<div class="outline-text-3" id="text-1-2">

<p>

the mode that the editor is in determines whether the alphanumeric keys will input those characters or move the cursor through the document.

</p>

</div>

</div>

<div id="outline-container-orgbb5584f" class="outline-3">

<h3 id="orgbb5584f"><span class="section-number-3">1.3</span> Why use vim?</h3>

<div class="outline-text-3" id="text-1-3">

<p>

if do any of the following, you probably want to look into Vim:

• System administration

• Programming

• Working with HTML, LaTeX, or other markup languages

• Heavy editing of plain text files

</p>

<p>

To start Vim from the shell prompt type:  vim filename &lt;ENTER&gt;

</p>

</div>

</div>

<div id="outline-container-org18706cc" class="outline-3">

<h3 id="org18706cc"><span class="section-number-3">1.4</span> The Modes</h3>

<div class="outline-text-3" id="text-1-4">

<p>

insert mode, command mode, and last-line mode

</p>

<p>

Esc  #command mode

I        # insert mode

</p>

<pre class="example">

# last-line mode

</pre>

<p>

i.e.

:w # write the file

:q to exit the editor.

</p>

</div>

</div>

<div id="outline-container-org2a26f8e" class="outline-3">

<h3 id="org2a26f8e"><span class="section-number-3">1.5</span> command mode</h3>

<div class="outline-text-3" id="text-1-5">

<p>

move around/jump:

      • h moves the cursor one character to the left.

      • j moves the cursor down one line.

      • k moves the cursor up one line.

      • l moves the cursor one character to the right.

      • 0 moves the cursor to the beginning of the line.

      • $ moves the cursor to the end of the line.

      • w move forward one word.

      • b move backward one word.

      • G move to the end of the file.

      • gg move to the beginning of the file.

      • `. move to the last edit.

      • A:append and switch to insert mode

</p>

<p>

• i → Insert mode. Type ESC to return to Normal mode.

• x : Delete the char under the cursor

• :wq → Save and Quit (:w save, :q quit)

• dd → Delete (and copy) the current line

• p → Paste

</p>

<p>

To go to (jump) to a user specified line:

change to command model

&gt; Esc

specify line number:

&gt; 3081

&gt; S( shift) +g

</p>

<p>

From <a href="http://yannesposito.com/Scratch/en/blog/Learn-Vim-Progressively/">http://yannesposito.com/Scratch/en/blog/Learn-Vim-Progressively/</a>

</p>

<p>

Here's a handy tip: prefacing a movement command with a number will execute that movement multiple times. So, if you want to move up six lines, enter 6k and Vim will move the cursor up six lines. If you want to move over five words, enter 5w. To move 10 words back, use 10b.

</p>

<p>

Editing a file

:e[dit] Edit the current file. This is useful to re-edit the current file, when it has been changed outside of Vim.

:e[dit]! Edit the current file always. Discard any changes to the current buffer. This is useful if you want to start all over again.

:e[dit] {file} Edit {file}.

:e[dit]! {file} Edit {file} always. Discard any changes to the current buffer.

gf Edit the file whose name is under or after the cursor. Mnemonic: "goto file".

</p>

<p>

From <a href="https://www.fprintf.net/vimCheatSheet.html">https://www.fprintf.net/vimCheatSheet.html</a>

</p>

<p>

Editing Vim Style

0# move to start of the line

x #delete the character that the cursor was on.

u# undo the last command executed.

U(capital)# undo a line

</p>

</div>

</div>

<div id="outline-container-org8af21d2" class="outline-3">

<h3 id="org8af21d2"><span class="section-number-3">1.6</span> Deleting</h3>

<div class="outline-text-3" id="text-1-6">

<p>

delete 100 lines forward from (including) the current one

</p>

<p>

repeat dd (delete current line) 100 times:

</p>

<p>

100dd

</p>

<p>

delete from current line to 99 lines forward

</p>

<p>

d99j

</p>

<p>

delete 100 lines backwards from (including) the current one

</p>

<p>

d99k

</p>

<p>

delete lines in a specific range by line number

</p>

<p>

:1,100d

</p>

<p>

delete lines in a range beginning with the current line

</p>

<p>

:.,.+99d

</p>

<p>

d #starts the delete operation.

dd# delte a whole line

dw # delete from the cursor up to the next word

de# to the end of the current word, including the last character

d0 #delete to the beginning of a line.

d$ # delete to the end of a line.

dgg # delete to the beginning of the file.

dG will delete to the end of the file.

u will undo the last operation.

Ctrl-r will redo the last undo.

d2w: delete 2 words

The format for a is:

              operator  [number]  motion

    where:

      operator - is what to do, such as  d  for delete

      [number] - is an optional count to repeat the motion

      motion  - moves over the text to operate on, such as  w (word),

  $ (to the end of line), etc.

</p>

<p>

From <a href="https://www.linux.com/learn/vim-101-beginners-guide-vim">https://www.linux.com/learn/vim-101-beginners-guide-vim</a>

/solve/set&gt; courant-number

Solve/set/courant-number

</p>

<p>

Searching and Replacing

&gt; /bunny, #search for "bunny"

</p>

<p>

syntax:

/ followed by the text you want to search for

</p>

<p>

• /text search for text in the document, going forward.

• n move the cursor to the next instance of the text from the last search. This will wrap to the beginning of the document.

• N move the cursor to the previous instance of the text from the last search.

• ?text search for text in the document, going backwards.

• :%s/text/replacement text/g #search through the entire document for text and replace it with replacement text.

• :%s/text/replacement text/gc search through the entire document and confirm before replacing text.

S

</p>

<p>

Saving and quitting

:w #write the file to the existing filename

:w filename # write the file to a different filename

:q # quit

:q! # leave without saving changes

set font size

gui

Edit \Select Font.

Command

:set guifont=*

</p>

<p>

PlugIn

</p>

<p>

The put command

p# put previously deleted text after the cursor

</p>

<p>

The replace command

rx# replace the character at the cursor with x

</p>

<p>

The change operator

ce# change until the end of a word

c$# change to the end of a line

The change operator is used with the same motions as delete

</p>

<p>

c    [number]  motion

</p>

<p>

The motions are the same, such as  w (word) and  $ (end of line).

</p>

<p>

Cursor location and file status

Ctrl+ g # show your location in the file and file status

G#move to the bottom of the file

Gg# move to the start of the file

50+G# move to  line 50

</p>

<p>

Search command

/error # search "error"

</p>

<p>

To search for the same phrase again, simply type  n .

To search for the same phrase in the opposite direction, type  N .

To search for a phrase in the backward direction, use  ?  instead of  / .

To go back to where you came from press  CTRL-O  (Keep Ctrl down while

    pressing the letter o).  Repeat to go back further.  CTRL-I goes forward.

</p>

<p>

Matching parentheses search

Type  %  to find a matching ),], or }

NOTE: This is very useful in debugging a program with unmatched parentheses!

</p>

<p>

The substitute command

:s/thee/the # only substitude  the first 'thee'  in the line

:s/old/new/g # substitude 'new' for 'old' in the line

:#,#s/old/new/g 

#where #,# are the line numbers of the range f lines where the substitution is to be done.

  :%s/old/new/g     

#to change every occurrence in the whole file.

:%s/old/new/gc   

#to find every occurrence in the whole file, with a prompt whether to substitute or not.

</p>

<p>

Lesson 5 how to execute an external command

:! + 'external command' #execute an external command

</p>

<p>

Retrieving and merging files

:r filename # to insert the contents of a file

</p>

<p>

Lessoin 6.1 the open command

o# open a line below the cursor and place you in insert mode

O# open a line above the cursor

a# insert text AFTER the cursor

A# insert text after the end of the line

e# comand moves to the end of a word

y# copy

p# paste

</p>

<p>

The append command

A

</p>

<p>

Copy and paste text

y# copy

p# paste

v# visual mode

:help user-manual # read the user manual

</p>

<p>

The vimrc file

</p>

<p>

:edit $MYVIMRC

Create a vimrc startup script to keep your preferred settings.

You probably got tired of typing commands that you use very often.  To start

Vim with all your favorite option settings and mappings, you write them in

what is called the vimrc file.  Vim executes the commands in this file when it

starts up.

</p>

</div>

</div>

</div>

<div id="outline-container-orga7a2863" class="outline-2">

<h2 id="orga7a2863"><span class="section-number-2">2</span> Reference</h2>

<div class="outline-text-2" id="text-2">

<p>

References:

<a href="https://www.linux.com/learn/vim-101-beginners-guide-vim">https://www.linux.com/learn/vim-101-beginners-guide-vim</a>

<a href="http://www.vim.org/docs.php">http://www.vim.org/docs.php</a>

<a href="http://vimhelp.appspot.com/">http://vimhelp.appspot.com/</a>

<a href="http://vimdoc.sourceforge.net/htmldoc/usr_toc.html">http://vimdoc.sourceforge.net/htmldoc/usr_toc.html</a>

<a href="http://yannesposito.com/Scratch/en/blog/Learn-Vim-Progressively/">http://yannesposito.com/Scratch/en/blog/Learn-Vim-Progressively/</a>

<a href="https://blog.interlinked.org/tutorials/vim_tutorial.html">https://blog.interlinked.org/tutorials/vim_tutorial.html</a>

</p>

</div>

</div>

</div>

<div id="postamble" class="status">

<p class="date">Created: 2018-09-20 Thu 11:01</p>

<p class="validation"><a href="http://validator.w3.org/check?uri=referer">Validate</a></p>

</div>

</body>

</html>

相关文章

  • Vim 常用命令

    VIM 命令 文件命令 VIM的模式 VIM导航命令 VIM插入命令 VIM查找命令 VIM替换命令 VIM使用技...

  • 小技巧3:vim学习

    摘要 VIM的插件管理 VIM写latex VIM写python VIM写C++ 1.VIM的插件管理工具vim-...

  • FFmpeg实践记录三:Vim基本讲解

    Vim处理模式 Vim常用命令 Vim拷贝、粘贴和删除 Vim光标移动 Vim行内光标移动 Vim查找与替换 Vi...

  • Vim操作记录

    vim 编辑显示行号: vim 编辑隐藏行号: vim 编辑多行注释: vim 编辑取消多行注释: vim 批量注...

  • 无标题文章

    # Getting Started with Vim ## History of Vim * Vim editor...

  • Vim学习资料

    VIMTUTOR OpenVim vim-adventures The basics of Vim Vim...

  • FFmpeg开发--Vim详解

    Vim编辑器Vim处理模式: Vim常用命令: Vim查找与替换:

  • vi或者vim中文乱码

    打开vi或者vim打开文件“/etc/vim/vimrc” ,指令为:vim /etc/vim/vimrc 将下面...

  • Vim常用命令

    Vim官网:*http://www.vim.org/[http://www.vim.org/] Vim文档: ht...

  • Vim插件

    vim-multifiles Sparkup vim-snipmate surround.vim

网友评论

      本文标题:vim

      本文链接:https://www.haomeiwen.com/subject/msinnftx.html