How to use vim in the terminal?

前端 未结 4 1417
遥遥无期
遥遥无期 2020-12-12 10:20

How does one setup and start using vim in the terminal on OS X?

I want to start writing my C code using vim in the terminal rather than a separate text editor. How d

4条回答
  •  遥遥无期
    2020-12-12 11:11

    if you want to open all your .cpp files with one command, and have the window split in as many tiles as opened files, you can use:

    vim -o $(find name ".cpp")
    

    if you want to include a template in the place you are, you can use:

    :r ~/myHeaderTemplate 
    

    will import the file "myHeaderTemplate in the place the cursor was before starting the command.

    you can conversely select visually some code and save it to a file

    1. select visually,
    2. add w ~/myPartialfile.txt

    when you select visualy, after type ":" in order to enter a command, you'll see "'<,'>" appear after the ":"

    '<,'>w ~/myfile $
    

    ^ if you add "~/myfile" to the command, the selected part of the file will be saved to myfile.

    if you're editing a file an want to copy it :

    :saveas newFileWithNewName 
    

提交回复
热议问题