• Linux vim撤销/恢复命令

    2020-02-13 19:06:17
  • linux vim命令VIM or the Vi Improved text editor is one of the most advanced text editors available. Let’s learn the top 20 best Linux Vim commands that you must know to gain amazing levels of ...

    linux vim命令

    VIM or the Vi Improved text editor is one of the most advanced text editors available. Let’s learn the top 20 best Linux Vim commands that you must know to gain amazing levels of productivity.

    VIMVi改进的文本编辑器是可用的最高级的文本编辑器之一。 让我们学习您必须知道的前20条最佳Linux Vim命令,以获得惊人的生产力。

    Remember, the VIM text editor has a pretty steep learning curve. But once you put in the time to get used to the commands, you will attain unmatched productivity in your day-to-day tasks that require working with text (perfect text-editor for programmers!)

    记住,VIM文本编辑器的学习曲线相当陡峭。 但是一旦您花时间习惯了这些命令,您将在需要处理文本的日常任务中获得无与伦比的生产力(程序员的完美文本编辑器!)

    Linux Vim Commands
    Linux Vim Commands – Color schemes
    Linux Vim命令–配色方案

    Very geeky isn’t it? Let’s understand the editor and the commands in it.

    是很讨厌吗? 让我们了解编辑器及其中的命令。

    用于基本导航的Linux Vim命令 (Linux Vim Commands for Basic Navigation)

    Before we begin, let’s go over how we can navigate within the VIM editor. VIM is a keyboard focused editor so you have to start getting used to not touching the mouse for basic navigation tasks.

    在开始之前,我们先来看一下如何在VIM编辑器中导航。 VIM是专注于键盘的编辑器,因此您必须开始习惯于不触摸鼠标来执行基本的导航任务。

    Arrow Keys
    h j k l
    Basic cursor movement as normal
    B b
    W w
    Move backward and forward by one word at a time – cursor at the start of the word
    <Line Number>GJump to a specified line number
    Similar to page up/down key while the cursor stays on-screen.
    eMove forward by one word – cursor at the end of the word
    Find the word within the document that your cursor is currently at.
    Repeats the last find command
    按键 行动
    <行号> G 跳转到指定的行号
    Ctrl + u
    Ctrl + d
    Ë 向前移动一个单词-光标位于单词的末尾


    掌握Linux Vim的主要命令和功能 (Geek Out with the Top Linux Vim Commands and Features)

    The VIM editor is not only flexible and comprehensive but also very intuitive and “smart” when it comes to understanding the code that’s written.


    But if you don’t mind spending your time moving the mouse cursor around pointing and clicking at things, there’s no reason for you to consider VIM. This text editor is for programmers and geeks who really love to go all out, ignore the mouse for good, and do everything using the keyboard.

    但是,如果您不介意花费时间在指向和单击事物周围移动鼠标光标,则没有理由考虑使用VIM。 该文本编辑器适用于那些真正喜欢全力以赴,永远忽略鼠标并使用键盘进行所有操作的程序员和怪胎。

    The thing with VIM is, if it can be done with a mouse in other text editors, it can be done with just the keyboard in VIM.


    1.在Vim中处理多个文件 (1. Work With Multiple Files in Vim)

    Most of us programmers are used to working with multiple files at the same time. Our GUI text editors give us tabs that allow switching between files while all stay open simultaneously. Even though there are a few keyboard shortcuts to play around with those tabs, it’s nowhere compared to what VIM can do.

    我们大多数程序员习惯于同时处理多个文件。 我们的GUI文本编辑器为我们提供了一些选项卡,可在所有文件同时保持打开状态时在文件之间进行切换。 尽管在这些选项卡上有一些键盘快捷键可以使用,但与VIM相比,这是无与伦比的。

    :tabedit <tab key to scroll through files in directory>
    Tabedit Vim Commands
    Tabedit Vim Commands
    Tabedit Vim命令

    The best part? You don’t touch the mouse whatsoever. How do you move around the files? With gt or gT to switch tabs forward or backward respectively. Also :tabfirst and :tablast will let you jump back and forth from the first to the last tabs that are currently open.

    最好的部分? 您什么也不要触摸鼠标。 您如何在文件之间移动? 使用gtgT分别向前或向后切换选项卡。 也可以使用:tabfirst:tablast从当前打开的第一个选项卡到最后一个选项卡来回跳转。

    But if you want to open all the files directly at the start, just type:


    vim -p source_file1.py source_file2.py source_file3.py 

    2.在VIM中保存并打开Tab会话 (2. Save and Open Tab Sessions in VIM )

    Alright, so now you have opened a ton of files in tabs and also moved across made changes to the files. But did you notice that you have to always open the files every time you want to have them in the tabs?

    好了,现在您已经在选项卡中打开了大量文件,并且还对文件进行了更改。 但是您是否注意到,每次要在选项卡中保存文件时,都必须始终打开文件?

    What if there was a way to save the open files as they are and just move with it?


    That’s exactly what VIM sessions are for. When you work with multiple files in VIM, it’s better to save a VIM session so the next time you open the session file, everything will come back up exactly as you left it.

    这正是VIM会话的目的。 当您在VIM中处理多个文件时,最好保存一个VIM会话,以便下次打开该会话文件时,所有内容都将按照您离开时的状态完全恢复。

    How do you create a VIM session? You first move out of the insert mode by pressing the Esc key. Then enter the below command.

    如何创建VIM会话? 您首先通过按Esc键退出插入模式。 然后输入以下命令。

    :mksession <Session Name>.vim

    Now the next time when you want to open the session, you can directly open it from the terminal by typing:


    vim -S <Session Name>.vim

    Or if you want to open a session file while inside VIM, just type:


    :source <Session Name>.vim

    3.在VIM中自动完成文本 (3. AutoComplete Text in VIM)

    Feel that VIM cannot compare with the autocomplete features of other IDEs or text editors? Well, give it a shot. Even though it doesn’t use Artificial Intelligence or any sort of machine learning algorithms to back this feature, it’s robust enough.

    觉得VIM无法与其他IDE或文本编辑器的自动完成功能进行比较? 好吧,试一试。 即使它不使用人工智能或任何类型的机器学习算法来支持此功能,也足够强大。

    When you’re in your VIM editor trying to edit some code, press the below key combination to check it’s superb auto-completion.


    Vim Ctrl N
    Vim Ctrl N
    Vim Ctrl N

    Based on the letters typed, the editor finds the closest match for the word you might type. Though it doesn’t understand anything of what you type, it does the job really well.

    根据键入的字母,编辑器会找到与您可能键入的单词最接近的匹配项。 尽管它不了解您键入的内容,但确实可以很好地完成工作。

    4. Linux VIM命令执行括号匹配 (4. Linux VIM Commands to Perform Brace Matching)

    As we previously mentioned that the VIM editor searches for patterns within the text, it brings with it brace matching while you’re coding. It makes things very easy for us when we’re working with long codes.

    正如我们之前提到的,VIM编辑器在文本中搜索模式,因此在编码时会带来大括号匹配。 当我们使用长代码时,这对我们来说非常容易。

    This one is pretty straight forward. Take your cursor to the opening/closing brace and press the % sign on the keyboard.

    这很简单。 将光标移至打开/关闭括号,然后按键盘上的%符号。

    And just like that, your cursor will jump to the matching brace.


    5.在VIM中标记并折叠代码块 (5. Mark and Fold Code Blocks in VIM)

    This isn’t as straightforward as you’d want it to be because the code editor does not understand what we are typing but only works on pattern matching. 


    So how do we go about folding code inside vim editor? We start with bringing the cursor to where we want to begin the folding and from there we use the letter V to begin marking the code until where we want it to fold.

    那么我们如何在vim编辑器中折叠代码呢? 我们首先将光标移到我们要开始折叠的位置,然后使用letter V开始标记代码,直到我们希望其折叠为止。

    Highlight Code Vim
    Highlight Code Vim

    Once we have marked the code with the letter V , then press zf to fold the code. The f in the zf stands for fold. how do we open the Code we just press by highlighting the first line of the folded code

    一旦我们用字母V标记了代码,然后按zf折叠代码。 zf中的f代表fold 。 我们如何通过突出显示折叠代码的第一行来打开我们刚刚按下的代码

    Code Folded
    Code Folded

    To open the code now, we can bring our cursor to the line where the folded code is (as you can see in the above screenshot, the grey colored line which says 6 lines: function1(). Once your cursor is on that line, press zo where o stands for open.

    现在要打开代码,我们可以将光标移到折叠代码所在的行(如您在上面的屏幕截图中所看到的,灰色的行表示6行:function1()) 。按下zo ,o代表打开

    But the above method is good in cases where the code is small. What if you want to jump through a few hundred lines of code? Let me show you another marking technique that will cut your time in half.

    但是,在代码较小的情况下,上述方法很好。 如果您想跳过几百行代码怎么办? 让我向您展示另一种标记技术,它将使您的时间减少一半。

    • Go to the line where you want to start the folding of the code

    • Press the letter m followed by any other letter to name the marking. For example mk

      letter m再按其他字母以命名标记。 例如mk
    • Highlight any of the braces within the code and press % to jump directly to the matching close brace.

    • Press zf'k


    The 'k signals the fold command to look for the “k” mark which we pointed out by typing out mk at the start.

    'k表示fold命令寻找“ k”标记,我们通过在开头输入mk指出了该标记。

    6.在不离开VIM的情况下浏览系统中的文件 (6. Explore Files in Your System, Without Leaving VIM)

    A regular GUI text/code editor person would feel that they miss the “Project folder” column that usually is provided on the left sidebar of the code editor window. Can VIM replicate that?

    普通的GUI文本/代码编辑人员会感到他们错过了通常在代码编辑器窗口的左侧栏中提供的“项目文件夹”列。 VIM可以复制吗?

    Of course!


    With the two commands :Vexplore and :Sexplore, you can split the window into two sections and browse through the entire file system. Have a look at both the commands.

    使用两个命令:Vexplore:Sexplore ,您可以将窗口分为两部分,并浏览整个文件系统。 看一下这两个命令。

    V Explore VIM linux vim commands
    V Explore VIM
    S Explore Vim linux vim commands
    S Explore Vim

    As you can see, in both cases, the file manager is opened and you can navigate through the files without losing your focus from the code file that you were working on.


    Since we’ve already seen the split-screen capabilities of VIM, how do we split the screen in two and edit two codes?


    7.拆分VIM代码窗口 (7. Split VIM Code Window )

    You can either Vertically or Horizontally split the VIM window and edit multiple code files without moving away from the other. How? Let’s have a look.

    您可以垂直或水平拆分VIM窗口并编辑多个代码文件,而又不会相互偏离。 怎么样? 我们来看一下。

    The Vexplore and Sexplore commands allow us to browse through files and open any file in the split section of the terminal. But if you just want to open the file, you can use the vsplit or split command.

    使用VexploreSexplore命令,我们可以浏览文件并在终端的split部分中打开任何文件。 但是,如果您只想打开文件,则可以使用vsplitsplit命令。

    :vsplit <filename>
    :vsp <filename>
    :split <filename>
    :sp <filename>

    The above command will split the terminal vertically and open the other file for you.


    Vim Split Windows
    Vim Split Windows
    Ctrl-w ←
    Ctrl-w h
    Focus on the left adjacent split
    Ctrl-w →
    Ctrl-w l
    Focus on the right adjacent split
    Ctrl-w ↓
    Ctrl-w j
    Focus on the bottom adjacent split
    Ctrl-w ↑
    Ctrl-w k
    Focus on the top adjacent split
    Ctrl-w n+
    Ctrl-w n
    Increase or decrease the size of the split by n lines
    命令 行动
    Ctrl-w l
    Ctrl-w j
    Ctrl-w k
    Ctrl-W n +
    Ctrl-w n

    If you’re working through an SSH client software like Terminus to connect to your Linux server, using the default VIM commands to switch splits will simply close the connection.


    Because Ctrl-W is the default shortcut to close tabs on Terminus and on many other Windows software. So how do we go about this?

    因为Ctrl-W是关闭Terminus和许多其他Windows软件上的选项卡的默认快捷方式。 那么我们该如何做呢?

    VIM allows us to remap keys to save keystrokes and also to avoid conflicts.


    8.重新映射和更改Linux VIM命令 (8. Remap and Change Linux VIM Commands )

    Some shortcuts in VIM are quite cumbersome and can make us wonder if all the effort is even worth it!


    The remap, noremap, nnoremap, inoremap, vnoremap commands allow us to remap existing VIM commands to any other key that we’d like to set up.


    The difference between the mapping commands is the map modes they work in. Covering the map modes is out of scope for this topic so I’ll leave it to you to read. Go ahead and type in :help map-modes.

    映射命令之间的区别在于它们使用的地图模式。本主题涵盖的地图模式不在本主题的讨论范围之内,因此我将让您阅读。 继续输入:help map-modes

    Map Modes Vim
    Map Modes Vim

    This is the overview of the map-modes but the help topic has a ton of details if you’re interested in understanding these modes.


    How to map the existing vim command shortcuts? We’ll work with the “map” command.

    如何映射现有的vim命令快捷方式? 我们将使用“地图”命令。



    :map <new key-combo> <existing key-combo>
    For example: 
    :map <C-J> <C-W><C-J>
    :map <C-K> <C-W><C-K>
    :map <C-L> <C-W><C-L>
    :map <C-H> <C-W><C-H>
    :map l gg

    The above mappings will change the default split-window switching commands to Ctrl-J, Ctrl-K and so on instead of the added Ctrl-W.


    The last command will change the gg command to l. So whenever you press l, you’ll be taken to the first line.

    最后一条命令会将gg命令更改为l 。 因此,无论何时按l,您都将被带到第一行。

    Do this for as many commands as you need. But these mappings are session-based. Once you quit vim, the mappings are reset.

    对所需的命令执行此操作。 但是这些映射是基于会话的。 退出vim后,映射将重置。

    To set persistent key mapping, we need to add the commands to the VIMrc file. Simply copy-paste the commands without the : in the ~/.vimrc file. If the file does not exist, just create one with only the commands that you need to run on startup of VIM.

    要设置持久键映射,我们需要将命令添加到VIMrc文件。 只需在〜/ .vimrc文件中复制粘贴不带:的命令即可。 如果该文件不存在,则仅使用启动VIM时需要运行的命令来创建一个。

    To set up these key mappings in addition to the existing default vim configuration, just make a copy or symlink the original file as below:


    root@ubuntu:~# ln -s ~/code/dotfiles/vim/vimrc ~/.vimrc

    9. Linux VIM命令启用语法突出显示 (9. Linux VIM commands to enable Syntax Highlighting)

    Continuing from our previous section, we can add the command syntax on in the ~/.vimrc file to enable the syntax highlight. Have a look at the difference that it would make.

    在上一节的基础上,我们可以在〜/ .vimrc文件中添加命令syntax on以启用语法突出显示。 看看会带来什么变化。

    Syntax Off Vim
    Syntax Off Vim
    Syntax On Vim
    Syntax On Vim

    You can obviously turn the syntax highlighting on and off while in session too as we did for all other commands before.


    10. Linux VIM命令剪切,复制和粘贴 (10. Linux VIM commands to Cut, Copy, and Paste)

    Copying and pasting are not as straightforward as Ctrl-c Ctrl-v but it’s pretty easy!

    复制和粘贴不像Ctrl-c Ctrl-v那样简单,但是非常简单!

    In VIM, Copy action is called Yank, and Cut action is called Delete. The paste action continues to be called Paste.

    在VIM中,复制动作称为Yank ,而剪切动作称为Delete 。 粘贴动作继续称为Paste

    So the shortcuts are named according to these names. For example, if I have to “Yank” something, I can type y and the selected text gets yanked.

    因此,快捷方式是根据这些名称来命名的。 例如,如果我必须“表示”某些内容,则可以键入y ,然后选中的文本将被选中。

    To cut a text, the command is the same as delete, the letter d. So you can understand that even when you delete a piece of text, the VIM editor is actually preparing the text to be pasted somewhere else.

    要剪切文本,命令与删除相同,即字母d 。 因此,您可以理解,即使删除一段文本,VIM编辑器实际上也正在准备将文本粘贴到其他地方。

    Whatever section the cursor is at, will get copied or deleted. To paste the copied text, just type p to paste after the cursor, and P to paste before the cursor.

    光标所处的任何区域都将被复制或删除。 要粘贴复制的文本,只需键入p光标后粘贴,以及P光标前粘贴。

    11. VIM中的拼写检查 (11. Spell Checking in VIM)

    Didn’t expect to see this point, did you? Well, VIm does have a spell checking option that works based on a dictionary file that is already available. All we have to do is set up the language.

    没想到看到这一点,是吗? 好吧,VIm确实有一个拼写检查选项,该选项可基于已经可用的字典文件工作。 我们要做的就是设置语言。

    Spell Check Off
    Spell Check Off

    In the ~/.vimrc file, add the following line:

    在〜/ .vimrc文件中,添加以下行:

    set spell spelllang=en_us
    Spell Check On Linux vim commands
    Spell Check On

    As you can see, the Lorem Ipsum text gets instantly highlighted when I enabled the spell check.

    如您所见,当我启用拼写检查时,Lorem Ipsum文本会立即突出显示。

    12.替代–在VIM中查找和替换 (12. Substitution – Find and Replace in VIM)

    The find and replace functionality that all the GUI text editors offer is also found on VIM. How? Because of pattern matching.

    所有GUI文本编辑器都提供的查找和替换功能也可以在VIM上找到。 怎么样? 由于模式匹配。

    :%s /Lorem/JournalDev/g

    The above line will instantly replace every occurrence of Lorem on each line (g) with the word JournalDev.

    上一行将立即用JournalDev单词替换每行( g )上出现的Lorem。

    13.在VIM中执行Linux命令 (13. Execute Linux Commands In VIM)

    So you’re editing some code and need to quickly run a command. Do you need to save and exit VIm just to run the code? Not really!

    因此,您正在编辑一些代码,并且需要快速运行命令。 您是否需要保存并退出VIm才能运行代码? 并不是的!

    Vim allows you to run the code from within the editor without having to lose track of the code. You can do this by the use of an exclamation mark after the colon. Here’s an example:

    Vim允许您从编辑器中运行代码,而不必失去对代码的跟踪。 您可以通过在冒号后使用感叹号来做到这一点。 这是一个例子:

    :!ping www.journaldev.com

    That’s it! Now if it’s a command that ends after output, you can hit the ENTER key and get back to programming. But in case of this ping command, you can hit the keyboard interrupt Ctrl-C and then hit the ENTER key without losing your VIM editor from the background.

    而已! 现在,如果这是一条在输出后结束的命令,则可以按ENTER键并返回编程。 但是,在执行此ping命令的情况下,您可以按键盘中断Ctrl-C ,然后按Enter键,而不会从后台丢失VIM编辑器。

    Alternatively, you can just type :shell to directly get a shell opened up for you. Once you’re done with what you need to do, you just type exit to exit the shell and get back to VIM which stays as it was left before.

    另外,您可以键入:shell直接为您打开一个shell。 完成所需的工作后,只需键入exit即可退出外壳程序并返回到VIM(保留之前的状态)。

    14.删除多个单词 (14. Deleting Multiple Words)

    You know that the words to the right of your cursor need to be deleted. But not the entire sentence. How do you do it? With the same command and some additional parameters.

    您知道光标右边的单词需要删除。 但不是整个句子。 你怎么做呢? 使用相同的命令和一些其他参数。

    The d command will simply make use of the number specified after it to delete those many words. Have a look at the command below. Both commands work based on where the cursor is at.

    d命令将仅使用其后指定的数字来删除许多单词。 看下面的命令。 这两个命令都基于光标所在的位置。

    d3w #This will delete 3 words to the right 
    d3b #This will delete 3 words to the left

    15. Linux VIM命令撤消更改 (15. Linux VIM command to Undo Changes)

    While you’re getting used to VIM, there will be times when you end up deleting something that you didn’t want to. The Ctrl-Z approach doesn’t work on VIM so how do you undo your work?

    当您习惯了VIM时,有时您最终会删除不需要的内容。 Ctrl-Z方法在VIM上不起作用,那么如何撤消工作?


    The letter u will automatically undo the changes just like ctrl-z would.


    16.从其他文件插入文本 (16. Insert Text From Different File)

    This is a pretty useful productivity hack. Saves time copy-pasting things from multiple files to merge between them.

    这是一个非常有用的生产力黑客。 节省了从多个文件复制粘贴内容以在它们之间合并的时间。

    So what exactly is this? It simply reads text from another file that is specified and inserts the entire text right after the cursor.

    那到底是什么呢? 它只是从另一个指定的文件中读取文本,然后将整个文本插入到光标之后。

    Before Retrieving Other File Linux vim commands
    Before Retrieving Other File
    :r <file name>
    After Retrieving File Contents
    After Retrieving File Contents

    17. VIM中的宏 (17. Macros in VIM)

    We know VIM can do a lot, but did you imagine a command-line editor to be able to record macros? Well, you better start imagining as this editor is called powerful because of the great potential this simple-looking editor has.

    我们知道VIM可以做很多事情,但是您是否想像命令行编辑器能够记录宏? 好吧,您最好开始想象一下,因为此编辑器具有巨大的潜力,因此它被称为功能强大的编辑器。

    How do you record a macro? It’s very easy! You enter the command mode (If you’re in insert mode, just press Esc).

    您如何录制宏? 非常简单! 您进入命令模式(如果处于插入模式,只需按Esc

    qb #The letter after q is just to identify the macro. Can be anything
    q #Stop recording macro
    @b #Replay the macro. The letter runs that specific macro

    What’s the use of this macro? Anything that you can do within the VIm editor can be done with a macro. So for example you:

    这个宏有什么用? 在VIm编辑器中可以执行的任何操作都可以使用宏来完成。 例如,您:

    • Go to the first word

    • Delete the first word

    • Replace it with something else


    If you have to do this for multiple lines, all you need to do is record a macro and replay it.


    18.使用计数命令 (18. Using Count For Commands)

    Almost every command that “might” need to enter multiple times, accepts a number as an argument. For example, the delete command d, the line jump command k, etc.

    几乎每个“可能”需要多次输入的命令都接受一个数字作为参数。 例如,删除命令d ,行跳转命令k等。

    So if I want to delete 6 lines, I can do the d command 6 times or just say 6d.


    That’s for delete, you can also do it when moving around the text. If I want to move by 3 words, all I type is 3w or 3e depending on where I want the cursor to be placed, at the start or at the end.

    这是为了删除,您也可以在移动文本时进行删除。 如果我想移动3个单词,则根据键入光标的位置(在开头还是结尾),我键入的都是3w3e

    19.了解文件中的进度 (19. Knowing Progress Within File)

    If you’re scrolling through a long file and you simply need to know where you are at present, go for this command. It will give you a percentage figure of where you stand at the present moment within the file.

    如果要滚动浏览一个长文件,而只需要知道当前位置,请执行此命令。 它将为您提供文件中当前位置的百分比图。

    Ctrl G Linux vim commands
    Ctrl G in VIM
    在VIM中按Ctrl G

    As you can see in the above image, it tells me that my cursor’s current position is at the 40% mark from the end of the file. The command to do this is by typing Ctrl-G when you’re in command mode.

    如上图所示,它告诉我光标的当前位置位于文件末尾40%的位置。 执行此命令的命令是在命令模式下键入Ctrl-G

    20. Linux VIM命令的帮助模块 (20. Help Modules For Linux VIM commands )

    I’m going to end this post by talking about the handy tool, the help command. Similar to man pages in Linux, the help command allows users to understand all the vim commands in detail. Here’s an example of what the help command shows for our delete command.

    在本文的结尾,我将讨论方便的工具help命令。 类似于Linux中的手册页, help命令使用户可以详细了解所有vim命令。 这是help命令显示我们的delete命令的示例。

    :help d
    Vim Help Command
    Vim Help Command

    结论 (Conclusion)

    This is just going to be the start of your journey in vim-land. There are loads of commands and features that you’ll explore as you go along with learning VIm.

    这只是您在vim-land之旅的起点。 学习VIm时将探索大量的命令和功能。

    But there’s one thing that you can be assured of. If you learn VIM well enough once, it will just become second nature to you to expect those features when you start using any other editor!

    但是您可以放心一件事。 如果您足够了解VIM,那么当您开始使用任何其他编辑器时,期待这些功能将成为您的第二天性!

    参考资料 (References)

    翻译自: https://www.journaldev.com/35713/linux-vim-commands

    linux vim命令

  • Linux vim撤销与恢复

    2020-05-08 17:02:34
    vim撤销操作:u vim恢复操作:ctrl+r



  • Linux vim

    2019-11-11 10:12:03
    subline用于win和linuxvim用于unix和linux类似win的notepad;vim为vi升级版本,vi使可文本编辑,vim在基础上进行coding。 vim有三个模式:1,末行模式2,编辑模式3,命令模式 命令模式:不可直接编辑,进行命令...


    vim filepath         打开指定路径
    vim +n filepath      打开路径文件并移动光标在n行
    vim +/关键字 filepath 打开并高亮显示关键字

    (1)保存:ww filepath 另存为
    (5)搜索/查找:/key 查找关键字,nohl取消高亮(nohighlight)
    (6)显示行号:set nu 反之set nonu
    :bn 表示下一个文件 back next
    :bp 表示前一个文件 back prev
    syntax on打开着色syntax off关闭着色





    ctrl+b 向上翻屏   before
    ctrl+f 向下翻屏	after

    复制:yy 粘贴:p
    (1)撤销u undo
    (2)恢复ctrl+r restore

    b,按下按键ctrl R,然后输入=,此时光标移动最后一行

  • Linux vim学习

    2017-08-17 14:51:16
    Linux vim学习
  • linux vim

    2019-12-08 10:28:57
    小插曲 最近正在搞linux的vi文本编译器 发现了好多事,首先是只有vi没有vim,要安装vim需要yum以及联网 网络配置: https://blog.csdn.net/helloonego/article/details/84038554 安装vim命令: ...
  • #linux linux VIM编辑器与磁盘管理   目录 #linux linux VIM编辑器与磁盘管理 1、VIM编辑器  1.1 概述  1.2 VIM编辑器的操作模式  1.3 VIM编辑器的命令格式 2、磁盘管理  2.1 查看磁盘信息的有关命令 ...
  • Linux Vim

    2017-06-12 17:48:00
    u|undo 撤销 .|重复上一次命令 mx|设置书签 编辑模式 进入 命令 描述 i (insert)字前添加 I 行首添加 a (append)字后添加 A 行尾添加 ...
  • Linux VIM 实用技巧

    2021-07-25 10:39:35
    Linux VIM 实用技巧 阅读代码 ctrl + f 向前翻 ctrl + b 向后翻 gg 文件第一行 G 文件最后一行 vim 文件名 +n 打开文件并跳到第n行 :/字符 在文件中进行搜索 n向后搜索 N向前搜索 编辑 i 插入 I 行首进行...
  • Linux vim命令

    2020-09-02 11:19:24
    vim的介绍 vim 是一款功能强大的文本编辑器,也是早年 Vi 编辑器的加强版,它的最大特色就是使用命令进行编辑,完全脱离了鼠标的操作。 vim的工作模式 命令模式 编辑模式 末行模式 说明: vim 打开文件进入的是...
  • Linux vim简介

    2020-07-19 18:01:08
    vim下常用的几个快捷键(我看到的是韩顺平老师的Linux课程,所以其实是老师总结的,嘻嘻): 拷贝当前行:yy, 拷贝当前向下n行并粘贴:nyy 删除当前行:dd, 删除当前行向下的n行:ndd 在文件中查找某个关键字:/...
  • linux vim查找替换撤销

    2017-09-27 09:59:58
    感谢原作者 ...(1) Linux下的vi编辑命令中查找·替换详解 一、查找  查找命令  /pattern :向下查找pattern匹配字符串  ?pattern:向上查找pattern匹配字符串  使用了查找
  • LINUXvim

    2018-07-19 12:56:52
    ###vim的命令模式### :set+调整参数(用来调整vim的工作方式) :set nu #显示行号 :set nonu #不显示行号 :set mouse =a #显示鼠标 :set cursorline #显示行线 注意: 在vim命令行中的设置是临时的,...
  • linux vim/vi 编辑器

    2021-07-10 09:13:51
    目录linux vim/vi 编辑器简介模式切换底行模式命令模式移动光标复制粘贴删除 替换 搜索撤销快捷键插入模式修改配置文件 简介 vim/vi 编辑器是linux下常用的文本编辑器,可以编辑、创建任何格式的文件 vim对vi的全部...
  • linux vim vi编辑时撤销输入操作 1,esc退出输入状态 2,u 撤销上次操作 3,ctrl+r 恢复撤销 转载于:https://www.cnblogs.com/cymwill/p/7839687.html
  • Vi和Vim的区别及联系1.使用vim替换vivim比vi强大多了,vim属于vi的超集,而且能够解决很多习惯的问题,所以还是有必要使用vim替换vi的。简单地话,可以直接使用“alias vi=vim”命令即可,不过这样只能在这次启动的...
  • Linux vim编辑器

    2019-09-14 12:29:12
    vi 编辑器 是所有unix 及 linux 系统下标准的编辑器,vim 也是 linux 的编辑器, vim 相对来说比较高级,更适合用于 coding 编辑 vim 点是光标的移动,模式切换,删除,查找替换,复制,粘贴,撤销命令的使用 二,...
  • linux vim命令

    2017-04-20 13:13:55
    vi/vim 基本使用方法  vi编辑器是所有Unix及Linux系统下标准的编辑器,它的强大不逊色于任何最新的文本编辑器,这里只是简单地介绍一下它的用法和一小部分指令。由于对Unix及Linux系统的任何版本,vi编辑器是完全...
  • 1. 启动vimvim 文件名2. vim的三种模式命令模式 - 按键代表命令: i ---> 进入 编辑模式(光标前插入)a ---> 进入 编辑模式(光标后插入): ---> 进入 末行模式/ ---> 进入 末行模式(查找)编辑模式- 键入...
  • linux vim的使用

    2021-07-02 19:28:52
  • linux vim 详解

    2016-05-28 14:52:30
    1.RPM查看vi vim 命令来源于哪个安装包 [root@zbb64 ~]# rpm -qf `which vi ` vim-minimal-7.2.411-1.8.el6.x86_64 [root@zbb64 ~]# rpm -qf `which vim ` vim-enhanced-7.2.411-1.8.el6.x86_64 2.vim编辑器...
  • linux vim 常用操作

    2021-07-29 14:49:45
    Vim 撤销 回退 操作https://blog.csdn.net/a1010256340/article/details/80077102
  • Linux vim 快捷键

    2018-08-03 14:01:04
    普通模式:  dd:删除光标所在行  数字dd:删除包括光标所在行在内的n行(n由dd前面的数字决定)  yy:复制光标所在行  数字yy:复制包括光标所在行... u:撤销操作  .:重复上一步操作  :set nu:显示行号  :set n...
  • Linux vim的练习

    2020-03-30 22:30:03
    vim vim简介 所有UNIX系列的OS都会内置vi文本编辑器,很多软件的编辑接口都会主动调用vi(例如crontab);vim具有程序编辑的能力,可以主动以字体颜色辨别语法的正确性,方便程序设计;vim会根据文件的扩展名或者是...
  • linux vim简单使用

    千次阅读 2019-01-27 20:57:10
    1.vim三种模式 命令模式:打开文件默认...末行模式:在该模式下,可以在末行输入命令对文件进行操作,如搜索,替换,保存,退出,撤销,高亮等。 2.vim打开文件的方式 ①#vim 文件路径 ②#vim +数字 文件路径 光标...
  • Linux Vim常用快捷键

    2018-05-16 16:42:35
    Linux Vim常用快捷键服务器上操作,经常要用vim查看编辑文件内容,不懂快捷键导致效率很低,于是就查阅网络资料总结了一下vim常用的快捷键。1、删除x 小写的 x 表示向后删除一个字符,也就是删除光标所在的字符nx...
  • Linux Vim 常用实用指令

    2019-09-10 18:55:02
    Linux Vim 常用实用指令保存与退出复制粘贴删除撤销插入使用命令计数移动光标滚屏在文本中查找下一个word多行注释多文件编辑 风萧萧兮易水寒 保存与退出 :w 保存文件但不退出 :w file 将修改另外保存到file中,不...



1 2 3 4 5 ... 20
收藏数 20,992
精华内容 8,396


linux 订阅