/fvt/ - Friendly Vim Thread

Users of all skill levels are welcome. Ask questions, help others. Post your vimrc and suggest tweaks.

>About Vim
Vim is a highly configurable text editor built to make creating and changing any kind of text very efficient. It is included as "vi" with most UNIX systems and with Apple OS X.

>Why Vim
Vim is rock stable and is continuously being developed to become even better. Among its features are:
#persistent, multi-level undo tree
#extensive plugin system
#support for hundreds of programming #languages and file formats
#powerful search and replace
#integrates with many tools.

>I want to use Vim but I don't know the keybindings/Nano is easier
#Learning them is easy and you only actually need a select few: navigation, search, b, i, w, :line, v and a few more
#Install Vim and get started with the built in vim tutor: vimtutor - very easy 7 lessons, takes you 30 minutes and you are there.

>I want to use mouse and click
While you can certainly do them in Vim, you will become too lazy to take your hand off the keyboard once you get comfortable with Vim.

>Vim is just a text editor
True, but you can scale Vim to be the IDE you want it to be: C/C++, Java, C#, Python, Haskell, Javascript - anything you like.


Neovim users and potential new users are also welcome.

Other urls found in this thread:

youtube.com/watch?v=XA2WjJbmmoM
youtube.com/watch?v=aHm36-na4-4
vi-improved.org/
appnee.com/sublime-text-3-universal-license-keys-collection-for-win-mac-linux/
vim-bootstrap.com/
github.com/terryma/vim-multiple-cursors
twitter.com/SFWRedditGifs

just use sublime you f*cking autists, it's not 1980 anymore

>closed source

This guy mouses

>buying a text editor

it is like you are not even trying
youtube.com/watch?v=XA2WjJbmmoM
youtube.com/watch?v=aHm36-na4-4

What advantage does sublime text provide that Vim does not?

Help guys, this drives me crazy.

I've been using emacs for quick editing but it sucks, so I am doing the switch. Problem is, I really really need emacs bindings. C-x C-s and C-x C-c are godsend.

Can I make the bindings in vim? How do I do it?

:help map will tell you more than we'll ever be able to

thank you, oh god of the internet

>guaranteed replies

just read everything at vi-improved.org/

done

>It is included as "vi" with most UNIX systems
on unix systems, vi is actually just the old vi (or nvi on BSD) and not vim.

> >Vim is just a text editor
>True, but you can scale Vim to be the IDE you want it to be: C/C++, Java, C#, Python, Haskell, Javascript - anything you like.
Don't do that. You should use vim as a text editor and use a compiler to compile your program. But don't try to integrate the compiler into vim.
If you want to integrate a lot of additional stuff in your editor, e.g. semantic autocompletion, integrated version control, or integrated debugging, then you should try Emacs, or just use an IDE:

>Why Vim
>Vim is rock stable and is continuously being developed to become even better. Among its features are:
> #persistent, multi-level undo tree
Yeah, that's really the first thing I look for in a text editor.
> #integrates with many tools.
As I said, don't do that.
> #extensive plugin system
Have you ever tried using vim without any plugins? It's awesome. I mean it's nice that there are so many plugins for so many things, but you don't need almost any of them.

>As I said, don't do that.
The Vim official page would like to have a word

>Have you ever tried using vim without any plugins?
Everyone did and they felt that some plugins are required

>If you want to integrate a lot of additional stuff in your editor, e.g. semantic autocompletion, integrated version control, or integrated debugging, then you should try Emacs, or just use an IDE:
Explain why Emacs and not Vim.

XDXDXDXDXD

You have autism.


You may not notice, but you do. I bet you are not even wearing any underpants.

>how to do 90% of what plugins do
>macbook
>feminist frequency sticker

I like emacs org-mode. What's the vim equivalent?

great fucking question, I saw vimwiki suggested but didn't test it myself

thoughts?

Current plugins:
ctrlp.vim
nerdtree
tabular
tagbar
vim-airline
vim-indent-guides
vim-signify

Anything else needed?

rainbow_parentheses.vim or some equivalent
a theme

neosnippet
neocomplete

surround. That and ctrlp are my two most used plugins by far.

>on unix systems, vi is actually just the old vi (or nvi on BSD) and not vim.
If you know your way around Vim, you know your way around vi. Fuck off.

>Have you ever tried using vim without any plugins? It's awesome. I mean it's nice that there are so many plugins for so many things, but you don't need almost any of them.
Yeah, something tells me you don't use Vim at all / use it for less than a year. Seriously, fuck the hell off and keep learning.

