Live data from Hacker News

How to boost your Vim productivity

sheerun.net

61–70 of 130 posts

Re: How to boost your Vim productivity

#61
post #49
post #48

Earlier quoted context omitted.

Wow I have only been using H and L, and only because of you have I come to know M, {, and }. Thank you! But would you mind giving an explanation as to what the other things you listed do (f/F/t/T/;/,)? From just playing with them, it seems like f goes to the next character that you type and F does the same but backwards. t/T does the same but instead of going to the character it goes one before/after. I can't figure…

They are documented in :help left-right-motions, which you can also read at http://vimdoc.sourceforge.net/htmldoc/motion.html#left-right... . fx moves the cursor to the next occurrence of x, and semicolon repeats the search. To repeat the search in the opposite direction, use comma. 4tx moves the cursor right before the 4th occurrence of x right of the cursor in the line. F and T move backwards instead of forwards; i…

Oh my god this is amazing. Thank you!

Re: How to boost your Vim productivity

#62
post #9
post #5

Earlier quoted context omitted.

Suppose a range of lines contains function calls in some programming language: i = foo(a, 42, 1) j = bar(b, c, 100, 2) # this is a comment (well, duh) bazbar(etc, 3) You want to edit the last parameter in each function call -- change it to 'hello'. I have two ways of approaching this: macros (interactive) or :norm (less interactive). 1. Put your cursor on the first byte in the first line, type qq to record a macro of…

Lord, that's so useful. I normally include a move to next line part in my macro and then guess at how many times to run it (20@q, repeat until I get it right). It's actually the main reason I often don't bother using macros. This is such a great tip. Thanks!

@@ applies the previously applied macro, so after applying the macro (including the move to next line, but see below too) you can you just hold down @ and quickly go through as many lines as you need. If you overshoot, you can just press u a few times.

Another tip: when you forget to add the move to next line to your macro, you don't have to start over. You can append to a macro, just use the upper-case register name instead. So to append a down and move to beginning of line to macro 'a', you'd type qAj0

Re: How to boost your Vim productivity

#63

The most productive mapping ever: imap jj . No more having to reach for the escape key.

Even better: imap jk imap kj I just hit both and j at the same time with my pointer and index fingers so it's essentially one keystroke.

`kj` has worked really well for me (except, actually, when trying to write a blog post about a recent trip to Reykjavik, but that's the one time it's bitten me versus the shitton of time it's saved). I also have `zkj` mapped to `:w` to save AND exit insert mode.

Re: How to boost your Vim productivity

#64
post #3

In my 6 years of coding and writing LaTeX in Vim, I have found that the greatest boost to my Vim productivity is learning all about the vi and ex foundation of Vim. My Vim knowledge applies 100% to any default Vim installation on a modern distro, and my vimrc contains mostly trivial tweaks. This means using :normal and macros instead of :s for most of my search/replace actions; using H, M, L, {, } to navigate quickly…

when I learned about f and F a whole new world opened up for me. It never ceases to amaze me how amazing vim is. Another quick thing I recently learned (yes, novice vim user here) is stuff like this

\includegraphics{test.png}

if you stand inside the curly brackets and type ciB (change in Brackets) you get this

\includegraphics{}

with your cursor active inside the brackets, just awesome ..

Re: How to boost your Vim productivity

#65
post #60

It is a long long time ago that someone taught me something really new about vim and used plugins that are not just fancy (looking at most status line plugins or nerdtree) but actually seem to improve productivity in a vim-ish sense. Kudos!

python-mode or jshint2.vim? I don't think that they are "just fancy. Bringing linting into the editing window is more helpful (to me personally at least) than having a separate process running with it.

(Note: I turn rope off in python-mode because it's horribly inefficient, and sometimes causes Vim to delay reacting to user input)

Re: How to boost your Vim productivity

#66

Why don't people seem to use the F keys? I have mappings for very frequent functions on F1-F5, and it really helps: map :w | "Fast save imap :w | "Fast save map :make | "Fast compile map :bn map :bp " Same mapping for gnome-terminal ( see http://stackoverflow.com/q/12813126/164171 ) map ^[O1;2R :bp map :bd | "Close buffer map :cnext map :cprev imap :cnext imap :cprev

"Why don't people seem to use the F keys?" Probably because that doesn't fit well with touch typing. A great thing about vim is that you can do everything as a touch typist, without reaching for the outlying districts of the keyboard (assuming you've remapped the escape key to capslock, or learned to use ^[, or mapped it).

Additionally, on many keyboards (specifically Apple keyboards), you have to hit a modifier key plus the function key. For example, you have to hit Fn + F1 to get F1 because otherwise it's the "Lower LCD Brightness" hotkey. This makes them even less useful.

Re: How to boost your Vim productivity

#67
I disliked the part about setting up Vim on servers. Do you really want to be adding all the dependencies for your editor on every server? I'm an advocate of using the netrw plugin to edit over ssh directly and avoiding logging into servers when not necessary.

vim scp://host//etc/whatever

Re: How to boost your Vim productivity

#68
post #59

Does anyone have any advice on bindings to change split size? Ctrl-w + and Ctrl-w - just don't work well, and my current configuration shadows Ctrl-a, which I really would like to avoid.

You can use "set winwidth=79". It'll automatically resize active column to at least 79 characters. I also use mouse for resizing.

Woah, thanks! There's a "set winheight" counterpart that i'll be setting as well.

Re: How to boost your Vim productivity

#70
post #67

I disliked the part about setting up Vim on servers. Do you really want to be adding all the dependencies for your editor on every server? I'm an advocate of using the netrw plugin to edit over ssh directly and avoiding logging into servers when not necessary. vim scp://host//etc/whatever

Plugins aren't installed until you call :PlugInstall

You can also use .nvimrc instead .vimrc, so only nvim instance on server gets plugins.

Post reply on HN