9 ms·
Vim 101: How to Start Using the Text Editor for Developers
- phosphophyllite 7y agoVim is great thing to learn and then go use other text editors.
- wolfhumble 7y agoNice introduction to Vim! Using bash/zsh extensively, and Vim a few times a day, I have been wondering if people treat bash/zsh and Vim as two different worlds when it comes to keybindings, or is it common to use Vi/m keybindings in bash/zsh/other shells? Would love to hear some input on this! :-)
- lsiebert 7y agoI use vi key bindings in bash and in tmux for that matter.
- intarga 7y ago“set -o vi” will give you vim bindings in bash
- wolfhumble 7y agoYes, and thanks! In this case I was actually trying to understand how people in general try to combine the two tools. Keeping them separate, or using one keybinding for both! :-)
- Antoninus 7y agoIf you don't have fkeys bound `$ vimtutor` works too. *I have never used them on osx and use a 50% keyboard.
- toastal 7y agoFor fish run (or store in config.fish) `fish_vi_key_bindings`
- itomato 7y agoThey are two different worlds. GNU readline enforces the keys you might identify with Emacs and other GNU components that make their way into your GNU/Linux distro bundle. https://www.gnu.org/software/bash/manual/html_node/Readline-vi-Mode.html https://www.gnu.org/software/bash/manual/html_node/Readline-... I've toyed with taking what suckless have done with their libs and implement some alternatives (people still gripe about missing CP/M (DOS) shortcuts)
- zwolbers 7y agoPersonally, I have vi mode enabled for anything that uses readline. Some of my friends, though, have been reluctant to use it since the prompt doesn't indicate which mode it's currently in. But... That changed with recent versions of readline, which introduced 'show-mode-in-prompt' [0]. It's somewhat limited - it only prints an indicator at the beginning of the last row of the prompt. You can, however, change what text is displayed. I use it to emit escape codes that change the shape of the cursor (similar to vim itself) [1]. [0] https://www.gnu.org/software/bash/manual/html_node/Readline-Init-File-Syntax.html#index-show_002dmode_002din_002dprompt https://www.gnu.org/software/bash/manual/html_node/Readline-... [1] https://wiki.archlinux.org/index.php/Readline#Editing_mode https://wiki.archlinux.org/index.php/Readline#Editing_mode
- megous 7y agoI started by typing vim into the terminal and then followed the instructions. All you basically need to do at the beginning is press F1 as instructed and just read. There's a very nice tutorial included with vim. :)
- ryannevius 7y agoEmphatically, this. I struggled to really understand and become comfortable with vim until I actually (1) completed the tutorial (vimtutor), (2) read the manual (:help user-manual), and (3) learned to use :help. If I would have just read the splash screen instead of browsing intro/intermediate-level vim articles online, I would have saved a lot of time in the long run. As an aside, vim has really had a positive impact on my life (no hyperbole). It's the only editor I've ever used where I can regularly reach a state of "flow" during my day. I highly recommend giving it a try beyond learning hjkl, if you haven't already.
- romanovcode 7y agoSo iconic that the picture is with a guy in a coffee-shop using a mac. It seems that the only people I see using VIM are those kind of people.
- coldtea 7y agoThat could just be your bias and/or the fact that Mac users are the most numerous UNIX users (10x those that use e.g. Linux on any kind of desktop/laptop). Tons of Linux users use Vim -- and Vim/vi of course has been popular for decades before Macbooks existed...
- collyw 7y ago> (10x those that use e.g. Linux on any kind of desktop/laptop). How many of those Mac users actually "using Unix" in any meaningful sense? Any more than Android users are Linux users?
- coldtea 7y agoEnough, considering that group shots of CS departments, programming conferences, hackathons, etc, are always like 50% or more Mac or so (at least in the west) SXSW hackathon: https://www.sxsw.com/wp-content/uploads/2019/06/2019-Hackathon-Photo-by-Randy-and-Jackie-Smith.jpg https://www.sxsw.com/wp-content/uploads/2019/06/2019-Hackath... TC hackathon: https://techcrunch.com/wp-content/uploads/2011/05/tcdisrupt_tc-9.jpg?w=1390&crop=1 https://techcrunch.com/wp-content/uploads/2011/05/tcdisrupt_... https://techcrunch.com/wp-content/uploads/2019/03/27478205537_84c9d8b450_k.jpg?w=730&crop=1 https://techcrunch.com/wp-content/uploads/2019/03/2747820553... Haskell (!) conference: https://miro.medium.com/max/1200/1*D8GHt8dceOWwQp0HljYqXg.jpeg https://miro.medium.com/max/1200/1*D8GHt8dceOWwQp0HljYqXg.jp... MIT student startup program: https://www.3daystartup.org/wp-content/uploads/2013/01/3dsmit1.jpg?w=640 https://www.3daystartup.org/wp-content/uploads/2013/01/3dsmi...
- collyw 7y agoI still see the majority of Mac owners as owning it as a status symbol rather than for the fact it has Unix. Most Mac users are not techies.
- mxschumacher 7y agoIn the conclusion the author says "It may not replace an IDE if you’re coding in Java or C++, especially if you’re using Frameworks and auto-complete is helping you." You don't have to make that choice and can have "the best of both worlds": For the last few years I've not been using Vim itself, but Vim bindings in VSCode and Intellj. I enjoy the trade-off of this this approach because it - is trivial to set up (in stark contrast to configuring a untouched Vim/Nvim install from the ground up) - gives me simple access to powerful extensions - allows me to use modern editor/IDE features (find usage, refactor) without forgoing "the essence of Vim", rapid code editing through the combination of motions & commands
- keithnz 7y agoother than a notepad replacement, I don't really use Vim. But I do use VsVim in Visual Studio and also have a guide on how to do that with R#, I use Vim emulation in all the Jetbrains products as it's really well done, also in VSCode, Vimium in all my browsers. Also use AutoHotKey to add Vimish type navigation to windows controls.
- mxschumacher 7y agoFor me it's i3 as a linux desktop wm that uses Vim bindings - really handy. Agree on Vimium in Chrome - I have to check whether it's available on Firefox. I've never heard of R# (and it's hard to Google) - what is it?
- StreakyCobra 7y agoFor firefox I am using https://github.com/ueokande/vim-vixen https://github.com/ueokande/vim-vixen
- bovine3dom 7y agoVimium is available for Firefox [1]. There are actually quite a few others too: Saka-key, Surfingkeys, Vim-Vixen (as a sibling has mentioned), VVimpulation and, last-but-most-janky, Tridactyl [2]. It'd be remiss of me not to mention Qutebrowser which is a standalone affair. [1]: https://addons.mozilla.org/en-GB/firefox/addon/vimium-ff/ https://addons.mozilla.org/en-GB/firefox/addon/vimium-ff/ [2]: I can slag Tridactyl off as I wrote a lot of it. It's still my favourite one.
- jasode 7y ago>To navigate a file on Vim, use the letters h,j,k, and l.These commands are called motions, as they move the cursor. The keys h and l will move your cursor horizontally (one character at a time), while j and k move vertically (one line at a time). If you put your hand on them, the layout sorta makes sense. The way the author explains it above (mechanical) is the way I was initially taught over 20 years ago. However, it wasn't effective for my learning style because it felt random and incoherent. So _why_ does 'h' key move left? And _why_ do I have to press 'i' for "insert" mode when I didn't have to do that in Notepad/MSWord? My UNIX instructor couldn't answer those questions. He just said, "I dunno, it's just the way it is." As a sysadmin, I memorized it but it was a very unsatisfying way to learn vi. My brain is most receptive to learning when it knows the underlying philosophy of why things are designed the way they are. Previous comment with some links.[0] Once one knows the design intentions behind vi, the learning feels much less random. [0] https://news.ycombinator.com/item?id=20605840 https://news.ycombinator.com/item?id=20605840
- celticmusic 7y agoThe other problem is that he doesn't have a sample.txt file for people to download, so he's asking them to open a blank file, then he teaches them how to move around (but there is no text), and only after all that does he start teaching them how to actually insert text.
- Torwald 7y agoThe title is misleading. The "text editor for developers" should point to an article about Emacs.
- dunefox 7y agoWhat's better than Vim? Vim and Emacs: http://spacemacs.org/ http://spacemacs.org/ (use the dev branch)
- bloopernova 7y agoWhen I first started using Spacemacs, I wished that the Emacs instance had been trimmed down to the bare minimum. That way I could have more easily mapped my Vim knowledge onto Spacemacs without getting confused/distracted by the multitude of extra features and tools Emacs gives you. I was wondering were that method were to be paired with a tutorial, if that would help ease people into Spacemacs/Emacs more. In other words, each step or lesson in the tutorial enables a new feature and explores it. So perhaps start with basic text editing, saving, opening, recently used files etc. Then add something like git or magit, and explore how that is used, then explore how the git and editing interact. Each new feature discussed would be like adding a new layer to the ~/.spacemacs file.
- the_duke 7y agoI used Spacemacs and then Emacs + Evil for a while. My biggest problem is that it is SLOW. Emacs, even without the Spacemacs bloat, would regularly freeze up on me or feel slow and a bit sluggish. My main reason for sticking with (neo)vim over Jetrains IDEs or VS Code is the incredible responsiveness. Thanks to Coc et al we now get awesome IDE features too, and Vim is easy enough to customize. (though not as much as Emacs, obviously) .
- bloopernova 7y agoI agree, and I think I've kind of trained myself to ignore it for the most part. Of course, this sets my ADD-addled brain off down a path of wanting to chase down every optimization for my ~/.spacemacs - thank you for that :P VSCode is great and responsive locally on this macbook pro, and running locally on Windows 10 with a directory open in WSL is also very snappy. Unfortunately some of my work has to be conducted in an Amazon Workspace, which is so slow sometimes as to be unusable. So frustrating, and apropos of nothing, just wanted to rant!
- 7y ago
- shrumm 7y agoA major use case this articles misses is having to manipulate files on a remote server. When you’re SSH’ing into your server, VIM is incredibly efficient to make quick edits.
- mxschumacher 7y agoWhen running large production systems in the cloud, is quick fiddling with files via SSH really such a common occurrence in 2019?
- meddlepal 7y agoMaking permanent edits? No. For debugging a b0rked system, yes. Unfortunately not every system is always optimally monitored if there are lots of teams so you sometimes need to get to the [Virtual]Machine and poke around.
- freeplay 7y agoYou try not to but sometimes when stuff is on fire, you have no choice. Making a change to your cookbook/playbook/Dockerfile/<insert other automation verbage>, submitting a PR, waiting on a new build and deploying doesn't always cut it time wise. Once in a while you need to just get in, make the change, and backfill the code changes in your build pipeline.
- itomato 7y agoUntil such a time as SystemD or Docker replace the standard shell.
- scarecrowbob 7y agoEvery freekin day. I do a lot of WordPress hosting for large-ish non-software clients running one-off webservers that were setup by who knows years ago. I certainly can and have automated stuff... but when I get a client who already has hosting setup, they just want me to manage it, not rebuild it. As a sibling comment mentions, a lot of that is troubleshooting... But making changes to stuff in /etc is an extremely common case where I just ssh in and use vim. None of these clients have documentation on how the server was setup, much less any sort of way to set one up automatically. So there is a lot of "hey, can you up the max_file_upload for PHP" or "add a link to the hard-coded footer menu in our Drupal install". And even when they want me to setup new stuff, they prefer me to just deploy a new instance and give them notes on whatever I do to it. Since these are 1-off things (like a server running some video conferencing or file management), there's not a lot of utility in build a script in BASH or ansible or whatever to build the server. I'm a dev and the only one at the buisness where I work, so I'd be stoked to hear about some better way of doing work. But really, spending time in an SSH and configin stuff with vim seems like the fast, lightweight path for most of the work I do.
- m23khan 7y agovim is definitely a great tool especially when you are editing/developing/viewing scripts within Linux. However, as soon as you start writing anything beyond one-file scripts, better move over to proper IDE, IMHO.
- drbojingle 7y agoI disagree with your last sentence. I use vim exclusively. Granted, I don't use vanilla vim very often so I'm with you on the proper IDE functionality, but I disagree on what the proper IDE is :P.
- erfgh 7y agovim has literally hundreds of features that deal with working with multiple files
- schwurb 7y agoNo need to give up on your favorite text editor: Spacemacs offers all the amazing IDE capabilities (Vimscript is simply a bad language compared to elisp) while still being one of the best VI-emulators around.
- cloudking 7y agoMuch prefer JOE https://joe-editor.sourceforge.io/ https://joe-editor.sourceforge.io/
- pedrorijo91 7y agoI miss a good tutorial on vim plugins :) still not trivial to explain to new comers how to use plugins they find on github for instance
- movieswebsite 7y agoGreat you tell me the information https://tezmovieswebsite.blogspot.com/2019/10/love-sex-aur-dhokha-2019-full-movie.html https://tezmovieswebsite.blogspot.com/2019/10/love-sex-aur-d...
- thekingofh 7y ago[I ... it will change your life. also [ CTRL-I and it's siblings N[ CTRL-I I rarely even use tags any more.
- fedemar 7y agoWhat does it do?
- imjasonmiller 7y agoAccording to the documentation: :help [I > Display all lines that contain the keyword under the cursor. Filenames and line numbers are displayed for the found lines. The search starts at the beginning of the file. :help [_CTRL-I > Jump to the first line that contains the keyword under the cursor. Both "] I" and "] CTRL-I" will start at the current cursor position instead. I did not know about these, but now I am wondering how to reverse "] CTRL-I" and go to the previous result, as it seems quite useful.
- thekingofh 7y agoThe key is that it recursively searches (for instance in C++) header files for the word under the cursor and brings you to the first result. To go backward 'CTRL-O' jumps back in the jump list. I've not yet found a way to go to the next item in the '] CTRL-I' list. so I 'CTRL-O' then '2 [ CTRL-I', etc.
- ainiriand 7y agoRelevant: https://vim-adventures.com/ https://vim-adventures.com/
- sebringj 7y agoI have to routinely use VIM for SSH related in command lines and am pretty comfortable but in no way does it compare to VSCode with the small exception use case that happens to be quite common of hop-in and hop-out of quick changes. Vim shines there. It is just so light weight and quick for that.
- ojuara 7y agoBtw, I just started reading SICP. How can I use Vim with Lisp code instead of Emacs? Because I did see people telling across the web that I should use Emacs for lisp code.
- numbers 7y agoUse what you're comfortable using, learning new concepts and a new editor will slow you down and frustrate you.
- iimblack 7y agoAssuming you're using Racket to go through the book: * https://crash.net.nz/posts/2014/08/configuring-vim-for-sicp/ https://crash.net.nz/posts/2014/08/configuring-vim-for-sicp/ * https://docs.racket-lang.org/guide/Vim.html https://docs.racket-lang.org/guide/Vim.html
- thosakwe 7y agoIMO, the most important Vim keystrokes for editing code are: * %, which lets you hop back and forth between ()/{} pairs. Extremely useful when working with, say, Flutter. * F/f/T/t (and ;/,), which let you jump to a specific character in the line, ahead or behind. This greatly sped me up, as I no longer needed to count out "okay, hop 16 characters to the left." Also, another important thing is that Vim makes editing fast, not necessarily writing. There's not really much you can do to make writing faster in the first place, as you eventually have to type anything you write at least once in some form. But for editing, boy, is it great. EDIT: Attempt to fix god-awful formatting
- jchw 7y ago> There's not really much you can do to make writing faster in the first place, as you eventually have to type anything you write at least once in some form. Well, that depends. It’s quite a bit like compression. If you are doing something repetitive, which unfortunately is still necessary in some conditions for good reasons, Vim is good at this (and so are most other modern code editors; multiple cursors are surprisingly powerful.) On the other hand you can always invent a shorthand. A popularized example would be emmet for writing XML, which is supported via plugin in most code editors.