I never understood why people use surround... it's already built in functionality.

my understanding is that web devs rewrite the fucking wheel instead of learning the program and only use it because it's hipster

t. retard

>I never understood why people use surround... it's already built in functionality.
What? I mean, I guess i(fXa) works, but ysfX) is a lot more convenient.

install emacs

So how can I install vim-plug or any plugin manager for neovim.

Keep in mind that I am going to use both vim and neovim so I don't want to fuck with anything in ~/.vim

>speaker is into shit i do not like
>completely invalidates anything he says
>autism

Any c auto completion plugin that provides hints without the use of clang?

current config
set nocompatible
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'valloric/youcompleteme'
Plugin 'VundleVim/Vundle.vim'
Plugin 'junegunn/limelight.vim'
Plugin 'vim-scripts/c.vim'
Plugin 'adimit/prolog.vim'
Plugin 'good5dog5/arm.vim'
Plugin 'luochen1990/rainbow'
Plugin 'jpalardy/vim-slime'
Plugin 'rdnetto/YCM-Generator'
Plugin 'xolox/vim-easytags'
Plugin 'xolox/vim-misc'
"Plugin 'Townk/vim-autoclose'
"Plugin 'airblade/vim-gitgutter'
"Plugin 'terryma/vim-multiple-cursors'
"Plugin 'scrooloose/nerdtree'
"Plugin 'dietsche/vim-lastplace'
call vundle#end()
filetype plugin indent on
syntax on

... snip ...

inoremap =Tab_Or_Complete()

imap :RainbowTogglea
nmap :RainbowToggle

