6 ms·
Vim Recipes
- slmbrhrt 17y agoHow very verbose. Isn't vim designed as a terse, efficient, no-nonsense text editor? http://vim.runpaint.org/basics/saving-a-file/ http://vim.runpaint.org/basics/saving-a-file/ for example, gives me several screens full of jabber, broken into Problem, Solution, and Discussion, plus the ubiquitous Needless Comment Form as on every page. All this fluff, and :w is mentioned only in a user-added comment. I don't mean to say you can't learn anything from this document, just that you could do a lot better with ':help tutorial' and maybe a googled cheatsheet. The tutorial really only takes half an hour, just like it promises.
- CaptSolo 17y agoAgree, it is too verbose. If I am using vim, I won't be looking for cookbook entry explaining simple tasks. There is probably be audience who'd benefit from the book, but does not appeal to me. I've found A Byte of VIM to be quite useful, though: http://www.swaroopch.com/notes/Vim http://www.swaroopch.com/notes/Vim
- runpaint 17y agoThanks for the feedback. :-) :w is mentioned as a footnote because :up is more sensible in the general case, as it preserves file timestamps and saves needless disk access, the latter being particularly useful when dealing with larger buffers or working over a slow link. If somebody wants a quick answer to the question, they can just look at the Solution. If they want to understand how saving works, and its how it relates to existing mental models they have of text editors, the Discussion elaborates. This is in contrast to the "cheatsheet" approach, which does exactly what you suggest. It gives a single cryptic command, then moves on to the next example. This may be sufficient for you and I, but newer users would prefer a more cohesive explanation. Oh, and the "Needless Comment Form" was added after multiple readers requested it. Apparently people find it easier than cloning the Git repository and submitting a patch. ;-)
- eddiegroves 17y agoWow, looks solid. I've only been viming for a year, so no doubt theres plenty of knowledge gems for me here.
- erlanger 17y agoThis is vapid. For instance: http://vim.runpaint.org/extending/creating-keyboard-shortcuts-with-key-mappings/ http://vim.runpaint.org/extending/creating-keyboard-shortcut... No mention of inoremap, nnoremap, etc. If you want to learn Vim well, do the following: 1. Ask "stupid" questions on #vim on freenode. Learn to use :help 2. Use :help 3. Ask the vim-use group any questions not obviously answered by :help
- bcl 17y agoI think you're missing the stated point of the book -- to focus on tasks not commands. The :help system can be a bit overwhelming to someone new to vim, especially if they are not sure what to search for help on. People learn in different ways, one of which is task oriented instead of memorizing commands from a manpage.
- wyclif 17y ago4. Be able to sprint through vimtutor. You have to learn to walk before you can run. 5. Never, ever use gvim. Forget about the mouse.
- shachaf 17y agoWhat does gvim have to do with the mouse? Regular console vim supports the mouse, and there are perfectly good reasons to use gvim without it (e.g., better color support, "Edit with Vim" in Windows).
- wyclif 17y agoPoint taken re: console support. I was thinking about the menu bars, too. Many users probably have them turned off, though.
- slmbrhrt 17y agoYeah, nothing's wrong with gvim after you throw 'set guioptions-=bmrt' and a colorscheme line into your .vimrc. Evim--now there's a crime.
- 17y ago
- blackman 17y agoI've posted this before, but i found the best way to learn some vim is by example. you soon get the idea. http://rayninfo.co.uk/vimtips.html http://rayninfo.co.uk/vimtips.html I've found it quite an efficient editor with MacVim+Ruby and Jamis Buck's FuzzyFinder TextMate.
- visitor4rmindia 17y agoVerbose and not worth the read IMHO. The best tip in this entire document was changing a sentence to title case. >Select the text you want to convert, hit :, then enter the regex: s/\<\(\w\)\(\w*\)\>/\u\1\L\2/g. And, even this is not completely correct. The expression will not work if you select part of a line. Your best bet would be to remap the following: nnoremap <A-c> :s/\<\(\w\)\(\w*\)\>/\u\1\L\2/g<CR> vnoremap <A-c> :s/\%V\(\w\)\(\w*\)\%V/\u\1\L\2/g<CR> To get key bindings that you like (I've defaulted to the EMacs capitalize-word binding).
- runpaint 17y agoThanks for the suggestion. I'll incorporate it into the recipe.
- Dobbs 17y agoSomething I recently learned that is really cool: :<area>!<command> will export the <area> to <comand> and then replace <area> with the output of the <command>. So you can do: :%!sort # Sort the entire file. :.!awk '{ print $1 }' # Replace the current line with the first word/column. So much power with this really simple set of commands. You can also highlight the an area using visual mode, and then just type ':!<command>' and it will autofill in the area for you.
- DEinspanjer 17y agoI'll concede it is verbose, but having a task oriented guide is much more useful in certain cases than the standard :help. I was happy to see a nice visual explanation of undo branches. Something that I've known exists but never learned to use well.