this post was submitted on 21 Jul 2023
144 points (100.0% liked)
Linux
48376 readers
1060 users here now
From Wikipedia, the free encyclopedia
Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).
Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.
Rules
- Posts must be relevant to operating systems running the Linux kernel. GNU/Linux or otherwise.
- No misinformation
- No NSFW content
- No hate speech, bigotry, etc
Related Communities
Community icon by Alpár-Etele Méder, licensed under CC BY 3.0
founded 5 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
Like many others I also use NeoVim, but it was quite a bit of learning curve before you get comfortable with it. And you really have to go all in and learn at least the basics, if you try to use it like a normal text editor thinking you'll learn commands as you go along then you're going to hate it.
In addition to having to learn how to use vim, you also need a good configuration and probably some plugins if you want to use it as an IDE. Personally I use fzf, coc, vim-dirvish, lightline, lightline-bufferline and papercolor-theme.
How long did it take you to get comfortable with NeoVim? I like the proposition of the vi/vim approach of no mouse. But it is really intimidating to get into.
I guess a few hours until I had memorised basic stuff like moving around, copy-paste, etc. Then maybe a week or two before I really felt comfortable with it. There's some point where you actually understand vim and start using it more like a programming language and less like a traditional text editor. For example I love the "repeat last command" (default bound to . key), but to use it effectively you need to create a command that will be usable everywhere you want it to, and there are many different commands that do the same thing.
Here's a random example:
Let's say you have the following text in a document you're editing with vim, and you want to delete the word "dance". Vim is currently in normal mode, and with the cursor placed on the highlighted "c":
If your brain is still in Notepad.exe mode, you might achieve this by pressing "i" to go into insert mode and using a combination of backspace and delete to edit the line.
A vim beginner might know that "x" and "X" in normal mode works like delete and backspace, without going to insert mode, so "XXXxx" does the same.
Someone who has learned basic movement could instead solve this by combining two commands, first "b" to move the cursor back to the beginning of the word, followed by "dw" (delete to next word).
But there's also a single command that deletes the current word, regardless of where the cursor is in it, which is "daw". And since this is a single command, you can repeat it with the "." key to delete a different word.
Now here comes the vim magic: If you instead want to replace the word "dance" with "pool" you just modify the above commands by replacing "d" (delete) with "c" (change). So in our example you could type "caw" in normal mode, which deletes the word under the cursor and places you in insert mode. There you write "pool" and press Escape to go back to normal mode. Now you have a single command that replaces any word under the cursor with the word pool, which you can repeat anywhere you like.
And if it's not just the current word you want to change, then replace the "w" in the command with something else, for example "ca)" will change a pair of parenthesis and everything inside them, which is very useful when programming C/C++/etc.. And if you have nested parentheses and want do something with two levels at the same time, the command becomes "c2a)" which might look complicated, but it's basically just simple rules that you string together.
https://vim-adventures.com/ might be a fun way to get started, then look up some nice vim cheat sheet and keep that nearby. I would also recommend looking up some example vim configs, because the editor is very bare bones with the defaults. I like relative line numbers for easy jumping between lines, so give that a try.
When you've mastered (?) vim you'll also see less (the program) keyboard shortcuts make a lot more sense. You can also change your shell to vi mode for faster editing of commands.
I will look into vim adventures. Trying to learn Vim at the same time as learning everything else is hard. So hopefully, a Vim game will be more palatable.
Run the command
vimtutor
in your terminal