Friendly vim thread

Friendly vim thread

Post workflows, screenshots, vimrcs, best practices, discuss vim related things here!

Attached: 1200px-Vimlogo.svg.png (1200x1202, 106K)

Other urls found in this thread:

github.com/Crysikrend/dotfiles/blob/master/.config/nvim/init.vim
gist.github.com/nifl/1178878
github.com/tpope/vim-surround
github.com/vim-scripts/ReplaceWithRegister
coderwall.com/p/kvzbpa/don-t-use-array-foreach-use-for-instead
github.com/yuttie/comfortable-motion.vim
github.com/mbert/elvis
learnvimscriptthehardway.stevelosh.com/
vim-voom.github.io/
github.com/vimwiki/vimwiki
github.com/jceb/vim-orgmode
vimways.org/2018/from-vimrc-to-vim/
twitter.com/NSFWRedditImage

Acme is better

> mfw i see a scrote using emacs

Attached: 400.jpg (400x270, 12K)

How do I level up my vim wizard skills? I've completed vimtutor but that's about it. Are there any good resources for configuring vim, using it in projects, etc.? I want to make the transition from vscode.

>What? VIM is evolving!

Attached: spacemacs.png (367x400, 98K)

>a new challenger emerges

Attached: 50423286-5b33a400-088e-11e9-830c-792ce1c7c126.png (1366x768, 83K)

Turn on relative line numbers. Then you can jump through the file quickly with j or k. Functions can be combined with another for example you can use d with any movement command and it will delete up until the point where you would move to if you used that command. Same goes for y. You can record macros with q, end the macro with another press of q, and then reuse that macro with @. And of course repeat the macro multiple times by typing a number first.

i think I'm getting RSI, help

How do I show the buffers window???

I'll post my rc (rear cock). just come to realize that I haven't changed it in a long time so I'm kinda content with it for the moment.

" set options {{{

filetype plugin indent on
" disable automatic comment insert
autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o
set number
set relativenumber
set splitbelow
set nobackup
set nowritebackup
set noswapfile
set ignorecase
set incsearch
set hlsearch
set scrolloff=5
set showcmd
set wildmenu
set foldmethod=marker
set title
set tabstop=4
set shiftwidth=4
set autochdir

" }}}

" functions {{{

" terminal
function! OpenTerm() abort
10sp new
call termopen('/bin/bash')
setlocal nonumber norelativenumber
startinsert
endfunction

"}}}

" mappings {{{

let mapleader = "\"

" functions
nnoremap :call OpenTerm()

nnoremap l :nohl
nnoremap s :source ~/.config/nvim/init.vim

" TABS
nnoremap tn :tabnew
nnoremap tt :tabnew
nnoremap ts :vsplit
nnoremap :tabn
nnoremap :tabp

" window client resize
nnoremap :vertical resize -4
nnoremap :vertical resize +4

" yank to clipboard using xclip
vnoremap y "+y

" delete line and go into insert mode
nnoremap cd 0d$a

" stop miss-clicking shit
nnoremap Q
nnoremap q:
nnoremap
nnoremap ;

" remap Esc to normal mode in terminal mode to bypass readline
tnoremap

" zeal
nnoremap gz :!zeal ""&

" insert current time
command Date :put =strftime('%Y-%m-%d %H:%M:%S')
nnoremap d :put =strftime('%Y-%m-%d %H:%M:%S')"

"}}}

" netrw {{{

let g:netrw_banner = 0

"}}}

Here's my init.vim (I use nvim), it's pretty flexible though and works for vim as well when I need it.
github.com/Crysikrend/dotfiles/blob/master/.config/nvim/init.vim
I wanted to ask if there's an org-mode like thing for vim out there somewhere? I don't take notes in vim at all, so was just

Thanks, nice setup!

I am compiling a tutorial on making Vim plugins. It will be 100% free. It should take a few more months to do because I'm also busy with work in real life and I only have few pages done right now. But does anyone think this is a good idea / people will be interested? I think it would suck to work on something people don't care about.

So thanks a lot to anyone that can help me decide.

Attached: 1546659074133.jpg (864x1080, 101K)

Look up vim antipatterns and read the vimwiki page on .vimrc

- Learn about object motions
- Turn on relative line numbers
- Practice vim as you would practice piano, slowly and one command/trick at a time
- Grok vim ! Use registers and marks, use / to move and delete text until a certain point quickly gist.github.com/nifl/1178878

Attached: 1dac3382d98bf2ce4913547490d98854.jpg (720x960, 195K)

Agreed. It's a lifelong learning, but it will change the way you edit text forever.
Learn it once, feel it's power until the end.

Attached: 7104c06b785878a1ae5d45fbbfd61549.jpg (640x427, 71K)

How do I fix those shitty white borders on gvim when I use gvim maximized?

