EADST

Basic Vim Commands

Vim is a powerful text editor with numerous commands. Here's a short guide to help you with basic commands, including how to find and replace text.

1. Opening a File

To open a file in Vim, use:

vim filename

2. Switching Between Modes

  • Insert Mode: Press i to start editing.
  • Normal Mode: Press Esc to stop editing and run commands.

3. Saving and Exiting

  • Save changes and exit:
    :wq
    
  • Exit without saving:
    :q!
    

4. Basic Navigation

  • Use arrow keys or:
  • h (left), j (down), k (up), l (right)

5. Deleting Text

  • Delete a character: x
  • Delete a line: dd

6. Finding Text

To search for a word in Vim: - Forward search (down the document):

/word
Use n to jump to the next match and N for the previous match.

  • Backward search (up the document):
    ?word
    
    Similarly, use n and N to navigate.

7. Replacing Text

To replace text, Vim has a powerful substitute command: - Replace within the current line:

:s/old/new
This replaces the first occurrence of old with new on the current line.

  • Replace all occurrences in the current line:

    :s/old/new/g
    

  • Replace in the entire file:

    :%s/old/new/g
    

  • Replace all occurrences with confirmation:

    :%s/old/new/gc
    
    Vim will prompt you to confirm each replacement with y (yes) or n (no).

These commands will help you efficiently find, replace, and edit text in Vim. Happy editing!

相关标签
About Me
XD
Goals determine what you are going to be.
Category
标签云
uwsgi Freesound COCO Tracking 阿里云 FP32 LeetCode CLAP Attention 顶会 算法题 搞笑 Web 证件照 Color NLP PyTorch Claude WAN JSON Search GGML Firewall Disk Land Video tqdm InvalidArgumentError YOLO LoRA BTC scipy Dataset Hilton 报税 Review NameSilo Jetson EXCEL Quantization GoogLeNet SQLite logger CV OCR OpenAI 强化学习 Cloudreve FastAPI News Knowledge Algorithm Markdown BeautifulSoup GPT4 Tensor ChatGPT Translation Transformers PDF GIT SVR Conda Data 飞书 SPIE Agent Vmess Qwen2 Baidu Windows CUDA 净利润 Pillow IndexTTS2 SAM DeepStream VSCode Website git DeepSeek UI NLTK Paper Michelin Input Bipartite Domain Augmentation mmap torchinfo GPTQ Streamlit HaggingFace 云服务器 Math Statistics Gemma Breakpoint Hotel Bitcoin Qwen Django Hungarian PIP Nginx Sklearn Shortcut TSV Excel Permission Quantize Animate Bert Linux PyCharm Tiktoken VGG-16 Heatmap Bin Magnet diffusers Llama Plate LaTeX AI C++ Vim XML LLAMA FP64 Ptyhon Image2Text 图形思考法 继承 公式 HuggingFace Pytorch transformers v2ray API TensorFlow Proxy Pickle FlashAttention Python Logo uWSGI Password hf 多进程 ModelScope QWEN TTS 版权 Miniforge CSV Paddle Use Mixtral PDB SQL printf Qwen2.5 Github ResNet-50 FP16 TensorRT UNIX CAM Plotly CC 多线程 Safetensors 腾讯云 Clash WebCrawler Datetime tar FP8 llama.cpp Template 第一性原理 Distillation Base64 VPN XGBoost Diagram BF16 Google v0.dev 财报 ONNX Food Docker CTC Card Interview Crawler git-lfs Pandas Numpy Jupyter OpenCV LLM 音频 域名 Anaconda 递归学习法 Git Zip MD5 关于博主 签证 Random CEIR RGB RAR Ubuntu
站点统计

本站现有博文321篇,共被浏览763973

本站已经建立2440天!

热门文章
文章归档
回到顶部