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

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

本站已经建立2462天!

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