Vim thread

Vim thread

Share useful tips and tricks, bindings, plugins

Attached: vim.png (1200x1200, 115K)

Other urls found in this thread:

github.com/junegunn/fzf.vim
github.com/ggreer/the_silver_searcher
github.com/junegunn/goyo.vim
twitter.com/SFWRedditImages

cc deletes the current line on puts you in insert mode

vi is better.

neovim is better

type ESC : q ! ENTER so you can leave vim and enter a decent editor like nano

echo >> is better

:!rm -rf /*

>not keeping a mug with shortcuts at your desk

Attached: 2019-06-18-12-10-31_compress79.jpg (1512x1512, 278K)

:earlier 20m
reverts you're doc to it's state 20 minutes ago.
:later 5m creates mustard gas
gg go to start
G go to end
M go to middle
33% go to 33%

Unironically where can I get one of these?

>using anything other than a,i,dd,y,v,V ever

apt remove vim
apt install neovim

My Sysad teacher gave me one of those. They are useless (unless for drinking) after the first month with vim, but they are a nice astethic, but get the one with tux on oit

>not using o and O

Attached: smug-anime-female.png (654x702, 401K)

make sure you dont forget the dependencies segfault and half assed reverse engineered vim script

Nostarch press. They are a bit pricey, but bought mine during one of their site sales.

apt install neovim
echo "alias vi='nvim'" >> ~/.profile

:!sudo apt purge nano

dilate

The goyo plugin is real comfy for editing prose

What does it do?

:30,40w goodpart
>write lines 30 -40 to a file named goodpart

it's a so called distraction free editing mode for vim.
I also use it sometimes, for editing markdown files.

:w !grep foo
will remove lines that don't contain foo

*should be
:%!grep foo

post colorschemes, I love this one but it doesn't have proper html formatting

Attached: Selection_014.png (795x545, 57K)

g; goes back to the location of the last edit.

You guys must get distracted real easy if you need a fucking distraction free vim interface.

Attached: samsquanches.png (421x479, 319K)

CTRL-n and CTRL-p to scroll up and down the possible tab-completion of long variable or function names.
If you are using a tags file, or if you have the file with the other definitions open in Vim, it will complete the name for you.

Jow Forums are autistic

Checkout PaperColor light background

I use it because in this mode text is field is centered and line length is limited, which makes text much easier to read when you have a file with long lines of text.
That's why it's handy for markdown.
But - hahaha, awesome joke, so talented. -_-

fzf + Ag is very helpful
github.com/junegunn/fzf.vim
github.com/ggreer/the_silver_searcher

awesome desu, thanks user

>created by a company just so they could ad their proprietary plugins to "vim"
>not fully backwards compatible with vim
>janky terminal bugs that have been around since day 1
I'll stick with what works thanks, when I want something that actually builds on what vim does instead of a janky fork I'll switch to Kakoune

gruvbox community fork

:v/foo/s/that/this/g changes that to this in all lines of the document that don’t contain foo

:Explore

:Vex/:Sex

vim -r
>searches out vim swap files in the usual areas.
find . -type f -name '*.sw[nop]' -ok rm {} \;
>gets the rest

vim ~/Documents

What's up with all these retards using nvim?

It's literally the same program. No one gives a shit that the code base is different.

i always return to the 'repulsive blue one' (as vim-solarized8 plugin here). also get polyglot plugin for syntax highlighting, indentation etc. covering most things.

Attached: 2019-06-18-205931_987x671_scrot.png (987x671, 141K)

this plugin is awesome, thanks a lot for the rec

It's LITERALLY the same program. Vim was designed to be hackable. Nvim is just some troglodyte's ~/.vimrc.

>Nvim is just some troglodyte's ~/.vimrc
It's a rewrite of the codebase you absolute brainlet.

The terminal, shell command, and job control systems are completely different as well as practically every feature added since they split off

Vanilla vim can encrypt files with :X. Also, try opening a .txt.gz file with Vim, it just werks.

what the actual fuck
is this real!? if so, will somebody explain why the fuck i've been using emacs for 6 months?

Emacs is for if you want to build commands like that yourself

I'm sure emacs could (be made to) do something like that too. It's just that vim comes with tons of this kinda stuff OOTB and it just works.

:h motion.txt
is one help page that's especially worth reading, and the rest are good to skim through too. The rest can be seen by typing :help

why haven't you installed evil-mode is the real question

M moves the cursor to the line in the middle of your window.
In addition:
H moves cursor to the top of the window
L to the bottom

to go to the middle of the file type
50%

ftfy, m8

the mnemonics for those keys are H(igh) M(iddle) L(ow)

"qp
pastes a macro you recorded in the q register - macros are just keys that get stored in a register, you can run any register's contents with @, regardless of what it contains

:let @+ = @q
sets the system clipboard to contain the same text as register q. you can obviously use any two registers this way

g; and g, move between recent changes

gi puts you into insert mode where you last inserted

`[ and `] go to the different sides of the latest change

%SOP IS A FAGGOTd

still using jellybeans to this day, been searching for a good colorscheme for the tty though

I also use jellybeans

What's the least painful way to set up an autocomplete for python that can also see into and predict names from installed libraries?

LSP and probably coc.nvim (stupid name and stupid design but it seems to be most actively developed) or another LSP client (vim-lsp is a good barebones one, language-client-neovim might be good)

So what does goyo actually do?

pastes the contents of cmd into the window
:r! {cmd}

execute an expression and paste it into the window
Ctrl-r =

resumes the previous visual mode selection
gv

lists all registers (macros included)
:reg

jump to exact last modification
`.

save and quit, without quitting
ZZ
ZQ

contents of the latest yank
"0

pause vim and use the terminal, unpause
Ctrl-z
fg

increment number, decrement number
Ctrl-a
Ctrl-x

next/previous method
]m
[m

I use evil-mode btw

Attached: 17076539_736594086499234_1566602987801935872_n.jpg (480x480, 35K)

>lists all registers (macros included)
this is good

It hides the modeline and centers your text. After using it for a while, prose without it looks unreadable and ugly.

there's also :marks which, well... lists all the marks

actually the screenshot from readme demonstrates it perfectly
github.com/junegunn/goyo.vim
It hides everything except text and makes your editing window centered on your screen while limiting its width and height.
This makes the text very readable which is nice if your text has long lines (like in markdown documents).

Attached: Screenshot from 2019-06-18 12-38-26.png (1920x1080, 987K)

>indenting the brackets
yikes!

also you can edit .tar.gz, .tar.xz and so on with normal vim also.

because i don't use software designed by non-aryans, thanks

Just learned how to do case insensitive search.
/\csearchstring
Neat.

Attached: 1560348543512.jpg (381x507, 42K)

>imagine needing this to simply edit text
have sex

GNU ed

:help user-manual
:help index

To change the char under the cursor, just type r then the new char.
No need to go in and out of insert mode.
>Yeah, actually I did just learn that recently. Doesn't mean I'm fucking stupid.

That means you're fucking stupid. Anyway.

>ci" doesn't require you to be at the text object

gutentags. best fucking plugin ever.

Does vim use regex on the '/' search function?

yes

Yeah but escaping is strange

Is there anything like the f motion that works exclusively? Now I just usually do vf and unselect the last character manually.

t/T

Ahh, thanks a lot user, I knew there must have been something.

On the matter of the f/t motion I've found repeating the last such motion with ; has been surprisingly useful for me.

Attached: VimCaptainsBlend.png (490x547, 114K)

Bend over then.

Attached: 1560879705633.gif (547x433, 94K)

Coming from Sublime Text I often miss multiple cursors, especially for quick refactorings. Just select a piece of text, alt f3, and you have a cursor at all the occurences of that text and can edit it and its surroundings. How do you do such things effectively in vim? i know I can search for the thing and bash n. or record a macro and :g//norm @@, but it’s too much effort for what was a matter of one key press in Sublime.

I use it because it had async/terminal support before vim, which allowed for ale/deoplete. vim used to have a big hiccup when you inserted from visual block mode while nvim was instant (I don't know if vim still hasn't fixed it). Now I just stick with nvim because why use the version that is playing catch-up?

Oh shit, had no idea about that one either. Good stuff.

>y
>but not p

How will you paste the content you've copied?

can also just use :set ignorecase unless you rely on case sensitive searches a lot

Notepadqq is better

Best way to do project wide search and replace? Or any good plugins?

In my vimrc I have:
set ic smartcase
This ignores case when making lowercase search querios.

So if I search text without caps, like /classname, it will return results for `className` and `classname` (or anything in between)
But if I search for text with caps, like /className, it will only return results for `className`

And I guess if I wanted to ignore case after typing capital letters I could still do /className/i or something but that rarely comes up.

why doesn’t A work the same way I does in visual line mode (append to every line as opposed to prepend) but it works fine in visual block mode?

I set my tabstop and shiftwidth to 5. That way if any code is indented with spaces instead of tabs I can switch it to tabs.

>:earlier 20m
>:later 5m
They looks cool, but in fact you'd never use them

Emacs can do that and much more

>What does it do?
>it's a so called...
>I also use it...
No wonder you needed a distraction free interface of an already very minimal within a terminal window text editor