Vim thread

Post your tricks, hacks. ask questions.
beginner: github.com/mhinz/vim-galore
newest stuff: spacevim.org

Other urls found in this thread:

vi-improved.org/loathing/
github.com/SpaceVim/SpaceVim
youtube.com/watch?v=ayc_qpB-93o
github.com/metakirby5/codi.vim
pastebin.com/sVhLnArZ
youtube.com/watch?v=XA2WjJbmmoM
geoff.greer.fm/2015/01/15/why-neovim-is-better-than-vim/
twitter.com/NSFWRedditVideo

what's the easiest way to make a colorscheme?

Wear lenses.

>Best vim hack
install neovim

Does neovim uses VIM style or perl style regexes?

vim, though you can make it use perl style

vim is better than an IDE and has more features.

VS sucks at debugging and refactoring. Tried to turn a function into a method of a struct in VS and it basically destroyed my whole program and somehow broke undo so that it only undid half the changes.

hello. im learning python 3 right now and i figured vim might be a good editor to use.

can vim directly execute python code and display it?

Installed nvim on my linux machine but there's still way too little nice async plugins ;(

Best plugins
ultisnips superab delimitMate mru.vim vim-airline

Also, started to do most stuff with leader instead of multi keys, it's nice:
nnoremap t :tabnew
nnoremap e :Vexplore
nnoremap w :set nowrap!
nnoremap l :set hlsearch!
nnoremap :noh
nnoremap h :split
nnoremap v :vsplit

How can I add python to my vim installation? I want to use latex-preview.

Should happen automatically if you have python installed and on your path. On windows you may need a different binary, what does :python say?

When I was using regular vim, I had to compile it from source to allow python plugins, but a few months back I switched to neovim and haven't looked back. Any plugins you already use are compatible with neovim.

pro tip: its .vimrc is in a different place, it should be ~/.config/nvim/init.vim instead.

Vim is a text editor

You can execute anything like in terminal using ':!' , eg :!python myfile.py will run it and show you the output.
Neovim has a :terminal mode to run stuff in.
Syntastic, vim-flake8 and jedi-vim will provide (in that order) syntax checking, style checking and command completion/hints

Why should i use Vim over emacs, or why should i use Emacs over Vim?

If you are using neovim, then you have an integrated shell and yes you can run python directly inside. Otherwise, you can always do :!python YOUR_SCRIPT.py

...

With python, neovim overrides your tab settings to make it PEP 8 compliant.

So if you want your tabs, say, 4 characters long instead of 8, you need to make python.vim file in nvim/after/ instead of the regular init.vim file

I think sequence-centerd commands (abc) as in vim are more convenient than combination-centerd commands (control-alt-c) as in emacs.
Other than that I have no idea, never used emacs a lot

Swap your capslock key and esc key, vim was designed for esc to be where capslock is. Your puberty will thank me.

Fedora: Install `vim-enhanced`

*Buntu: install `vim-nox`

They have python support. Otherwise you can compile vim pretty easily.

I mean pinky. Not your puberty.

