lainchan / λ
Is vim worth learning?
Dougie Jones · 2017-10-18 20:17
My fellow Lains, I've been using Ubuntu regularly for almost two years now and I'm seriously considering getting very into Vim. I already the basics and how to use it but I've never seen the use for it. For programming I always prefer an IDE (eclipse for c++/java) but the more and more comfortable I get using the command line, the more and more I want to use it more for programming. So my question is:
Is Vim even worth learning? It has a crazy steep learning curve and it took me a while to get comfortable with just editing a quick line of code in a file. I know there are a lot of wacky plugins, are there ones for predictive text, linters and documentation referencing? These are the things that'd make me really interested in learning in depth about Vim.
Please let me know what ya think!!
sizeof · 2017-10-18 20:34
Depends on what you want to do really. Vim (as well as emacs) can serve perfectly fine as an IDE with the right plugins (syntax highlighting, auto-completion and the like). Not to mention some games (roguelikes and the like) use vi/vim keys by default, so even if you do not end up using vim itself, you will have another control scheme learned.
Personally I learned the basics simply to learn something new and to be able to play roguelikes comfortably. I have run into a few embedded systems in the past that only have vi installed (not even nano) so I had to learn it one way or another anyway. Unfortunately I did not get very deep into it (as I use another editor for programming), so I really could not tell you the details of what exists for programming specifically.
Sipho Nkosi · 2017-10-18 20:41
>>4430
Just use Sublime or Atom in vim mode, the only good thing about vim is the hotkeys. If you try and use vim as your editor you are going to spend ALL your time designing your own custom editor with a mile long .vimrc and configuring various plugins to do what a normal programming editor does out of the box
string · 2017-10-18 22:32
There's certainly no harm in trying it. You should be able to answer this question by yourself.
Trinity · 2017-10-18 23:22
vim's command scheme is really worth learning; it's essentially a higher level language for text editing, and though it's not the best you could possibly get it's still much better than the alternative.
I'm beginning to doubt its usefulness as an IDE. Vimscript is an awful language, and as much I'd like to write plugins of my own I refuse to touch it for anything more than writing a syntax file.
I'm thinking of switching to emacs (with evil or something similar) at some point, but I haven't bothered yet.
Hopper · 2017-10-19 00:36
Vim allows me to be efficient, and it has some pretty neat plugins such as vim-notes and other stuff depending on what you do. It's not as hard as people make it out to be. You can do fine productivity-wise just knowing the very basics which take a few days only to learn, and a week tops to get reasonably comfortable.
Basically if you want a simple, minimal but super efficient and powerful editor / "IDE", then why not! I feel like an inefficient crippleed guy having to use other peoples workflows now.
Joe Bloggs · 2017-10-19 04:53
if vim is as hard as you're making out to you you have more serious problems with your problem solving skills and learning abilities.
Trying not to just make a smug soykafpost with this but it really should not be some kind of challenge to learn how to edit text with vi/m. How to take full advantage of it probably, sure, but just how to use it, no.
Ive never felt the need for addons and apparantly a number of things people typically use addons for can actually just be done with the vanilla version, with vim.
Hagbard Celine · 2017-10-19 11:24
Trying to replicate an IDE experience inside Vim is misguided.
Vim is not a linter and it does not provide documentation lookup. Trying to integrate these features into it will only create frustration. Vim is a text-editor; it edits text, nothing more. Fortunately, it does that extremely well.
Extraneous functionality is provided by other specialised tools bound together by simple shellscripts, this is the kind of workflow for which Vim was intended and where it really shines. The operating system as a whole becomes your IDE.
If, however you do want a whole toolset sharing one environment I can strongly recommend looking at Emacs instead. It can support basically every IDE feature and then some, It even has a very accurate vim emulation mode if you do become attached to that editing style.
As a small warning, writing Java is horrible in basically anything that's not a dedicated IDE for various reasons, so I wouldn't try to force that one.
Jane Doe · 2017-10-19 15:35
>>4451
Syntastic makes writing code in vim a lot easier.
Armitage · 2017-10-19 17:31
It really depends on what you want to do! If you do any coding or edit text, it is worth learning. Here's what I have to say as a loyal vim zealot:
In my experience doing web development and some sysadmin stuff, it's improved my workflow and is a fantastic tool that has increased my productivity. you can move around so quickly and do batch operations very well. On nearly any computer I ssh into, vim (or at least vi) is going to be there.
I also use it for notes. For example, if I'm trying to analyze routing information before and after applying a VPN, I can from inside vim type `:r !sudo router -n` which writes the output of the `sudo router -n` command into the buffer (into the vim window). You can do this for nearly any arbitrary command!
If you want to go farther, you can also use plugins, but personally I stick with vanilla since it has everything I need (and I ssh around enough that I don't want to become dependent on them). That said, I'm assuming there is some value in just using an IDE like vscode since a lot of that functionality is built-in and a rich, easy-to-use plugin system. But vim as been around since 1991 and we're still talking about it, so I think it has some more staying power. It's worth learning.
As for actually learning it, here's my advice:
1. Run "vimtutor" and go through the entire thing. Take notes in a separate text file (using vim!)
2. Use the following .vimrc (`vim ~/.vimrc`): This disabled the crutch that is arrow-key movement. If you have any trouble remembering, just think that the `j` key has the nub on it because it is the most commonly used key: Moving down on the page.
syntax on
" Disable Arrow keys in Escape mode
map <up> <nop>
map <down> <nop>
map <left> <nop>
map <right> <nop>
" Disable Arrow keys in Insert mode
imap <up> <nop>
imap <down> <nop>
imap <left> <nop>
imap <right> <nop> 3. Use vim only. Don't muck around in gedit or notepad or sublime or whatever. JUST USE VIM unless you literally have no choice.
4. If you have to perform some text editing operation like adding a period after 100 lines of varying length, or turning a one-line list of words into a csv, google around and learn the shortcuts. Stack overflow is your friend. If you can't figure it out with google, ask a clear and pointed question in a #vim irc room or on this very thread.
5. Don't worry about ricing your vim install by installing plugins or copying someone's .vimrc. Just add things to your config when the needs arise.
It's really easy to speculate about learning vim or just talking about it on some imageboard, so to achieve functional skills you need to exclusively use it, like jumping into a foreign country to learn the language. Once you learn basic stuff like exiting, saving, and inserting, you can start learning more advanced techniques. It will not be hard to learn like you say in your OP if you follow this advice. Stop thinking about how to learn it and instead just jump in!
Void · 2017-10-19 20:45
>>4446
>problem solving skills and learning abilities.
or they could have trouble getting the muscle memory down.
It just takes a bit of practice.
Tank · 2017-10-19 21:36
Yes 100% https://medium.com/@peterxjang/how-to-learn-vim-a-four-week-plan-cd8b376a9b85
Ivan Petrov · 2017-10-19 22:07
>>4451
And what exactly stops me from using vim as an IDE? The OS is a terrible IDE, nothing works together unless you write lots of hacky awk scripts, the only reason why vim is not often used as an IDE is because it's not as extensible as it could be, and vimscript is a terrible language.
Joey · 2017-10-20 02:09
>>4463
not him but..
build management systems are taking over making IDE's no longer necessary except for ecosystem rich languages like Java, C# and C++
Yet Another Lainon · 2017-10-20 03:31
Use emacs. Vim a soykaf
St. IGNUcius · 2017-10-20 08:02
Vim is absolutely great and worth every second you put into it. Once you learn the standard keybindings, you can absolutely fly through editing text. Ever since I became used to Vim, I actually get a little frustrated using any other editor, but fortunately most IDEs have a Vim mode or Vim plugin that will allow you to use a Vim-like editor within that IDE.
As far as Vim as its own IDE, I've set it up to be an IDE for C recently. There are syntax checking plugins, autocomplete, etc., that make it a breeze, especially when used in conjuction with Makefiles. You can even integrate gdb with Vim. It's fuarrrking fantastic.
Vim also somewhat recently updated its plugin management system so they're a lot easier to install and maintain, as well.
>>4433
>If you try and use vim as your editor you are going to spend ALL your time designing your own custom editor with a mile long .vimrc and configuring various plugins to do what a normal programming editor does out of the box
According to whom? My .vimrc is only 45 lines long (including comments and empty lines)
Naomi Nascimento · 2017-10-20 09:12
>>4470
> I've set it up to be an IDE for C recently. There are syntax checking plugins, autocomplete, etc., that make it a breeze, especially when used in conjuction with Makefiles.
> My .vimrc is only 45 lines long (including comments and empty lines)
I believe you
I'll bet your Mom is so proud she has a 'systems programmer' in the house(Always argue in good faith and avoid using personal attacks.)
Lady 3Jane.. · 2017-10-20 09:26
>>4433
>If you try and use vim as your editor you are going to spend ALL your time designing your own custom editor with a mile long .vimrc
Default Vim is terrible and it does take time and effort to configure Vim to work best for your workflow but if you are planning to write code for the next 30 years then it is a worthwhile investment.
On the other hand if you are "teaching yourself python" on weekends then what you said it 100% correct. You are not the target audience of Vim. But don't project your own needs and incompetence onto everyone else.
JARGON · 2017-10-20 09:29
>>4473
>if you are planning to write code for the next 30 years then it is a worthwhile investment.
Even if you switch languages and platforms half way through your career, you don't need to learn a whole new environment, you can just take Vim with you as is.
John Doe · 2017-10-20 11:42
>>4470
Please share your .vimrc, anon.
Drifter · 2017-10-20 15:39
I never learned vi-style editing because I use a Dvorak keyboard layout.
I did learn ed before using Emacs, though, and ed will almost always certainly be available on a UNIX system in some way, so perhaps learn that instead; it's awful when you use a better editor, but it's not horrible for quick edits, which will be what you use it for most.
Of note, Emacs has a mode that allows it to edit without the files being local, so that's always an option if you find yourself editing remote files often.
⍕ · 2017-10-22 05:03
>>4433
If you don't customize your editor, no matter what it is, you're not using it to its full potential.
>>4451
>Vim is not a linter
You can integrate linters with Neomake, Ale, Syntastic and others.
>it does not provide documentation lookup
It does. :help K will tell you about it.
>>4480
>I never learned vi-style editing because I use a Dvorak keyboard layout.
Different keyboard layouts aren't really a problem, you can use the langmap (:help langmap) feature to get everything working as you wish.
>Emacs has a mode that allows it to edit without the files being local, so that's always an option if you find yourself editing remote files often.
So does vim, with netrw (a plugin that is packaged with vim by default). You can just :edit scp://user@server//path/to/file.text and everything will work as if the file was stored on your computer.
>>4430
Yes, I'd say Vim is worth learning, more as a language to edit text than anything else. Vim has function (d, c, y...) that can be applied to arguments (w, i", a[...). It has for loops (2, 5, 10...) and registers ("+, "1, "a...). You can combine all of this into programs (qqdiwq, qa2Wq...) and combine these programs into bigger ones (qs@q@aq...). This is a really interesting idea and more people should try to understand it.
Dougie Jones · 2017-10-24 00:18
UPDATE! OP here and I started my journey a couple of hours after posting this! I decided on using Neovim instead of Vim and so far so good! The keyboard shortcuts were very confusing at first but as with everything practice makes all the difference! This is what my setup looks like and so far its going as smoothly as any IDE! Thanks for everyone's input!
Delilah · 2017-10-24 04:23
>>4530
I'd recommend giving up on tagbar and nerdtree or whatever these two plugins are. They go against vim philosophy. You can instead use Netrw (enabled by default) if you really want to navigate directories and Denite if what you really want is opening files. You can jump between tags with <C-]>, tselect and others.
swap · 2017-10-24 08:23
>>4532
And who are you to tell that lainon what's against the "vim philosophy"?
Erik Johansson · 2017-10-24 12:21
>>4532
What's the "vim philosophy"? In your own words.
Switch · 2017-10-24 12:50
>>4532
Nobody cares about whatever the hell you think the "vim philosophy" is. Vim is what you make of it, there isn't some underlying philosophy that stops you from doing anything,
McCarthy · 2017-10-24 14:44
>>4477
let g:syntastic_c_checkers = ['make', 'gcc']
set nu
set autoindent
set shiftwidth=1
set tabstop=2
set expandtab
syntax on
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 0
let g:syntastic_loc_list_height=6
""" for ultisnips
" Trigger configuration. Do not use <tab> if you use https://github.com/Valloric/YouCompleteMe.
let g:UltiSnipsExpandTrigger="<tab>"
let g:UltiSnipsJumpForwardTrigger="L"
let g:UltiSnipsJumpBackwardTrigger="H"
" If you want :UltiSnipsEdit to split your window.
let g:UltiSnipsEditSplit="vertical"
"auto complete:
filetype plugin on
set omnifunc=syntaxcomplete#Complete
:inoremap <expr> <CR> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
"<c-n> to use
"to use `:Man 3 printf` and such
runtime! ftplugin/man.vim 39 lines*
Acid Burn · 2017-10-24 20:10
>>4439
You could try using spacemacs, after being a VIM user for about a year, i've switched to spacemacs and it's pretty good. Has a lot of cool features out of the box, you can enable some layers in order for it to do more
nibble · 2017-10-24 22:28
>>4458
Please tell me how you got your DE looking like that!
Eldon Tyrell · 2017-10-25 00:18
>>4548
I downloaded i3 as my WM and fiddled with the color settings a bit to be clean colors, then changed around the .i3status contents. I installed the terminus font and set that as my default font for i3. The windows are "floating" so I can drag them around with a mod key+Lclick-and-drag or mod key+Rclick-and-drag to resize. Usually they're tiled.
I'd highly recommend downloading i3 from your favorite repo since it's really open to customization. Much like vim it encourages customization and efficient use. What I took a scrot of is a mostly default config but I can share the dotfiles if you're interested.
let · 2017-10-25 05:20
>>4535
And who are you to ask me who am I to tell that lainon what's against the vim philosophy? Present Day, Present Time! AHAHAHAHAHA!
>>4536
I don't know, working primarily with keyboard shortcuts instead of a graphical user interface? Seems quite obvious to me, even Gvim is quite minimal as far as GUI go.
>>4537
>there isn't some underlying philosophy that stops you from doing anything
Something being possible doesn't mean it's a good idea.
Miho Iwakura · 2017-10-25 07:38
chords > modes
just make sure to remap your keyboard so alt becomes control and capslock becomes alt
Dougie Jones · 2017-10-26 05:09
>>4532
What exactly is the Vim philosophy if I may ask?
I personally have found tagbar to be extremely useful and nerdtree has also had its uses for me. I see no reason why I shouldn't use them just to uphold some philosophy that I myself am not even aware of.
Dozer · 2017-10-26 16:05
>>4569
Your question was answered in >>4552 .
FILLER · 2017-10-26 16:30
>I've never seen the use for it.
Productivity gain is worth it if you master it, pic related.
Plus it's fun and makes you feel super 1337 for just editing a simple file.
Tomohisa "Tom" Kanezaki · 2017-10-27 13:49
>>4536
Giving your money to starving children in Uganda.
Pulse · 2017-11-02 19:52
>>4430
Is worth learning. Vi/Vim is installed by default in almost every unix so getting to know the basics is mandatory and is extremely useful if you have to edit a config over ssh.
As others have said you can use it for programming too and turn vim into an IDE via plugins.
Personally i use it to edit files and code scripts so my config is quiet simple.
I was reading this the other day so maybe you want to take a look.
>VIM after 15 years
https://statico.github.io/vim3.html
Yuki Nagato · 2017-11-09 17:19
>>4430
I was taught on vim and I really like it, for what that's worth.
Colmerauer · 2017-11-14 07:00
>>4433
>If you try and use vim as your editor you are going to spend ALL your time designing your own custom editor with a mile long .vimrc and configuring various plugins to do what a normal programming editor does out of the box
this is a common... misconception I guess of what I see to be the philosophy behind vi-type editors
here's my .vimrc:
>set cp
>set nu
>set ai
>set sm
>set et
>set ts=4
>set sw=4
>set is
>set nojs
>
>syntax on
>colorscheme ir_black
short enough that on a new machine I can reproduce it from memory if need be. I honestly don't understand people who load up on plugins and such trying to construct an IDE-like experience and tend to think they would be happier with vi keybinds in emacs or a full IDE. the idea of emacs/IDE is that your editor does everything, it is a self-contained workspace that you never have to leave to accomplish whatever task you want to do. the idea of vi is that it is simply a text editor, it does one job and does it well, and everything else is deferred to other individual programs invoked from the shell. unix philosophy sort of thing. this is how I tend to work (and I work with a codebase well over a million lines), relying on sed, grep, find and so on to do a lot of the wrangling I expect emacs integrates into itself. using vim in this way is surely a substandard experience compared to emacs, but using it like a vi is plenty pleasant if that's how you like to work. it's a different style is all
Tank · 2017-11-14 07:02
>>4569
oh I see I gave my view of your question in >>4950 before I saw it
exos · 2017-11-14 13:25
>>4430
> Is Vim even worth learning? It has a crazy steep learning curve and it took me a while to get comfortable with just editing a quick line of code in a file.
I'm using vim about five years ago (I'm programmer) and, yes, really worth to know use vim, I consider using vim for quick changes it's like to be a ninja, you open the file, and in some keys you can to get a fast way to modify source files as a text files.
But I thinks, the real learning curve is about one year, this is the time to dominate the editor.
> I know there are a lot of wacky plugins, are there ones for predictive text, linters and documentation referencing?
There are a lot of shared configurations for dev working, I have the mine[0], with plugins for PHP, Python, JavaScript (Ecmascript) and a look and feel based on utf8 icons, but I don't recommend it because I still don't write the documentatio :P.
But, there are a lot of configurations.
[0]: https://github.com/exos/perfect.vim/blob/develop/.vimrc
p.s. sorry my poor english
:wq!
HELIOS · 2017-11-14 17:46
>>4950
If you don't use plugins you don't use vim at its full potential.
Here are a few plugins that merge into vim so well that you wouldn't be able to tell they weren't there from the start if they started being packaged with vim:
https://github.com/chrisbra/Recover.vim
https://github.com/tommcdo/vim-exchange
https://github.com/tpope/vim-commentary.git
https://github.com/tpope/vim-repeat
https://github.com/tpope/vim-surround
https://github.com/wellle/targets.vim
https://github.com/kana/vim-textobj-user
https://github.com/thinca/vim-textobj-between
https://github.com/glts/vim-textobj-comment
https://github.com/jceb/vim-textobj-uri
https://github.com/kana/vim-textobj-line
https://github.com/kana/vim-textobj-entire
https://github.com/rbonvall/vim-textobj-latex
https://github.com/ludovicchabant/vim-gutentags
Undisclosed · 2017-11-15 04:53
>>4964
>:wq!
:x will do the same thing.
Drano · 2017-11-18 18:07
>>4695
>is extremely useful if you have to edit a config over ssh
This. It doesn't happen very often or at all depending on what you do, but sometimes you'll find yourself working on a machine that doesn't even have nano, but has vi. It has happened to me working on a Knight's Corner; of course you can work around it by editing on your local host and then using scp or rsync but it's unwieldy.
For normal development I also prefer either a feature-rich IDE or a simple GUI text editor like textadept.