4 ms·
Aiming to combat "you don't know what you don't know", here's a list of things to consider. How comfortable are you with: * find/replace/regexes * registers a
by thesteamboat 11y ago
Aiming to combat "you don't know what you don't know", here's a list of things to consider.
How comfortable are you with:
* find/replace/regexes
* registers and macros
* vim settings (spell, list, highlight, number, wrap)
* the plugin ecosystem
* editing multiple files simultaneously (splits, buffers, moving between them)
* folds
Anyone else want to chime in with stuff I've either forgotten or don't know I don't know?
- base698 11y agoI asked on /r/vim about "Who uses folds?" Didn't get any takers. I always forget they exist and haven't used them in my workflow yet. Tag files would be another good one.
- colordrops 11y agoI use them. They don't help as much with new development, but when editing a large pre-existing code base it makes perusing the contents of a file much easier. It's like getting a table of contents for free if your code is cleanly organized.
- revscat 11y agoI don't use folds that often, but when I do they are be extremely helpful. When you run across that block of code that's way longer than it should be, and need to collapse it so you can see the context around it, folds can be very useful. Also for taking care of long comment blocks. So while I agree with you in that they aren't a part of my typical workflow, they are a piece of vim that I'm glad I familiarized myself with.
- dnr 11y agoI use folds for one specific thing: I have a general "notes" file for home and for work, which is a big outline where I put anything I'm thinking about or working on. I usually don't delete stuff, so the file grows over time. I make a fold for each top-level item (~project or subproject) and sometimes nested folds if things get too big. I always use fdm=marker. The automatic fold methods are too confusing. Everyone uses tag files, in some sense, when they use :help :)
- lemonberry 11y agoI use them for learning a library or framework. I'll fold all of the functions, methods, etc. in a file and and then unfold to dig deeper. I work on a 13" mba so it helps with the lack of vertical screenspace.
- mdup 11y agoI use them all the time (I've switched them on by default in .vimrc) while editing C++ code. Extremely, extremely helpful to get the structure of a file at a glance. For example, if a 400-line file has about 10 functions in it, you can fold all "zM" and instantly you see only the function signatures, while the bodies are folded. How to enable it: use "set foldmethod=syntax" (with C++) or "set foldmethod=indent" (with JS, where "syntax" doesn't work for me). Also, I use "set foldminlines=0" so that 1-line paragraphs get closed as well (it looks more consistent). How to use it: close all folds "zM" (I remember it because the M is shaped like it's all folded on itself). Open all folds "zR". Open one fold "zo", close one fold "zc". Open one fold recursively "zO", close one fold recursively "zC". By the way, I almost never use manual folds, so "zf" is almost useless to me.
- dghf 11y agoI still don't fully understand how folds work (e.g., how can I get them in my JavaScript files by default?), and thus I find them difficult to work with, but when I can get them to work, I'm very glad of them. They make navigating round a large file much easier.
- alarge 11y agoI couldn't live without folds. Whether I'm in C++, Java, Go, Ruby, or a custom ASCII report I've written, I use them extensively. I add fold tags around every method/function implementation, and sometimes an additional one around around groups of them (e.g., classes). I generally set foldlevel to 0, so most files I enter have a few intro lines and then N folds, so that even large (1000+ lines) source files fit into a single page or two. I almost never use searches or tags to find declarations, since I can usually navigate to them directly with a single keystroke. FWIW, I map <Space> to za, so that I can unfold/refold quickly. I also map - to zx to quickly fold up a file I may have drilled some holes in.
- uxcn 11y agoMarks (non-global, global), the quickfix list, tabs, vimscript, python bindings, there's a lot. Vimcasts (http://vimcasts.org/ http://vimcasts.org/) has some good tutorials. Vimgolf (http://vimgolf.com/ http://vimgolf.com/) also has some good exercises.
- thesteamboat 11y agoOh neat! I didn't know about global marks before.
- uxcn 11y agoCapital letters and numbers are global, lowercase is buffer local. There are also dynamic marks that vim sets which you can use instead of manually navigating or setting marks. For example, g'. will go to the position of the last change. You can use :help marks to get a lot more info.
- DoggettCK 11y agoOpening a new buffer. Figured I'd try :new, and wound up getting good at splits. Still don't know how to just open up a new, blank buffer in the window I'm in without specifying a filename to :e.
- mangamadaiyan 11y agoIf you don't mind getting your hands dirty with a little vimscript, you can set the buftype to nofile, and open a "scratch buffer" of sorts.
- snorge 11y ago:enew
- mangamadaiyan 11y agoThanks :) I'd completely forgotten about enew.
- DoggettCK 11y agoJust what I needed. Thanks!
- markmontymark 11y agoAg support and ctrl-p https://github.com/rking/ag.vim https://github.com/rking/ag.vim https://github.com/kien/ctrlp.vim https://github.com/kien/ctrlp.vim Save me so much time opening files and finding matches+open-at-match
- mangamadaiyan 11y agoSlightly tangential, I also found "Your problem with Vim is that you don't grok Vi" a good source of things to learn from. While it starts off sounding like a rant, it isn't - I think it actually manages to convey a fair bit of the philosophy :) HN thread: https://news.ycombinator.com/item?id=2911930 https://news.ycombinator.com/item?id=2911930
- ijaaz 11y agoUgh. I still haven't truly mastered buffers/splits. It's all because I'm too comfortable with tmux :(