Attached: border_gvim.png (206x202, 2K)

idk, i've installed Spacevim a while back and it looked buggy a.f.

i just like vim out of the box

Yeah desu I think one of the main advantages of vim is that its on all POSIX systems, and if youre used to spacevim it kind of ruins that advantage

install gentoo

Why should I learn a text editor? I don't know how to program

Some random things

>gj, gk
Go up and down to the char that is visibly above the current char, in case the line is longer than the screen width.
>:e#
Open previously opened file
>:e.
Open current folder
>:mksession (filename)
Save info about all opened files, windows and tabs into a file. Resume that with `vim -S (filename)`
>``
Go to line previously used
>`.
Go to line of previous modification
>"+y
Copy into OS-clipboard
>"+p
Paste from OS-clipboard
>:sh
Go to shell. Vim will still be running, and you can check for that by seeing wether $VIM is set.
>%
Go to matching parenthesis
>= (with selection)
Auto-indent

In insert mode
>^oO
Create new line above and insert there

My vim setup is too basic to win any cool points, I'm just using the stock torte colorscheme and a plugin that toggles list/nolist when I press F4

You don't, it sucks because it makes it so that moving your mouse all the way to the edge of the screen won't put input focus on the scrollbar but it's one of those quirks that's baked in

I can't think of a reason to use vim full time. Small quick edits and non-programming purposes is all I use it for. I went through vimtutor, added a few things to rc for convenience and downloaded some theme to make it look bearable. I haven't tried plugins yet.
All that effort behind me, and more to come and it's still more time efficient to use a pleb and brainlet friendly editor like vs code. I mean it also has convenient shortcuts and extensions like automatic code formatting or one-click compiling and running small programs are irreplacable. In vim you'd have to switch to a second terminal window and repeat the gcc command, and then switch back. Vim has its learning curve too. Why spend hours getting used to a text editor, making it usable and customizing it instead of spending that time on actual work?

Which terminal emulator do you guys use on vim? I tried getting the powerline theme on urxvt and it gets all messed up.

I got Deoplete and Tern and I still can't get any of the JS syntax to show up in the box. I'm getting nothing but standard English words, which is NOT what I want. What the hell do I configure to make this thing work?

>Workflow
0. Install kakoune
1. Remove Vim (if you had it for some bizarre reason)

:!gcc %
:./a.out

Forget where I found this, but a quick way to turn relative numbering on or off, in this case mapped to F1 and F2 keys.
Saves you having to count the number of lines up or down from your cursor location.
nmap :set rnu
nmap :set rnu!

I forget where I got this theme, someone posted a link in another thread awhile ago.

Attached: vim.png (1285x695, 46K)

gg=G

Using neovim with light PaperColor colorscheme. Nothing fancy.

Please don't tell me you wrote that code user.

Attached: KF2hwbS.png (850x800, 115K)

pls help

Attached: 1471505018665.jpg (2560x1440, 421K)

What's the problem with his code?

Forget, if c>a>b it fails.

So it is normal if it just appears after a while and disappears when I reinstall gvim?

BEST PLUGINS
github.com/tpope/vim-surround
github.com/vim-scripts/ReplaceWithRegister

If you have to ask, I want you to know that you don't belong in this industry.

What? I took the pseudocode out of the discrete mathematics text book I'm reading write now, and wrote it up quick. There's literally nothing wrong with it, though I could have used a ternary operator.

Attached: huh.png (1001x412, 60K)

Nvm, I am retarded. Carry on with your day.

Attached: dammit.png (557x247, 32K)

>discrete mathematics text book
What kind of discrete mathematics text book includes something as basic as that?
>There's literally nothing wrong with it
You really have no idea.

It's in the third page of the algorithms chapter. What is wrong with it? Enlighten me.

there's literally nothing wrong with it your being trolled

A max function hardcoded to take only 3 parameters is terrible. You'd be metaphorically shot if you submitted that in a PR at work. Not to mention that you named the function terribly. Use the spread operator.
The standard library includes a max() function anyway that takes any number of parameters. Use that.

>the absolute state of webshits

Really, this industry is fucked. I don't know else what I expected from a vimtard JS monkey though.

Third page of the algorithms chapter of WHICH BOOK, you hapless techno-weenie?

coderwall.com/p/kvzbpa/don-t-use-array-foreach-use-for-instead
>"for loops are really annoying when you're trying to build something complex, maintainability becomes harder [...]"
>"Premature optimization!!!"
>"Do yourself a favor as a coder and DO NOT follow this "tip". Instead, read the-simian's comment. Rule #1 in coding: do not attempt premature optimization, favor code clarity and simplicity."
Webshits literally think for loops are hard to read and constitute a premature "optimization"

But it's a max of 3 inputs only. Jeez, I was showing the editor, not looking for a code review
Why are you calling me names? It's just called Discrete Mathematics, 6th edition by Richard Johnsonbaugh. Probably not the best book, but it was like $3.00 on ebay

Maybe I went a bit overboard, but maybe I didn't. You're obviously fluent in JS, but you seem to lack fundamental programming knowledge like most webshits these days. If I can get anything through to you - don't become a fucking idiot. Learn some other languages, because JS will frankly give you brain rot.

>but you seem to lack fundamental programming knowledge like most webshits these days
Not a complete brainlet, but yeah, pretty much. That's why I'm going through this book, and taking a course called "The Coding Interview Bootcamp" -- to learn data structures/run time complexity, etc.. The text book also goes through this stuff, only provides the mathematics with it.
JS isn't the only language I know, though.

Using vim plugin im vs code works great for me

>coderwall.com/p/kvzbpa/don-t-use-array-foreach-use-for-instead
There are cases in js where it makes more sense to use the built-in array methods than a for loop. For instance if you want to do your operations within a single expression. Otherwise it's just a stylistic preference.

const users = [
{ name: 'Bob', age: 43 },
{ name: 'Alice', age: 32 },
{ name: 'John', age: 20 }
];

// worst case loops over all users twice, but fits in a single expression
const usersOver30 = users.filter(({ age }) => age > 30)
.map((user) => user.name);

// vs.

// worst case loops over all users once
const usersOver30 = [];
for (let i = 0; i < users.length; i++) {
if (user.age > 30) usersOver30.push(users[i].name);
}

// or this, easiest to read imo

// worst case loops over all users once
for (const user of users) {
if (user.age > 30) usersOver30.push(user.name);
}

The book "Practical Vim" is really good. It's a collection of useful tips that can be applied in very general cases.

const usersOver30 = users.reduce(accumulator, user) => {
if (user.age > 30) {
accumulator.push(user.name);
}
return accumulator;
}, []);

Even better.

Seems to be missing one (.

Stretch your forearms.

How to fix RSI plox

>vim plugin im vs code
its one of the better vim binding layers out there for non-vim editors, after trying ones for atom, sublime, etc.

if you map the vscode interface keys for moving around windows and tabs it gets even closer to comfy vimness.

if there were a way to make vscode use vim's windowing and tab/layout philosophy that would be so fuckin tight

it even has vim-surround and easymotion built in to it. wow

user recommends this highly if you want a good onramp into full vim, or if you just dont want to spend months/years slowly crafting your very own comfy editing environment

>RSI from Vim
[Laughs in Emacs]

nobody cool respects you even a tiny little bit, take your paternalistic mentor roleplay shit elsewhere. talk vim or fuck back off to your tree stump

anyway

github.com/yuttie/comfortable-motion.vim
i really like this plugin lately, makes ctrl-u and ctrl-d scroll movements use a cool acceleration and deceleration instead of the default behavior of instantly teleporting your text up and down the screen.

i thought it was going to be useless rice but it really helps me keep track of the cursor while jump scrolling, which has had a big effect on helping me keep focus.

>cit
change inside tag. lets you change text inside a tag change this shit

in all realness i'm super productive with IntelliJ IDEA with vim shortcuts. better for actually doing work than pure vim, as much as I love being a purist.

you need to make sure your terminal is using a font that supports powerline glyphs. there are only a few. i'm using Tamzen for Powerline.

Attached: 2019-01-26-150613_1600x900_scrot.png (1600x900, 852K)

Serious question, does anyone actually use vim for anything other than the memes? It's got no autocomplete, code highlighting (for any modern langauges, anyway), linting, debugger integration, or IDE-like features. It's like using notepad to do anything.

I've gone through the vim tutor and it certainly seems cool to use (like I'm a hacker, lol), but the key combinations are still so weird! (No Ctrl+C it's y". Completely intuitive and I had to look it up several times before I memorized it.) Why does anyone use Vim? It's probably the most poorly designed software I've ever used, and it certainly doesn't help that the mouse doesn't work with it.

didn't know some of those, thanks

once you spend some time learning the basic movements and editing commands, its addictive and you'll get annoyed any time you have to take your hands away from the homerow for literally anything.

all of those features are plugins in vim, and getting the right combination of them all working together takes a long time to find and configure; its not something people do in one sitting. if you try to do that it's a waste of time.

the best thing to do for getting into vim is finding out if there is a set of vim bindings you can install as a plugin or add on to your main current text editor. you get to keep all your nice features, which you 100% deserve.

in your spare minutes when you think about it, try to edit a file in terminal or gui vim and see what you miss from your main editor. install a plugin manager like vim-plug, and search for a plugin that gives vim that feature.

there are also vim distributions out there that are pre-configured with a lot of popular plugins. sticking with your old mainstay editor is fine too, because the vim movement and editing key bindings is the actual thing that gives you miraculous efficiency.

After a month and a half I'm starting to think that I got memed and it's impossible to have a vim workflow faster than in a simple normie editor. Either that or I'm too brainlet.

People who rice vim with plugins are literally missing the whole point of the editor.
The main strengths of vim are modal editing and the fact that every system has vim. Perfect for quick edits everywhere.

Once you start ricing the fuck out of it you lose half the appeal of the editor. If you need to customize your own IDE, use Emacs with Vim bindings.

ur not brainlet it really does take a long time, unless you are born with vim brain. once youre over the big initial hump you'll be editing text as fast as you can think

hmmmmm. maybe. emacs is nice but the emacs keys are not for everyone.

but vimscript exists and plugins continue to be supported.

the thing about modal editing is that once you become addicted to doing it for quick configs over ssh or whatever, you want that kind of editing anywhere else you have to type and edit text.

and if 95% of your text editing happens to take place in your ide and that ide doesn't have a vim key layer available...... you see where i'm going. this is why we rice.

>emacs keys are not for everyone
I'd even go as far as to say they are utterly shit for the most part :^)
Luckily, there is evil mode for Emacs, which is the best vim emulation in any software.
(I've been a vim user for a long time and switched when I noticed I was trying to turn vim into something that it can't really be.)

>but vimscript exists and plugins continue to be supported.
vimscript is a shit scripting language though, that's why some plugins rely on external Python etc. to even do their thing.
Emacs Lisp is a fully-fledged Lisp and so much more powerful (and a great intro into Lisp as well, if you interested in functional programming/symbolic computation/metaprogramming).

>the thing about modal editing is that once you become addicted to doing it for quick configs over ssh or whatever, you want that kind of editing anywhere else you have to type and edit text.
Agreed. Modal editing is king.
I still prefer using vim for quick little edits. When I know I'll be working on a project for a longer time, I like the IDE-like features I have in Emacs.

Emacs with evil mode is a better vim than vim

>vimscript is a shit language though
yeah it's beyond awful, so limited and expensive to run. but it's there, and if vim didn't want you to individually tailor it, it wouldn't be. vimscript going extinct might be a positive on balance actually

i always forget about emacs evil mode. i haven't had performance problems with terminal vim even with ridiculous regex-based syntax highlighting and everything else that's supposed to make it piggish though so i haven't had a need to try emigrating.

i 100% do believe emacs is just better quality software, that is completely not disputable.

I am interested. Where will we be able to find the tutorial?

github.com/mbert/elvis

Attached: Elvis.jpg (685x385, 26K)

Check this learnvimscriptthehardway.stevelosh.com/

Doesn't even support half of vim's keybinds for just the SMALL subset of vim functions that emacs also happens to support, let alone the full set of functions. You have to add 500 compatiblity libs to get anywhere, and everything conflicts because since everyone realized modal editing is superior, every single emacs mode uses modal keybinds.

>Seething vimlet

The only thing I'm seething about is the fact I let myself be hyped and scammed by evil mode. It's a quite apt name, evil users really are evil. They are liars and live only to waste people's time. Because let's be honest here: emacs's ability to efficiently interact with files is a complete joke compared to vim, but vim is very limited, power-wise. If evil was anywhere near as good as it claimed to be, not a single vim user would exist today, they'd all be on evil. Turns out that the whole emacs ecosystem and extension system is a joke though.

>1000 character post
>not seething

Case in point.

@69540018
(You)

The atom one is shit, I have to use it and I hate it, can't even make things like :s work

>I wanted to ask if there's an org-mode like thing for vim out there somewhere? I don't take notes in vim at all, so was just
There is vim-voom.github.io/

But needs python and it breaks. Can someone make a simple version of this with not python needed?

Attached: voom_linux1.png (780x574, 94K)

Made the move myself about 2 years ago and it's been great

Try out Vimwiki. Nice wiki syntax with links and easy-to-reach index file:
github.com/vimwiki/vimwiki
There's also Vim-OrgMode, but I didn't try it and can't tell how complete it is compared to the Emacs one:
github.com/jceb/vim-orgmode

Attached: screenshot_2.png (830x559, 49K)

rc

Attached: Screen Shot 2019-01-27 at 12.51.11 AM.png (1268x1600, 326K)

What extensions do you use for markdown?
Is there something similar to Sublime's MarkdownEditing, with shortcuts for bold/italic and auto-completion for numbered lists?

Some keybinding that I got used to. Also, I noticed, a lot of people use autogroup command to do filetype specific configs, but it's easier and more cleaner to just use the vim's own directory layout for this kind of things.
vimways.org/2018/from-vimrc-to-vim/

Attached: screenshot_205.png (1541x1007, 287K)