Vim - Tumblr Posts

2 years ago

If I remember correctly, you mentioned using Vim as your day-to-day text editor. I'm also a fan of Vim and I've finally started to customize it to make it my primary Python editor; any particular plugins you'd suggest, or tips and tricks that you can offer?

Alright you asked for it this is going to be long.

vim and its friends are very handy, there's a lot you can do to make it more livable from the get go without any plugins at all.

My neovim config is here, it's a little out of date but if you want to reference what plugins and so on I have, here

rc/vimrc at master · KaliumPuceon/rc
GitHub
config files. Contribute to KaliumPuceon/rc development by creating an account on GitHub.

Enable the mouse! It's really handy to be able to click between tabs, around a file, resize splits, etc. when you want to. In your config file put:

set mouse=a

Presumably you already have your movement in vim pretty down pat, but it's worthwhile to go over a movement hint list like this one from Bart Kummel to see if there's any you missed, using G and gg to move to the top and bottom of a file is super handy. Knowing that u and C-r will undo and redo is also good.

Learn how vim's integral split and tab features work. You can :sp and :vs to split horizontally and vertically, and C-w+<direction> to move between splits, alternatively use your mouse. To create a new tab, you can :tabedit &lt;filename> or :tabnew <filename> to open or create a new file in a tab, and then use gt and gT to move through tabs (go tTab) quickly, or again, your mouse. With mouse enabled you can even drag to rearrange tabs and resize splits, way easier than memorizing the commands. More detail on tabs here and splits here.

If I Remember Correctly, You Mentioned Using Vim As Your Day-to-day Text Editor. I'm Also A Fan Of Vim

Learn to use ctags in vim. At the top of your current programming project, run ctags -R . to build a ctags database for the project. Then, in the file, you can use C-] to jump to the definition of any function or variable, and C-t to move back up the stack of tags you've followed. You can even C-w+} to preview the definition in a split. There's way more features, you can learn them here.

Get familiar with visual mode, which will let you select a chunk of text and then cut, paste, find/replace, etc. it. Press in Normal mode to enter Visual mode, and then move around like normal, selecting text. You can then d to delete and cut to clipboard, y to copy to clipboard, or you can apply a find/replace on the selection. Of course, if you've enabled your mouse you can also just click and drag to select.

If I Remember Correctly, You Mentioned Using Vim As Your Day-to-day Text Editor. I'm Also A Fan Of Vim

Learn your regexes, they're an unbelievably fast way to find and edit files. You can do /<regex> to immediately search for the next instance of <regex> and then move to the next and previous match with n and N. Your regex can just be the exact thing, but if you get a handle on basic regex features like word boundaries, repeats, and sets, you can construct very fast and effective searches.

With regexes you can also do find/replace, using :s/find/replace to immediately fire that off on the line you're on, or to affect the entire selection in a visual block. Very useful for renaming functions and variables.

Learn tmux, which isn't a vim thing, but is a general purpose terminal multiplexer. With a tmux session you can spawn multiple terminals in one window, each running their own shell, in separate tabs and splits, and you can background an entire session without closing it. Very useful if you want to create a self-contained programming environment, at work I have a separate tmux session for each bug I'm working on which may have a debugger, several code windows, multiple file explorers, etc. I won't cover tmux in detail here, but I wrote about it for some undergrads once and you can find my notes on that in section two of this document. If you're configuring tmux, hit me up, but my config is not suitable for general consumption.

If I Remember Correctly, You Mentioned Using Vim As Your Day-to-day Text Editor. I'm Also A Fan Of Vim

That's about all the vim techniques I use on a daily basis at work, there's way more depth you can get into to go even faster but with those you can do all the things a conventional editor's Edit menu would do without ever leaving your keyboard. Less commonly used features includes the macro system, folds, and using the built-in file browser. I barely touch these.

Plugins:

I don't use a ton of plugins, I stick to a relatively vanilla vim experience because it means that you wont' be so lost when you sit down at someone else's config. I recommend mostly adding rather than changing, although I absolutely do have things like remapping my leader key to ,

