Skip to content

renmiamu/CS219_Advanced_Programming_Project

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

52 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Building Your Vim-like Text Editor

Hongli SHEN && Ximing ZHENG

Description

This project initializes the core functionalities of Vim on a Linux system using C++. It leverages <ncurses.h> to enhance its usability and interface.

  • Basic parts
    • Normal mode: file and mode commands, cursor movement, line navigation, basic editing.
    • Insert mode: direct text insertion, new line creation, backspace support, real-time display update, cursor movement with typed text, exit to normal mode.
  • Bonus parts
    • undo and redo
    • line numbers and jumping
    • Search and replace
    • switch through multiple files by command line, as well as editing them simultaneously
    • UI improvements:
      • better color
      • mode display
      • background color change
      • warning messages display
      • words underline
      • font bold

Contributions

  • Hongli SHEN: Basic parts without overflow content, undo and redo, line numbers and jumping, background color, document.
  • Ximing ZHENG: bug fixed, overflow content, background color change, search and replace, warning display, switch through multiple files, simultaneously editing, words underline, font bold.

Project structure

CS219_Advanced_Programming_Project/                # The root directory
├── build/                       # Build directory containing intermediate and binary files
│   ├── CMakeFiles/              # Auxiliary files generated by CMake
│   ├── cmake_install.cmake      # CMake installation configuration file
│   ├── CMakeCache.txt           # CMake cache file
│   ├── Makefile                 # Makefile generated by the build tool
│   └── MiniVim                  # The compiled executable file
│
├── files/                       # files to edit, containing .txt files
│
├── include/                     # Header file directory for storing declarations
│   └── MiniVim.h                # Header file for the MiniVim module
│
├── src/                         # Source code directory for implementation files
│   └── MiniVim.cpp              # Implementation file for the MiniVim module
│
├── CMakeLists.txt               # CMake build configuration file for defining build rules
├── main.cpp                     # Entry point of the program
├── README.md                    # Documentation providing an overview and usage instructions for the project

The project initialize the vim functions through a C++ class MiniVim. It include a head file <ncurses.h> for terminal-based capabilities. http://tldp.org/HOWTO/NCURSES-Programming-HOWTO

Usage

Build

mkdir build             #create a build folder
cd build                #change directory to build
cmake ..
make

./minivim               #run the program

Should work for Linux.

Choose file

you need to input a file name to enter the specific file.

#example: suppose you want to enter a file named text.txt
text                    

Arguments

We start with normal mode when enter mini-vim.

Normal mode

  • h,j,k,l: move the cursor(left,down,up,right)
  • Arrow keys to move the cursor
  • 0: jump the cursor to the beginning of the current line
  • $: jump the cursor to the end of the current line
  • gg: move the cursor to the first line at the beginning
  • G: move the cursor to the last line at the beginning
  • dd: delete the current line
  • yy: copy the line
  • p: paste the copied line below the cursor
  • u for undo and Ctrl+R for redo
  • i: move to the insert mode
  • Ctrl+B: font bold
  • Ctrl+U: words underline

Insert mode

  • type characters for insertion
  • enter: create a new line
  • backspace: delete characters
  • move cursor operations are the same as in normal mode
  • esc: exit to normal mode

we press : to enter command line mode when we are in the normal mode.

command line mode

  • :q: exit the program
  • :w: save the file
  • :wq: save the file and enter the program
  • :+number: jump the cursor to the specific line at the beginning
  • :background: change background color (light and black)
  • :cd/file_name: change directory to another file
  • s/old/new: replace the first old word in the current line to new words
  • s/old/new/g: replace all the old words in the file to new words

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors