6 ms·
A Vim Tutorial and Primer
- plg 13y agoIs there anything like org-mode (emacs) with vim?
- phowat 13y agoAlthough I haven't tried myself, I've heard good things about VimOrganizer: https://github.com/hsitz/VimOrganizer https://github.com/hsitz/VimOrganizer
- MWinther 13y agofor someone like me, who is familiar with vim, but not-so-familiar with emacs, it would help if you would specify which features you are looking for more specifically. My guess would be that if the features you want are available, they might not be packaged in the same way, so listing some key features might get you more answers.
- jbeja 13y agoWhy don't you try Emacs with Evil-mode (all the power of emacs with vim key-bindings). I have made change an never look back.
- MetaCosm 13y agoDo you happen to know of a cross-platform fuzzy finder for emacs? Bonus points if it can also fuzzy-find over tags.
- jbeja 13y agoThere is: ido-flex: https://github.com/vic/ido-better-flex https://github.com/vic/ido-better-flex. ido-verical mode (just to make ido to display results in a column instead a row): https://github.com/gempesaw/ido-vertical-mode.el https://github.com/gempesaw/ido-vertical-mode.el. Simp.el, that act like sublime text fuzzyfinder : https://github.com/re5et/simp.Also https://github.com/re5et/simp.Also is good to read this post about it: http://ck.kennt-wayne.de/2012/aug/find-project-file-with-fuzzy-matching-in-emacs http://ck.kennt-wayne.de/2012/aug/find-project-file-with-fuz.... And this new one called "ag.el" that is "An Emacs frontend to ag, ("the silver searcher" ack replacment)": https://github.com/Wilfred/ag.el https://github.com/Wilfred/ag.el. Play with them and see if they can be useful to you ;).
- Codas 13y agoIn addition to those jbeja mentioned, there is also fiplr[1], somewhat in the spirit of ctrl-p, command-t etc. for vim. One favorite tweak of mine for file finders like this in general: rewrite the dir listing to use "git ls-files -co --exclude-standard". This obviously only works in git projects (similar commands exist for mercurial I think), but is really fast and most of the time is exactly what I want. [1]: https://github.com/d11wtq/fiplr https://github.com/d11wtq/fiplr
- platz 13y agovim emulation frustrates me to no end because it is never a complete emulation. Additionally, in emacs, there are many conflicting keybindings that prevent normal usage of using vim.
- laichzeit0 13y agoAs a long-time vim user I just recently made the switch to Emacs + Evil because of the excellent functional-language support Emacs has (with the slime plugin). Vim users are used to the "modes" like insert, normal, visual. Coming from Vim it feels like Emacs is only in Vim's insert-mode. Having to press ctrl+key just to navigate the screen felt completely wrong to me. All the ctrl/alt keybindings just seems like a recipe for RSI. However, with the Evil plugin, a Vim user can immediately use Emacs because you're editing with Vim keystrokes. Vim also encourages you to spend as little time in insert-mode, and there are very few commands in Vim that work in insert mode (to be honest, I never use them anyway) So what you can do is you can tell Evil to drop Vim keybindings when you're in insert-mode (except for ESC) and then.. voila... you're back to Emacs keystrokes, but only while you're in insert-mode (which is what Emacs seems to be about anyway) ;; use Emacs keybindings when in insert mode }:) (setcdr evil-insert-state-map nil) (define-key evil-insert-state-map [escape] 'evil-normal-state) This is the coolest thing ever if you want to learn both editor's commands, or if you're coming from the one/going to the other. (Yeah you can switch mode with Ctrl-z but this is "seamless" for a Vim user) You probably also want the Evil-leader plugin so you can map things like ",f" to find-file and ",h" for help-command, etc.
- shocks 13y agoI use vim-orgmode[1]. :) 1: https://github.com/jceb/vim-orgmode https://github.com/jceb/vim-orgmode
- Blinkky 13y agoThe Advanced section should definitely talk about marks. http://vim.wikia.com/wiki/Using_marks http://vim.wikia.com/wiki/Using_marks
- danielrm26 13y agoThis is the author, and you're absolutely correct. I'm going to add it soon. Thanks!
- seanccox 13y agoPerhaps beginners aren't in the intended audience, but as a cautious (Level 0) beginner to Vim, you lost me at the "Configuration" section. I appreciate your impulse to teach and I like the layout of the guide, so I hope you can massage it a little for a beginner like myself.
- danielrm26 13y agoMy apologies. Can you tell me what tripped you up and what you would have liked to have seen?
- oinksoft 13y agoI'm not your audience at all, but a few ideas from that section: * You refer to ~/.vimrc and ~/.vim with no prior introduction. Even assuming knowledge of "~" expansion is risky, and ignores Windows users. * You mention a "self-managed Vim install" and Janus in passing. Who cares? It's confusing. * Why am I remapping stuff I haven't used yet (<Leader>)? * Why am I remapping <Esc> to `jk` (why would you suggest such a radical change for somebody just starting out?) * Why do I care about CAPSLOCK? * Pathogen? Github? What's going on? I thought I was learning an editor. This is kind of a scatter-shot ... there's a lot of stuff that makes no sense unless you're already familiar with Vim, and with configurable Unix text editors' mode of operation in general.
- seanccox 13y agoWhat oinksoft said. I think it's a common mistake of people who want to teach anything, but I see it frequently in coding (probably because that is what I am trying to learn these days). That problem is usually articulate with this phrase: "Before you get started..." Essentially, when I look for a beginner's guide, I want to start at the beginning. There is nothing before the beginning. If I need to plug something in, turn something on, or install something, I'd like to know how to do that. I exaggerate only slightly. For example, when I was learning to play the piano as a child, I started centered on the first note I played, which was a G, and arranged myself accordingly to accommodate my chosen midpoint, since no one had taught me about Middle C. Oinksoft's points are all crucial. You're clearly knowledgeable, but those details are beyond the scope of my understanding for a Level 0 beginner, so if they are essential, they need to be broken down. If they aren't, then you can leave them out. As a general rule for teaching anything, you should explain, demonstrate, and then solicit a student response or reproduction of the concept. I think the material you have here can be arranged such that it accomplishes these components, and rearranging it thus would make it easier for someone ignorant of the subject, like myself, to follow along. I hope this is helpful criticism. I really like what you're doing and I'm excited by your attitude – 'basics to ninja' – because this is useful for preventing learners from stagnating. With some work on the beginner level information, I think you'll have a solid guide.
- sstanfie 13y agoSome thoughts on CAPSLOCK remapping: After using vi / vim since 1986, I finally remapped CAPSLOCK to CTRL at the operating system level. It's made a world of difference, and not just for vi. It easily unlocks all the EMACS style cursor movements like ctrl+A, ctrl+E, etc. Yeah, I know you can do it with the CTRL key in the lower left. But if you move from Mac laptop with Fn key in lower left, to an external keyboard with no Fn, you're gonna have a bad time. But here's another reason why I advocate this approach. Remember vi was written by Bill Joy back in the 1970s. Back then, the early terminals had the control key right there next to the A. In fact, the CAPSLOCK was to the left of that! I was recently at the Computer History Museum in Mountain View where you can see some of these early terminals. A lot of us know the Happy Hacker Keyboard, with the control key at it's rightful place. But to see it on the old terminals, it's a pretty good archeological insight into why it just feels right. Plus, WHO USES THE CAPS LOCK KEY ANYWAY EXCEPT FOR SHOUTING IN FORUMS?
- Dobbs 13y agoCaps as control makes a lot of things very nice. Including hitting the "ctrl+[" which is the escape code for "esc". So not only do you have easy access to keys like "ctrl+d" you also get escape.
- quadrangle 13y agoI use CAPS LOCK as my compose key…
- snake_plissken 13y agoi write SQL in all caps...
- dontdieych 13y agoI also recommend capslock as both ctrl and esc. With combination of other keys, It works as ctrl. Otherwise it's just esc. In linux, X11, xcape does it.
- roryokane 13y agoI often use Caps Lock for acronyms, such as HTML, CSS, IntelliJ IDEA, and ad-hoc acronyms for book titles in notes. I do remap Caps Lock to Ctrl when I use Windows, because Windows requires Ctrl for many keyboard shortcuts, but I also make it so that Shift+CapsLock activates caps lock, so I can still use it.
- imslavko 13y agoFor me a big discovery in Vim after two years of active use were <C-i> and <C-o> in normal mode. They allow you to jump between your navigation history. Allows you to edit a piece of code. Search for something else in the same buffer and go back in one stroke. Useful if you lookup documentation or often "jump to definition". Works across files so you can "git grep", iterate through the result list and go back to your editing position.
- danielrm26 13y agoI'll add this. Thanks!
- janus 13y agoAs always, what loses me on vim is that I'm not sure what's the easiest/best/common way to have a "project directory" open and quickly open one of the files inside that directory... no basic tutorial seems to tackle this, yet it's essential to migrate from any other editor you use as a programmer...
- cal2 13y agoI'm not sure if this is what you want, but NERD Tree[1] works for a lot of people. Here's a tutorial[2] for NERD Tree that I quickly found. [1]: https://github.com/scrooloose/nerdtree https://github.com/scrooloose/nerdtree [2]: http://code.tutsplus.com/tutorials/vim-essential-plugin-nerdtree--net-19692 http://code.tutsplus.com/tutorials/vim-essential-plugin-nerd...
- janus 13y agothanks, I'll give it a try. When I briefly tried NERDtree, my issue was how to switch back and forth between the tree and the opened files list
- bitcrusher 13y agohold down control and hit w, twice, when in visual mode. That will move the cursor from frame to frame. If you want to see a 'file browser', open VIM and type ":sp ." Strictly speaking you don't need nerdTree (though I love it ).
- rtfeldman 13y agoYou want CtrlP - it's a plugin that works basically the same way as Sublime Text's Cmd-T. If you want a more familiar Sublime-esque experience, you can also rebind it from Ctrl-P to Cmd-T (which is how I personally use it). So my workflow on a Mac is to type `mvim ~/project-dir-goes-here` and then press Cmd-T just like I would in Sublime to start typing in a filename and see a list of matching files to open. https://github.com/kien/ctrlp.vim https://github.com/kien/ctrlp.vim http://stackoverflow.com/questions/11979313/command-key-in-macvim http://stackoverflow.com/questions/11979313/command-key-in-m...
- platz 13y ago0i:j0vG. this did not add a colon to the entire file for me.
- coldpie 13y agoThe guide is a little off in parts, and that was one of the worst offenders. It assumes you're on the first line. Then, you have to hit Escape after typing the colon. Finally, the whole command depends on your having "vnoremap . :norm.<CR>" in your configuration, which I sure don't.
- bstpierre 13y agoThanks for that tip! I wandered in here hoping someone had already asked and answered and got my reward. I mostly use emacs for the past 15 years, but I learned vi about 20 years ago and use it regularly at something approximating level 4, but only for vi (not vim) commands -- having no real knowledge of visual mode or some of the extended commands. One of the hard things about learning vim is figuring out how to search for help -- because "enable dot command in visual mode" (and variants) doesn't turn up anything useful right away. I know I've got the right idea (esp. when seen in a tutorial like this one) but there's some setting or plugin or subtle nuance that I'm missing.
- raimue 13y agoSo, the first motivation for using vim is that you think it's readily available everywhere. However, the first thing you explain to me is how to remap the Esc key. That is definitely not something configured everywhere. For beginners with vim, just leave the Esc key as it is. It is way simpler to grasp the modes if a single key is required to switch. Also, you can just hammer a single key multiple times to get back to normal mode at all times. Mapping keys are an advanced topic. That is not the first thing you should start with when explaining vim. Unexperienced users will not understand the significance.
- Crito 13y ago> "So, the first motivation for using vim is that you think it's readily available everywhere. [...] That is definitely not something configured everywhere." The aversion to custom settings is a rather uniquely "vim thing" (emacs people don't seem to do it), but I've never understood why it is a thing. I am probably temporarily annoyed by my missing custom settings once every year or two at most. Most machines I work with get my vim config lazily loaded as I use them. Where that isn't feasible/possible/permitted, the lack of my custom color scheme flips a bit in my brain and I naturally use the compat feature set. Custom settings not being ubiquitous is an objection that makes sense in theory, but it just doesn't seem to be an issue in reality to me. Honestly I have more trouble with ~/bin
- pessimizer 13y ago>Custom settings not being ubiquitous is an objection that makes sense in theory It makes sense if your reasoning for using vim is that it is ubiquitous.
- Crito 13y agoRight, but even if that is your reasoning, the objection does not hold if you observe reality. In reality, even ubiquity is a reason you use vim, custom settings aren't damaging.
- williadc 13y agoGreat tutorial. There's a mistake in "Getting things done" -> Moving within the Screen. It lists ^U and ^D as moving a full screen, which is not true. Those only move half a screen. You correct this a few line later... I think you just forgot to take it out.
- danielrm26 13y agoFixed, thanks!
- brenfrow 13y agoFYI: Clicking on "Working With Your File" isn't linked correctly.
- jordanlev 13y agoI run Chrome with cookies (and local storage) disabled by default. When I visit the site, I only see the first two headings of a table of contents, and no actual tutorial content appears. Why does an information-only (non-interactive) web page require cookies and/or local storage to function?
- erikb 13y agoWhat is "cit"? It doesn't explain it. "t" is only presented as a verb but not as an object as far as I can see.
- Simucal 13y agoIt is "change inner tag".
- redwall_hp 13y agoChange Inner Tag. You could also use ci" to change inside quotation marks, or yit to yank the text, etc.