windows10 install vim editor

When we are doing git operations, many text editing tasks will open Vimthe editor by default for operations.
Vimis a highly configurable text editor designed to make creating and changing any type of text very efficient. Most UNIX systems and Apple OS X include it as an editor vi, and you are used to the editor in Linux . If you need to edit files in the cmd terminal of Windows , you need to install the Windows version separately .VimVim

1. Installation

1. Open PowerShell

There are many ways to open PowerShell, the following are the ways:

  • You can open PowerShell here by pressing shift+ on the desktop or in a blank space of the folder .鼠标右键
    insert image description here
  • You can switch to edit mode in the address bar at the head of the folder, then enter powershelland press Enter
    insert image description here
  • You can press the key combination Win+ Renter powershelland press Enter to open Powershell.
    insert image description here

2. Download+Install

Enter the following command in PowerShell , and the installer will automatically start after the download is complete

wget -o gvim90.exe https://ftp.nluug.nl/pub/vim/pc/gvim90.exe ; ./gvim90.exe

insert image description here
The installation process will be completed by default in the next step.

3. use

Just enter the command in powershell: vim, it will automatically switch to the vim editor.
insert image description here
insert image description here

Two, common commands

1. Basic commands

Here are some basic Vim commands:

  • i: Insert text at the current cursor position.
  • x: Delete the character at the current cursor position.
  • :w:save document.
  • :q: Exit the Vim editor.
  • :q!: Force quit the Vim editor without saving the file.
  • :wq: Save the file and exit the Vim editor.

2. Cursor movement command

Moving the cursor is a common operation when editing text. The following are some commonly used cursor movement commands:

  • h: Move the cursor one character to the left.
  • j: Move the cursor down one line.
  • k: Move the cursor up one line.
  • l: Move the cursor one character to the right.
  • w: Move the cursor to the beginning of the next word.
  • e: Move the cursor to the end of the current word.
  • b: Move the cursor to the beginning of the previous word.
  • 0: Move the cursor to the beginning of the current line.
  • $: Move the cursor to the end of the current line.
  • G: Move the cursor to the end of the file.
  • gg: Move the cursor to the beginning of the file.
  • /<pattern>: Search downward <pattern>.

3. Text editing commands

Vim has a wealth of text editing commands, the following are some commonly used commands:

  • dd: Delete the current line.
  • yy: Copy the current line.
  • p: Paste the copied or deleted text.
  • u: Undo the last operation.
  • Ctrl-r: Redo the last operation.
  • r: Replace the character at the current cursor position.
  • c: Delete the text from the current cursor position to the specified position and enter the insert mode.
  • v: Enter visual mode and select text.
  • :s/<old>/<new>/g<old>: Replace the current line with <new>.
  • :%s/<old>/<new>/g: Replace throughout the file <old>with <new>.

4. Insert mode command

In insert mode, you can enter text. The following are some commonly used commands in insert mode:

  • Esc: Exit Insert mode.
  • Ctrl-h: Delete the character to the left of the cursor.
  • Ctrl-w: Delete the word to the left of the cursor.
  • Ctrl-u: Delete all text in the current line.
  • Ctrl-a: Insert text to the beginning of the line.
  • Ctrl-e: Insert text to the end of the line.
  • Ctrl-t: Insert a tab character.

5. Macro commands

A macro is a method of recording and executing multiple sequences of operations repeatedly. Here are some macro commands:

  • qa: start recording the macro and store it in register a.
  • q: Stop recording the macro.
  • @a: Execute the macro stored in register a.
  • @@: Repeat the last executed macro.

6. Split screen command

Vim can display files in split screens in windows. Here are some split screen commands:

  • :sp: Horizontally split the current window.
  • :vsp: Split the current window vertically.
  • Ctrl-w h: Move the cursor to the left window.
  • Ctrl-w j: Move the cursor to the lower window.
  • Ctrl-w k: Move the cursor to the upper window.
  • Ctrl-w l: Move the cursor to the right window.
  • Ctrl-w +: Increase the height of the current window.
  • Ctrl-w -: Decrease the height of the current window.

7. Multi-file editing command

In Vim, you can edit multiple files. Here are some multi-file editing commands:

  • :e <filename>: Open the specified file.
  • :tabnew <filename>: Open the specified file in a new tab.
  • :tabnext: Switch to the next tab.
  • :tabprev: Switch to the previous tab.
  • :tabclose: Close the current tab.

8. Other commands

Here are some other commonly used Vim commands:

  • :set number: Display the line number.
  • :set nonumber: Hide line numbers.
  • :set expandtab: Use spaces instead of tabs.
  • :set tabstop=4: Set the tab width to 4 characters.
  • :set hlsearch: Highlight the search result.
  • :set nohlsearch: Cancels highlighting of search results.
  • :set background=dark: Sets the background to a dark color.
  • :set background=light: Set the background to a bright color.

Guess you like

Origin blog.csdn.net/bobo789456123/article/details/130958446