I also don't have a ton of my plugins setup because this is a new computer, so I won't have demo photos.

I use neovim, which is a vim fork that focuses on being more modern, having saner defaults, and expanding the programming interface to languages other than vimscript. This is nice, because it means you can write plugins in a modern language like python, rust, or C++. For all intents and purposes to the average end user it is indistinguishable from vim, but the plugins I use might sometimes be nvim specific and I'll try to call out vim equivalents if I remember.

Tim Pope is the most influential vimscript programmer of the generation, having written everything from git managers to plugin installers to the de facto standard aftermarket vim default configuration. Flip through his repos and see if anything strikes your fancy. Many people like vim-surround which enables modern-editor style automatic insertion of matching braces, apostrophes, angle brackets, etc.

Neovim Completion Manager, an autocomplete tool built for Neovim. Combine it with Jedi to do intelligent python completion, pyclang for C/++ completion. The vim equivalents would be YouCompleteMe or Deoplete which is apparently now ddc. I've no preference, having used both a little, but YouCompleteMe is more popular.

Ale by w0rp, a linter that will mark out syntax errors. Nonessential, but a handy little thing, saves a lot of time, gives you relevant compiler errors right where they are.

ctrlp, a clone of sublimetext's infamous ctrl-p fuzzy search, a good way to quickly switch files in vim. Vaguely mash out something that looks like the file you want to open, and ctrlp will usually find it.

IndentLine, especially good for Python, shows vertical lines and leading spaces at your indent levels like you'd find in modern graphical editors.

That's about everything I use regularly, you can really go deep in on customizing vim into your perfect IDE, but I like to keep it light.


Tags :
5 months ago

This is probably me retroactively justifying something that's become muscle memory, but it seems obvious that you'd want navigation on the home row because navigation is half of what you do in an editor. Up/down navigation is more frequent than left right navigation so it makes sense to use your two strongest fingers (index + middle) for it. And the left right goes on either side of up/down because again, less finger motion. For a while I considered rebinding to jkl; because there's less motion required to reach all the keys, but using the pinky for stuff sucks far more than moving my index finger a touch. Anyways that is my entirely post facto justification.

Calling it a mnemonic has got to be a joke though :P

Monospaced white text on a black background reading: Experienced users prefer the hjkl keys because they are always right under their fingers.  Beginners often prefer the arrow keys, because they do not know what the hjkl keys do.  The mnemonic value of hjkl is clear from looking at the keyboard.  Think of j as an arrow pointing downwards.

It is really funny to me just how full of cope the vim documentation is


Tags :
vim
1 year ago
Balcony Girls: Vim And Vinegar

Balcony Girls: Vim and Vinegar


Tags :
1 year ago

see, the idea of doing the5 different quests that involve me clearing out the Vim! Pop factory is enticing, but also

Extra big scary green basement man


Tags :
1 year ago

nvim

i use nvim solely to feel cool

Nvim

like look at this i know what im doing i definitely was not combing through documentation for the past hour definitely i am so good at what i do definitely mhm


Tags :
3 years ago

I’m glad I wasn’t hallucinating. But what was Vim thinking

As I am scrolling through Pinterest at 2am as one does, I see this add and I am leaving it here so I. The morning I know I was not hallucinating

As I Am Scrolling Through Pinterest At 2am As One Does, I See This Add And I Am Leaving It Here So I.
As I Am Scrolling Through Pinterest At 2am As One Does, I See This Add And I Am Leaving It Here So I.
As I Am Scrolling Through Pinterest At 2am As One Does, I See This Add And I Am Leaving It Here So I.
As I Am Scrolling Through Pinterest At 2am As One Does, I See This Add And I Am Leaving It Here So I.

Tags :
7 months ago

Some days, my problems can be resolved by a simple :%s/<.\{-}>//g

(that’s the vim command that removes html and leaves behind the unformatted text).

Also, piratesexmachine420, you have an excellent pfp. Triangles are good.

This meeting could've been an elaborate and transfixingly beautiful flag semaphore transmission.


Tags :