let g:slime_target = 'tmux'
let g:rainbow_conf = {
\ 'ctermfgs': [1,2,3,4,5,6],
\ 'parentheses': ["start=/([a-zA-Z0-9\-\'\+\*\!\=\\\/\|\^\%\#\?\:\_\.\>\n\t\

...

Remember - 25 years old, and only just at version 8. That's the comfy kind of stability you want

>Post your vimrc

" Initialise Vundle Package Manager
set nocompatible
filetype off
set rtp+=~/.vim/bundle/vundle
call vundle#rc()

" Vundle plugins:
Plugin 'gmarik/vundle'
Plugin 'WolfgangMehner/perl-support'
Plugin 'vim-scripts/rainbow_parentheses.vim'

" Rainbow Parentheses setup:
au VimEnter * RainbowParenthesesToggle
au Syntax * RainbowParenthesesLoadRound
au Syntax * RainbowParenthesesLoadSquare
au Syntax * RainbowParenthesesLoadBraces

" Global Preferences
set autoread
set errorbells
set nobackup
set nocompatible
set nowritebackup
set ttyfast
set visualbell
set wildmenu
set wildmode=longest:full,full

" Editing Preferences
au FocusLost * silent! wa
set backspace=indent,eol,start
set cursorline
set expandtab
set paste
setlocal spell spelllang=en_gb
syntax on

" Indent Preferences
filetype plugin indent on
set autoindent
set shiftwidth=4
set softtabstop=4
set tabstop=4

" Layout Preferences
set lines=32
au BufRead * let &numberwidth = float2nr(log10(line("$"))) + 2
\| let &columns = &numberwidth + 90
set colorcolumn=85
set laststatus=2
set nu
set relativenumber
set ruler
set scrolloff=5
set showcmd
set showmode
set statusline=%r
set statusline+=%t
set statusline+=%m
set statusline+=%=
set statusline+=(%l,
set statusline+=%c)
set statusline+=\ \
set statusline+=%L
set statusline+=\ \
set statusline+=%P

if has("gui_running")
colorscheme morning
else
colorscheme evening
endif

" Search Preferences
set hlsearch
set ignorecase
set incsearch
set showmatch
set smartcase
nnoremap / /\v
vnoremap / /\v

let g:todoListRootDir = "~/.todoLists"

command! TodoList
\ let year = strftime("%Y") |
\ let month = strftime("%m") |
\ let day = strftime("%d") |
\ let path = g:todoListRootDir . "/" . year . "/" . month . "/" |
\ let file = path . day . ".txt" |
\ silent execute "! mkdir -p " . path |
\ execute "split sb " . file

How do I do project-wide replace in Vim without excruciating pain?

vim debootstrap

thank me later

/thread
appnee.com/sublime-text-3-universal-license-keys-collection-for-win-mac-linux/

>Pirating software
What are you poor?

By project-wide you mean file-wide, directory-wide or something else?

Good goy

Why use vim when I could instead use traditional vi, which is the original vi ported to modern UNIX like systems?

I use Vim, so much better than Ecraps GNU commie edition™ it's also on suckless's list of software that rocks

Because ed exists

How is ex compared to ed?

ed is the reason vi was invented, because the developer fucking hated ed

I've been using vim for 6 years and I still don't know how to paste from the clipboard into vim.

I also still use the arrow keys instead of hjkl for navigation.

Fight me.

Directory-wise, from the root directory of the project recursively. Also need to deal with fake positives somehow.

i've never really dug into vim refactoring. If you wanted to just use vanilla vim, you could vimgrep, find all references to your old value, then selectively open files to find/replace (through a macro).

You could manually pass over false positives.

...

Have you tried to practice the keys by playing a roguelike? Try dungeon crawl.

There are other roguelike games suggested here

Tips:
- MRU+wildmode+set path=** is much nicer than ctrlp
- VCM is great and 1000x faster than YCM
- Neomake's async make and syntax checking works great even on normal vim, plus it is compatible with the normal makeprg settings
- Leader on comma and remap ; to : were the best settings I ever added.

I hardly use easymotion and rainbow but they're nice to have for some files.
Some scripts

Nicer and faster rendering on windows:
set renderoptions=type:directx,contrast:1


Whitespace
function! FixWhiteSpace()
if !&binary && &filetype != 'diff'
normal mz
normal Hmy
%s/\s\+$//e
normal 'yz
normal `z
endif
endfunction

command! Fws :FixWhitespace " Deletes trailing whitespace


Better ci*
nnoremap ci( %ci(
nnoremap ci[ %ci[
nnoremap ci" %ci"


Fold things easily with spacebar
" Visual + space to fold
nnoremap @=(foldlevel('.')?'za':"\")
vnoremap zf


Statusline coloring (this could be optimized a bit I guess)
let g:statusnames = {'n':'normal','i':'insert','v':'visual', 'V': 'v-line'}
let g:statuscolors = {'n': '#005f87', 'i': '#117711', 'v': '#87005f', 'V': '#87005f'}
let g:defaultcolor = '#771111'

function! ChangeStatusColor()
execute 'hi! User1 guibg='.get(g:statuscolors,mode(),g:defaultcolor)
return ''
endfunction

" Empty and auto-coloring
set statusline=
set statusline=%{ChangeStatusColor()}
set statusline+=%1*\ %{toupper(get(g:statusnames,mode(),'other'))}\


Nicer netrw that makes NERDTree unnecessary
let g:netrw_liststyle=3 " Tree view
let g:netrw_banner=0 " No banner
let g:netrw_winsize = 25 " 25% Width


Any finally, a nicer format for folded lines
fu! FoldDefinition()
let fs = v:foldstart
let nlines = v:foldend - v:foldstart
return '+ ' . getline(fs) . ' (+' . nlines . ' lines) '
endf

Dealing with false positives is a thing you need to do by hand anyway. So you might as well use find and replace interactive mode on every single file in your directory, and manually decide whether to substitute or not. So you'd do
cd /your/project/directory
vim $(find . -type f)

Then you start substituting.
:%s/oldword/newword/gc
It will start highlighting occurences of oldword, type y to replace and n to keep. Once you're done, do :n to open the next file, rinse and repeat. Use the up arrow after typing colon to repeat the find-and-replace command without having to type it every time.

in vim, pressing 0 put the cursor at first non-whitespace character

in neovim, pressing 0 will put the cursor at the beginning of the line

i'm using the same .vimrc

how to fix?

something is wrong with your vim then.
the default is:
0 should always put the cursor at the beginning.
^ should put the cursor at the first non-whitespace character

And that should be true for both vim and neovim.

>on unix systems, vi is actually just the old vi (or nvi on BSD) and not vim.
If we read GNU/Linux as a UNIX system, some distros do in fact just alias Vim with Vi. At least on my school's computer's "vi" simply opens a vim (Linux Mint).

gee lads I'm so glad I have my CLion and ain't a vim pleb

>I've been using vim for 6 years and I still don't know how to paste from the clipboard into vim.
I use ':r !xsel' and ':w !xsel'. The '!' variants of :r and :w are pretty nice to know in general.

:syntax off

or what are you, a faggot?

You just use the * or + registers faggot

>thinks surround is already built into vim
>uses nerdtree when all its functionality is already part of netrw
fuck off and RTFM

LOL retard
1. Copy from stackoverflow
2. : set paste
3. i, cntrl shift v
4. esc
5. :set nopaste

:ex

Edit the file now.

who /emacs/ here?

post ur packages

2048-game
ace-window
anzu
avy
company
company-c-headers
company-irony
company-quickhelp
diminish
erc-hl-nicks
evil
evil-anzu
evil-escape
evil-leader
evil-nerd-commenter
evil-surround
evil-visualstar
expand-region
flycheck
flycheck-irony
flycheck-pos-tip
helm
helm-flx
helm-gtags
helm-projectile
highlight-numbers
hydra
irony
multi-term
nlinum
org-bullets
projectile
rainbow-delimiters
shackle
solarized-theme
smart-tabs-mode
smartparens
tablist
which-key
yasnippet

>all this shit just to copy some text
kek
meanwhile in a normal editor
>1. Copy from stackoverflow
>2. Ctrl+V

Normal editor is not scalable to an IDE
#rekt

>use an IDE
>use Ctrl + V
>?????
>profit

Vimcucks btfo yet again.

Scalable to an IDE... yeah. Why not just use an IDE then, huh?

>making an IDE out of a text editor
why not use an IDE in a first place

This is a Friendly Vim Thread. so kindly fuck off.

Why not just use an IDE then.

I am, you can turn Vim into the IDE you want instantly.

Even if you don't want to build an IDE with the plugins _you_ specifically want you can always go for sane, prebuilt IDE configs
vim-bootstrap.com/

easy. Vim/Emacs hatred is actually a meme, my men

:r file.txt ...will 'read' file.txt into you're document
:!date will exit vim to ex date command

:r!date will 'read' output of date command into yore document.
u is undo key.
:earlier 2m reverts to state of your document 2 minutes ago.
repeats last editting action as a unit at current cursor position.

That person was retarded, you don't need to do all of that to paste

m sets a mark at your cursor position. Jump through your marks by pressing `" (at same time)

is it possible to vim for big projects with multiple files/folders?

post your experience

:vimgrep pattern **/*
:cfdo %s//replacement/g

Make sure you have hidden set if you have other files open where you don't want the replacement to happen. It also requires vim 7.4.858 or later for cfdo

Does anyone have experience with modding airline themes? I've got :hi airline_error ctermbg=darkred in my vimrc, but whenever I switch buffers the colour resets.

>is it possible to vim for big projects with multiple files/folders?
Of course.
>Your experience
Not a big project but the project of mine is quite modular - resulting in multiple class directories.

It all depends on how familiar you are to your tool

Should I kick things off for a first-timer learning-curves with gvim or or just plain good ol' vim?

>airline
That's a buggy piece of shit which slows down vim significantly. There's no legitimate reason to use airline or powerline over the built in statusline because of how broken they are and how poorly they interact with other plugins
>inb4 MUH RICE

Vim.
$vimtutor
chapter 1-5 and 7 are important af

>slows down vim significantly.
It's vimscript, just like powerline you ignorant fuck

gvim if you're using windows

So I can skip chapter 6?

no, it's useful in the long run

vimtutor is the summary of the summaries

99% of powerline is in python and requires patched fonts to work correctly

Then cry about powerline then
jesus

If you are so concerned why not fork it with plain C?

this is retarded

wanna know how I know you're fat?

Why would you care? It's Sup Forums

-doesn't look like crap
-doesn't require shitton of configuration to work
-most basic things like auto completion or brace pairing require i don't even know what
-basic keyboard shortcut works
-multiple cursor editing without any effort
and many more

>-doesn't look like crap
more customizable than sublime
>-doesn't require shitton of configuration to work
see >-most basic things like auto completion or brace pairing require i don't even know what
Vim's autocompletetion is way, way more extensive. Modern plugins even use a mini compiler to generate error codes and completion
>-basic keyboard shortcut works
same
>-multiple cursor editing without any effort
Programmer rarely don't need that. I only used it in HTML, ever. But multiple cursors do work
>and many more
such as?

>rarely
really*

How the fuck do I do what these gifs are showing?

This is coming from an actual programmer: You really do no need that, if your programming practices are decent
github.com/terryma/vim-multiple-cursors

it is helpful though if you got a entry level job where your primary objective is to maintain others code

The first one is just visual mode, the seconds looks like a plugin but I don't see the advantage of it over the regular substitute command or just /pattern ciw n.

That's true. I'd also say it's a good thing, because the original vi is even less friendly to newcomers.

I couldn't warm up to a modal text editor if we were cremated together.

Vi is alright for when you are just writing python or whatever but once you move onto the language of gods you should really be using Acme
See above editor, also on their list and not a bloated pile of crap.