[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

Vim thread

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 90
Thread images: 7

File: 256px-Icon-Vim.svg.png (15KB, 256x256px) Image search: [Google]
256px-Icon-Vim.svg.png
15KB, 256x256px
Post your tricks, hacks. ask questions.
beginner: https://github.com/mhinz/vim-galore
newest stuff: http://spacevim.org
>>
what's the easiest way to make a colorscheme?
>>
>>58335040
Wear lenses.
>>
>>58334956
>Best vim hack
install neovim
>>
>>58335101
Does neovim uses VIM style or perl style regexes?
>>
>>58335113
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.
>>
>>58334956
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?
>>
>>58334956
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 <leader>t :tabnew<CR>
nnoremap <leader>e :Vexplore
nnoremap <leader>w :set nowrap!<CR>
nnoremap <leader>l :set hlsearch!<CR>
nnoremap <leader><space> :noh<CR>
nnoremap <leader>h :split<CR>
nnoremap <leader>v :vsplit<CR>
>>
How can I add python to my vim installation? I want to use latex-preview.
>>
>>58335815
Should happen automatically if you have python installed and on your path. On windows you may need a different binary, what does :python say?
>>
>>58335815
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.
>>
>>58335539
Vim is a text editor
>>
>>58335539
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
>>
>>58334956
Why should i use Vim over emacs, or why should i use Emacs over Vim?
>>
>>58335539
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
>>
File: 1483008332214.png (320KB, 1979x1346px) Image search: [Google]
1483008332214.png
320KB, 1979x1346px
>>
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
>>
>>58336138
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.
>>
>>58335815
Fedora: Install `vim-enhanced`

*Buntu: install `vim-nox`

They have python support. Otherwise you can compile vim pretty easily.
>>
>>58336264
I mean pinky. Not your puberty.
>>
>>58336264
Better swap it to caps lock, you can escape insert mode with ctrl + [
>>
// close buffer that is covering other buffer
map <C-q> :b#<bar>bd#<CR>
// appends are easier
nmap a A
// save is easier
nmap ; :w<enter>
// command mode is easier
nmap <space> :
// switch between open splits with tab
nmap <Tab> <C-w>w
nmap <S-Tab> <C-w>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.
>>
>>58336400
i meant to control not caps lock
>>
so why would i use this over spacemacs?
>>
>>58334956
Quit vim
apt-get install emacs
>>
>>58335785
ycm
>>
File: vim.png (34KB, 516x305px) Image search: [Google]
vim.png
34KB, 516x305px
>>58335785
>>58338018
>vim-airline
>ycm
absolutely disgusting

>https://www.vi-improved.org/loathing/
>>
>>58334956
Does anybody here actually use spacevim?
It looks horribly bloated to me.
>>
>>58338319
>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
>>
>>58335101
What are the benefits?
>>
>>58338592
>neovim
>benefits
reddit karma, that's all
>>
Hey guys check it out

https://github.com/SpaceVim/SpaceVim
>>
>>58338592
>https://www.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
>>
File: Screenshot_2017-01-05_10-19-24.png (1MB, 1920x1080px) Image search: [Google]
Screenshot_2017-01-05_10-19-24.png
1MB, 1920x1080px
post vim rice
>>
>>58335539
Use https://github.com/metakirby5/codi.vim
like >>58339177
>>
>>58339177
>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?
>>
>>58336418
Oh god, I couldn't live without a or ; commands
>>
>>58336418
>nmap a A
nice, you just broke vim

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

>YoucompleteMe
please stop
>>
File: Screenshot_2017-01-05_10-58-27.png (157KB, 1920x1080px) Image search: [Google]
Screenshot_2017-01-05_10-58-27.png
157KB, 1920x1080px
>>58339272
It's just to show it off senpai. My use case looks a lot more like this. Which is still aesthetic
>>
>>58339177
>>58339633
post your fucking screenfetch you chucklefuck
>>
>>58339633
Is that OS X or Linux?
>>
File: Screenshot_2017-01-05_11-08-29.png (276KB, 1920x1080px) Image search: [Google]
Screenshot_2017-01-05_11-08-29.png
276KB, 1920x1080px
>>58339679
>>
>>58339633
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?
>>
>>58339672
oops I also meant to tag >>58339728
>>
>>58339736
I don't ssh for vim ever. Even if I did I'd just deal with the unpatched fonts (they render as <'s) or install patched fonts. I like vim because I can customize it more than anything else and still have it look pretty and work fast, not to be 1337 or anything. The airline fonts just look nice imho. The emoji is just for the lulz
>>
>>58335040
Edit the colors of an existing one
>>
>>58339736
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.
>>
>>58340378
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: http://pastebin.com/sVhLnArZ
>>
:!<command> run a command, but ctrl z, <command[s]> then fg werks just as/better gud.
:r!<command> put command output into you're document.
example>> :r!date
>>
>>58339435
No, I'm using it correctly.
>>
You don't need YCM. Ctrl-n in normal mode shows auto complete options.
>>
>>58340479
NERDTree doesn't make vim into an IDE.

It's literally just a way to view your directory in a tree.
>>
>>58340795
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).
>>
>>58334956
Vim doesn't even need most plugins

https://www.youtube.com/watch?v=XA2WjJbmmoM
>>
>>58335539
>research about Makefile
>mount a generic template to weekend projects
>:!make run
>???
>profit
>>
>>58335539
acme can
>>
>>58338239
What are better alternatives, specifically for auto completion.
>>
>>58341698
Not that Anon 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.
>>
>>58342591
mucomplete, vimcompletesme.
>>
vim-plug or vundle?
>>
>>58344219
I've used both

Vim-plug is better.
>>
>>58335076
keked
>>
>>58344326
Is there anything better than vim-plug?
>>
>>58344378
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?
>>
>>58335040
:help color
should help you
>>
>>58336135
This. And map it too!

:nmap <Space> :!python file.py<CR>


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?
>>
>>58339177
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
>>
>>58342591
vim has autocomplete built in
>>
>>58345966
try
:s/tab/spaces/gc
>>
>>58339679
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?
>>
>>58338592
http://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.
>>
>>58345748
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
>>
File: Vim.jpg (192KB, 1800x696px) Image search: [Google]
Vim.jpg
192KB, 1800x696px
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.
>>
>>58347469
That's probably a better way for large projects. Vim isn't my main development environment, so >>58345748 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.
>>
>>58351795
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.
>>
>>58340883
Good talk, going to be replacing some of my plugins with just rebinds.
>>
>>58344219

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

>>58342591

Supertab


>>58334956

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
>>
>>58354450

>For example: FizzBuzz in Vim

Oh shit, I'm retarded..

Here is the complete Vim-FizzBuzz:
>>58332218
>>
:!sudo apt remove vim
>>
>>58354450
Try
:put =range(1,100)


>>58338239
>>58340883
Okay I might try this actually over the weekend.

>>58339272
>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
Thread posts: 90
Thread images: 7


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.