Better swap it to caps lock, you can escape insert mode with ctrl + [

// close buffer that is covering other buffer
map :b#bd#
// appends are easier
nmap a A
// save is easier
nmap ; :w
// command mode is easier
nmap :
// switch between open splits with tab
nmap w
nmap W

// persistent undo and backups
set undofile
set undodir=~/.vim/undodir
set backupdir=~/.vim/backup
set directory=~/.vim/swp

// Improve performance over SSH
set lazyredraw
set ttyfast


Also, I recently switched from YoucompleteMe to mucomplete. Mucomplete doesn't need to be compiled and seems to have better completion. I use it for mostly golang.

i meant to control not caps lock

so why would i use this over spacemacs?

Quit vim
apt-get install emacs

ycm

>vim-airline
>ycm
absolutely disgusting

>vi-improved.org/loathing/

Does anybody here actually use spacevim?
It looks horribly bloated to me.

>spacevim
It's not just you, all vim "distros" are anti-vim. Using then is even more stupid than using emacs and pretending it's vim

Vim is a simple text editor, it's not an ide, stop overcomplicating things or if you don't get it switch back to atom, it's more hip these days

What are the benefits?

>neovim
>benefits
reddit karma, that's all

Hey guys check it out

github.com/SpaceVim/SpaceVim

>youtube.com/watch?v=ayc_qpB-93o
Check this video for the history of Vim and explanation behind it's design choices

As a bonus it exposes all the neovim shills lies and misinformation

Neovim is bad and doesn't offer any benefit over Vim especially now that Vim 8 is released.

Neovim serves no other purpose than to inflate the egos of neovim developers and make ignorant neovim users, who don't even know what the ; key does and foolishly remap it to :, feel special

post vim rice

Use github.com/metakirby5/codi.vim
like

>file drawer open
>there is only one (1) file in the file drawer
>buffer tabs
>statusline plugins with patched fonts
>patched fonts for a terminal text editor
>the patched fonts look like shit

>vim rice
>rice a text editor

That's a joke right?

Why are you even using vim if you are not using it the way it's meant to be used?

Oh god, I couldn't live without a or ; commands

>nmap a A
nice, you just broke vim

>nmap ; :w
great, you just destroyed one of the most useful vim motions

>YoucompleteMe
please stop

It's just to show it off senpai. My use case looks a lot more like this. Which is still aesthetic

post your fucking screenfetch you chucklefuck

Is that OS X or Linux?

...

It's the same as before, you just closed nerdtree

You still have the anti-vim buffer tabs and the statusline plugin with the patched fonts.

You are using a terminal text editor to (I suppose) be able to ssh from another workstation and you put a hard dependency on having patched fonts? Why?

You know, you don't have to use Vim if you are try to make it behave like a subpar gui text editor.

And I'll be polite and won't say anything about the airline-like shell prompt and the emoji error.

Zsh, right?

oops I also meant to tag

I don't ssh for vim ever. Even if I did I'd just deal with the unpatched fonts (they render as

Edit the colors of an existing one

Woah. It's almost like people can use their computers as they want and not in some ridiculously specific fashion that adheres to your standards. What a time to be alive.

My vimrc is pretty basic. Just adds stuff like line numbers, set tab to 4 spaces, color scheme to solarized, etc. I've only used vim for C and ASM, and have never tried an plug-ins. What would you guys recommend as some must haves?

Also do you guys use vim for absolutely everything programming related? Like I can't imagine programming in vim for Java.

I use Atom for when I start to hate vim and IntelliJ when I need a full blown IDE. I used to use Atom almost exclusively until I saw the huge potential of vim.

Codi is cool for some languages like python, NERDTree is cool if you want to IDEify it. I personally use a shitload of keybindings.

Mine: pastebin.com/sVhLnArZ

:! run a command, but ctrl z, then fg werks just as/better gud.
:r! put command output into you're document.
example>> :r!date

No, I'm using it correctly.

You don't need YCM. Ctrl-n in normal mode shows auto complete options.

NERDTree doesn't make vim into an IDE.

It's literally just a way to view your directory in a tree.

if you have to press ctrl-n it's not automatic.

I use mucomplete, which uses built in completion and doesn't need to be compiled, but lets you switch between different sources for completion and is more context aware than the built in completion (and automatically pops up).

Vim doesn't even need most plugins

youtube.com/watch?v=XA2WjJbmmoM

>research about Makefile
>mount a generic template to weekend projects
>:!make run
>???
>profit

acme can

What are better alternatives, specifically for auto completion.

Not that user but I wish I had the willpower to learn a whole new editor again, acme seems like something I'd either like a lot or get frustrated with, the only way to know is to try it in the real world but I just don't want to go through that again even if it's worth it. I'm jealous of people who like and use acme.

mucomplete, vimcompletesme.

vim-plug or vundle?

I've used both

Vim-plug is better.

keked

Is there anything better than vim-plug?

they're the only two I've used, but I heard vim 8 has a "built in plugin manager" but I don't know how it works.

best vim plugins for php development?

:help color should help you

This. And map it too!

:nmap :!python file.py

That makes Vim run your code whenever you hit spacebar in normal mode.

I am actually an Emacs person, but when I am stuck without it, I find this is the best way of incrementally testing things as you build them.

anyway in vim to sort inconsistent use of tabs and spaces?

what theme?

Is there a way to open a split with a Python shell in vim. Instead of opening two terminals.

Also cool leader presets?
Like run last : command?

Vim is awesome on its own. Control+p is pretty handy

vim has autocomplete built in

try :s/tab/spaces/gc

linux is a kernel you pleb

Gotta admit, spacevim looks pretty good. Anyone tried it? Currently using spacemacs, but I really just use the vim keybindings.

when i go to apply a colorscheme it just changes nerdtree font colors but not the background or anything else.

I have the Plug '...' in my vimrc, what am i missing?

geoff.greer.fm/2015/01/15/why-neovim-is-better-than-vim/

The article is a bit dated. Vim 8 has implemented a few things since then from neovim, asynchronous plugins for one.
But he point is vim is resistant to change, with a fuckton of legacy code, and a frankly bad plugin API.

I prefer to use :make and set makeprg based on different filetypes. So for latex I'd call rubber, for c I'd invoke make, for python, python, etc. Combine that with the Grand Central Dispatch plugin to get the :Make command which instead runs in the background and doesn't interrupt your editing. Then set :Make to run on BufWritePost so it'll run every time I save.

Vim?
Thats one 'm' too many for my taste

Is there a way to pad some characters to a certain text width similar to printf using only vim?

How do I set Vim to use RGB hex values for colors instead of their macros?

Anytime I try to use hex, it gets changed to black/default values.

That's probably a better way for large projects. Vim isn't my main development environment, so is basically something I do with no customization beforehand for incrementally making and testing things.

My strategy is basically hitting space in normal mode so it will either die and tell me where I screwed up, or let me test the thing interactively when things are fine.

I should add that I hit space an awful lot when I do this.

Not only does it force me to think about modularity, but it also lets me catch problems really quickly, even if they escaped my notice when writing the actual code.

And when I say testing, I mean running all unit tests before even trying to run my code... Because 100% test coverage and contract testing tells me instantly when I break my design contracts. Also good tests for a well-designed project, even a large one, shouldn't even take a second to run.

Good talk, going to be replacing some of my plugins with just rebinds.

Pretty much the same unless you want real fancy stuff (Vim-plug has more features).

Supertab


Best plugins:
Fugitive, Syntastic, Surround, Emmet

My favorite shortcuts:


Replace Tabs with 2 spaces (you can also put this in ".vimrc"): :set tabstop=2 shiftwidth=2 expandtab retab
Save and close current file: ZZ
Scrolls screen, make current appear in the middle: zz
Change text inside of quotes: ci"
Indent the block inside braces: >i{
Re-indent the block inside braces (Re-indent block according to curretn indention rules according to ): =i{
Paste buffer (i.e. after doing "5yy") and match text indention at surrounding: ]p
Indent 5 lines: 5>>
Run command line: :! [command]
Get date (from command line) and insert at cursor position: :r! date
Select all text in brackets (visual mode): vi{
Replace text in parentheses with current buffer: vi(p
Delete until next dot: dt.
Increment or decrement number under the cursor: [Ctrl]+a and [Ctrl]+x
If you edit something, but need sudo rigths to save it: :w !sudo tee %
Start recording macro: qq
End recodring: q
Run macro 3 times: 3@q

For example: FizzBuzz in Vim:
i
1
[Esc]
qq
yy
p
[Ctrl]+a
q
98@q

>For example: FizzBuzz in Vim

Oh shit, I'm retarded..

Here is the complete Vim-FizzBuzz:

:!sudo apt remove vim

Try
:put =range(1,100)

Okay I might try this actually over the weekend.

>how its meant to be used
Who cares? I care for speed and efficiency but have zero regard for 'purists' and all that.
If I'd let someone tell me how to use my software I might as well use nonfree software