1

How to use Vim from -10

Fernando
fezjqn
15455

Vim -10

Before to start we have to see the learning curve have Vim.
curve_vim.png
This is not meant to demotivate you, is for know Vim is gonna be hard. And you have to love the challenge. At the start, you have to learn a lot and practice a lot. But once you get the hang of it, you can edit text without thinking about it. In flow


First press in your keyboard Ctrl + Alt + t
Now it’s time to install Vim if you are in ubuntu try this command

sudo apt install vim

if you don’t know you have vim put this in your terminal

vim --version

Have to appear you something like that:
much-text.png
If you see very much text is because you have it. After to confirm you have it let’s continue

Vim 0

Open vim just typing vim in your terminal/console
Let’s start with the initial commands
begin.png

Normally when you start to use Vim you see something like this, you don’t know what to do, search in google how to close vim and your frustrating, but to be honest vim no is too hard like others say.

Vim 1

Now let’s press i
zero-to-one-edit.jpg
Like you see is a Insert on the down, that’s mean you can write freely you want. Exist 3 modes in Vim, Visual mode, Insert mode and Normal Mode. You pass to Normal mode into -> Insert mode.
If you wan’t to come back press esc


Now you know the basis in vim it’s time to move it in Normal Mode if you are in Insert mode press esc and follow these:
h: move left
j: down
k: up
l: right
If you want to save your file follow this table:


CommandFunction
vimOpens the specified file. If it doesn’t exist, it creates it
:qCloses the editor
:wSaves the changes
/[busqueda]Searches within the text
ddIn normal mode, selects a line and deletes it

You learned Moving 🗸 delete🗸, quit🗸 and save 🗹

I give you some tips, depend very much the utilities your gonna use vim for replace vscode, or edit content, use it like replace bash is in your choice and for what you like it. 👍

Record actions
The command q can record what you do, e.g. 3w, for stop it press again q is very useful if you wanna save a specific command you can reproduce it like @a or any letter from a to z.
recording-edit.jpg

Move at the start and at the end of the file
The command gg put you in the start of your file is very useful. And the command shift + g put you in the end

Other movements
If you wanna move faster you can press w or b
w: move you in the first letter of a word in the next line ->
b: move you in the first letter of a word in the before line <-
See it like this w is left and b is right
You are starting so you can see it like this

Paste the last deleted or copied text.
Normal mode

  • u: Undo the last action. (ctrl + z)
  • ctrl+r: Redo anything that was undo. (ctrl + shift + z)

Saving and Quitting:

  • :wq + Enter: Save and quit.

Searching and Replacing:

  • / starts searching from your current cursor position and goes downward, moving toward the end of the document. It searches from the cursor position to the end of the file.
  • ? starts searching from your current cursor position and goes upward, moving toward the beginning of the document. It searches from the cursor position to the beginning of the file.

So, / is used for forward searching (from the cursor towards the end of the document), while ? is used for backward searching (from the cursor towards the beginning of the document). This allows you to search in both directions within your document, depending on your needs.

Copying and Pasting (Visual Mode):

  • v: Enter Visual mode (for selecting text).
  • Use movement keys to select text.
  • y: Yank (copy) the selected text.
  • p: Paste the copied text.

If you want to practice more, there are some resources that can help you. For example, you can check out Vim script, Vim tutorial and Opensource. Remember, try to use Vim all the time, even for commands like sudo apt update. You can do this in Vim by pressing :! sudo apt update. You can also become root by typing :! su root`. Learning Vim is like acquiring another language if you want to become fluent, you need immersion yourself in it.

Escribe tu comentario
+ 2