Ever been stuck in the terminal for not including a message when committing? Can't get out by pressing esc
or q
. Seriously had to google how to exit vim or nano every time.
Madness? This is a top-of-the-line text editor!
The most confusing part of vim to me was the modes. What's the point of all these modes? Well, after a lot of research, I found my answer. Now bear with me here, I'm still new to coding, so every time I hear of a keyboard shortcut I get excited. It's like finding hidden treasure. And you know those coders that are so good their hands never leave the keyboard to touch the mouse? They are like grand master coders to me. Well, with these text editors, the mouse doesn't exist. There is no scrolling up and down and clicking on a word with the mouse. So how does one move around? With the keyboard. For example, the letters h
, j
, k
& l
are used to move left, down, up & right. What if I need to type using those letters? Switch modes, normal mode is the movement mode, and insert mode is for typing. This is how one keeps their hands off the mouse or the arrow keys, for the most part. Now when first starting, like I am, being restricted to only these few commands along with a few others I learned on :Tutor
from nvim keeps me pretty slow. Kind've like how I started learning to code with var. Now, I can't even remember the last time I actually used var. Whenever I come across var, I'm like, 'what's this?'.
List of basic moment commands
move around =
h
- left,j
- down,k
- up,l
- righthope forward by word =
w
hope backwards by a word =
b
jump to the beginning of line =
SHIFT I
jump to the end of line =
SHIFT A
-
search for word =
/
(equivalent toCTRL F
)- jump through results =
n
or backwardsSHIFT N
- jump through results =
List of basic editing commands
insert before the cursor =
i
insert after the cursor =
a
add line below and enter insert mode =
o
add line above and enter insert mode =
SHIFT O
copy/yank a word =
y
copy/yank line =
yy
paste line one line below =
p
delete character =
x
delete line =
dd
(goes to same register as yank command)undo last command =
u
exit to normal mode =
Esc
||CTRL [
Enter Visual Mode =
v
highlight a word =
w
highlight line below =
j
delete current word and forward =
dw
delete current line plus one down =
dj
yank word =
yw
yank current line plus one down =
yj
help with specific word =
:help <topic>
or:helpgrep <topic>
Now my first interaction with vim, back when I forgot to commit a message, I saw a plain, boring editor. No colors or special fonts. Well, vim is the most powerful when it's stripped of all those things that make it pretty. But vim is very customizable, just not easy to do. So here's where neovim comes to the rescue.
Not only are there so many configurations for neovim, but it's easier to configure.
Just like with learning any new language, it's best to start with the basics. I started with :Tutor
with neovim. There's also vimtutor
from vim, which says it's only 20 minutes. Neovim's tutor took me longer than 20 minutes, but it doesn't have colors. Vim's tutor vimtutor
looks like it might be shorter.
Sources
Top comments (0)