Vim Advanced entry Features

Source: Internet
Author: User

2.1 Multi-file editing 2.1.1 using Vim to edit multiple files

There are two forms of editing multiple files, one being a parameter that is used before entering Vim is multiple files. Another is to enter vim and then edit the other files.

Create two new files and edit them simultaneously

Vim 1.txt 2.txt

1.txt editing interface for files

  • Command-line mode input :n Edit 2.txt file, you can add ! namely :n! Force switch, the input of a previous file is not saved, just switch to another file

  • Command line mode input :N edit 1.txt file, can be ! forced to :N! switch, the input in the previous file is not saved, just switch to another file

2.1.2 Open new file after entering vim
  • Command line mode enter :e 3.txt open new file 3.txt

  • Command line mode input :e# back to the previous file

  • command-line mode input :ls to list previously edited documents

  • Command line mode input :b 2.txt (or number) can be directly into the file 2.txt edit

  • Enter :bd 2.txt (or number) in command-line mode to delete a file item from a previously edited list

  • Command line mode input :e! 4.txt , new open file 4.txt, discard the file being edited

  • Enter :f The file name you are editing in command line mode

  • Input in command line mode :f new.txt , change the file being edited name to New.tx

2.1.3 Recovering files

If the document is not saved due to a power outage, you can use the recovery method, enter the vim -r document, input :ewcover 1.txt to restore

Vim-r 1.txt

2.2 Visual Mode 2.2.1 Visual Mode command Introduction
  • Enter in normal mode v (lowercase), enter the character selection mode, you can move the cursor, where the cursor will be selected. The selection is deselected when the V-meeting is pressed again.

  • In normal mode input Shift+v (lowercase), enter the line selection mode, press V will be the entire row selection, you can move up and down the cursor select more rows, again, press once Shift+v can be deselected.

  • In normal mode Ctrl+v (lowercase), this is the area selection mode, you can select the rectangular region, and then cancel the selection by one time Ctrl+v .

  • Enter d Delete Selection area contents in Visual mode

  • Enter y Copy selection area contents in Visual mode

2.2.2 Visual mode Command practice

Copy the practice file to the current directory

$ cp/etc/protocols.

Open the practice file

$ VIM Protocols
  • In normal mode 9g Jump To line 9th, enter shift+v (lowercase v), enter the visual mode for row selection, select 5 rows, press >> indent, indent 5 rows into a shiftwidth

  • Enter in normal mode Ctrl+v (lowercase v), enter visual mode for rectangular area selection, select the first column character and then x delete the whole column

2.3 Windows Operation 2.3.1 Windows operation Introduction

Vim can open multiple windows in one interface for editing, which are called Vim windows.

There are many ways to open a method, for example, you can use the command line mode to enter:new Opens a new Vim window and enters the window to edit a new file (normal mode inputCtrl+wYes, butCtrl+wThe shortcut keys for Chrome to turn off the tab in Chrome will conflict, so use this shortcut to practice in IE or another browser, except:newcommand, the various methods listed below can also open a new window in command mode or Normal mode:

  • Command-line mode :sp 1.txt to open a new horizontal split-screen window to edit 1.txt

  • Command-line mode :vsp 2.txt to open a new vertical split screen window to edit 2.txt

  • Ctrl-w s split the current window into two horizontal windows in normal mode

  • Ctrl-w v split the current window into two vertical windows in normal mode

  • In normal mode Ctrl-w q , it is: Q ends the split window. If you have input in a new window, you need to use the mandatory character! namely: q!

  • Ctrl-w oOpen a window in normal mode and hide all previous Windows

  • Ctrl-w j move to the following window in normal mode

  • Ctrl-w k move to the upper window in normal mode

  • Ctrl-w h move to the left window in normal mode

  • Ctrl-w l move to the right window in normal mode

  • Ctrl-w J Move the current window below in normal mode

  • Ctrl-w K Move the current window to the top in normal mode

  • Ctrl-w H Move the current window to the left in normal mode

  • Ctrl-w L Move the current window to the right in normal mode

  • Ctrl-w -reduce the height of the window in normal mode

  • Ctrl-w +increase the height of the window in normal mode

2.4 Document Encryption 2.4.1 Creating encrypted documents
$ vim-x File1

Enter your password

Confirm Password

This will require you to enter your password the next time you open it


This article is from the Linux Essentials blog, so be sure to keep this source http://13131277.blog.51cto.com/13121277/1956140

Vim Advanced entry Features

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.