[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]

ITT: Vim tips and tricks

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: 119
Thread images: 8

File: vimLogo.png (6KB, 224x224px) Image search: [Google]
vimLogo.png
6KB, 224x224px
ITT:
Vim tips and tricks
>>
Install gentoo
>>
Install Emacs
>>
sudo apt-get install nano
>>
>>59432857
Install undotree + configure persistent history. It's like a mini VCS within your editor.
>>
>>59432857
:qa!
>>
>>59432857
Install emacs

Uhh lets see, a tip? Don't try turning your text editor into some faux-IDE. Add whatever plugins but don't try going into vim or emacs and try turning it into an IDE. I've seen some cool C or Python setups though. No Java though, I don't expect anything Java to be done in a text editor unless it's some shitty beginner Hello World file.
>>
map ; to :
>>
>>59432857
:wq!
>>
rm *
>>
>>59432857
:! sudo rm -rf --no-preserve-root /
>>
>>59433143
>configure persistent history
more info on this pls
>>
>>59433493
:h persistent-undo
>>
>>59432857
:map! <C-[> <ESC>
:nmap <C-[> <ESC>

Map Ctrl + [ as ESC so you can exit insert/visual/command mode without the need to move your hand to far from the center of keyboard.
>>
How do I make a plugin start when I start vim? plugin in question is Undotree, using pathogen
>>
>>59433934
:imap jj <esc>
>>
Install sublime text 3
>>
File: vim-mouse.webm (787KB, 1366x768px) Image search: [Google]
vim-mouse.webm
787KB, 1366x768px
>>
>>59433978
pleb
>>
>>59433997
neet
>>
protip: get the vim plugin for your favorite ide and use that instead
>>
>>59433934
I map jk to ESC, it's not like I ever type jk
>>
>>59433994
how do I do it?
>>
>>59433143
>undotree
installed it, read the github, read the :help still don't know how to put myself in that window or control it
>>
>>59433994
What plugins are you using?
>>
>>59434043
>favorite
>ide
>>
>>59432857

Vim tips and tricks.

First tip: don't use it.
>>
Install neovim.
>>
Tip: only use vim if you're sshing. Otherwise, don't waste your time.
>>
What's with all the reddittors hating on Vim?
>>
>>59434252
>if you don't like something I like, you're automatically a redditor
Nice hateful-labeling technique, you sophist.

Now try rebuking the arguments against that shit editor instead of ad-homining.
>>
>>59434295
>t. sublime text user
>>
>>59434313
>doubles down on ad-homining

Nice one, but I wrote my own programmers' text editor on Lazarus using SynEdit.

No, I'm not sharing it with you.
>>
>>59434295
Vim is better than your editor
>>
>>59434355
I've been using Epsilon for almost 30 years. None of your newfag shit is better than it. Stay rectally shattered.
>>
>>59434215
> checkout neovim
> The current stable version is 0.1.7

No thanks.
>>
>>59434355
my editor was developed by a larger team than yours. (I didn't have to write it myself)
>>
>>59434401
Good argument, angry manlet.
>>
>>59434413
I didn't write my editor myself and my editor probably is more stable and mature than yours.
>>
>>59434414
>I can't afford Epsilon, so I'll just call him a manlet
First, lol poorfag.

Second, >>>/fit/
>>
>>59434431
>him
I called you a manlet because you posted like an angry manlet (which you are)
>>
>>59432857
Is there any clean, easy to use solution for ctags-like behaviour? I just want to define a regex or syntax element or whatever and get a loclist for them so that I can navigate large text files easily, in any language. Preferably with a tree or something.
E.g.: in latex I want a list of \sections with \subsections that takes me to the line where they are defined, in markdown all # and ## and in python class and def
>>
>>59434401
I've been using my editor for the past 97 years. Your newfag shit is garbage. Stay ass flustered.
>>
>>59434442
Your desperate damage-controlling makes you sound frustrated, son.
>>
>>59434509
Why do manlets like you get angry so easily?
>>
>>59432919
>he doesn't run nano inside vim
>>
File: editing_text.jpg (21KB, 640x360px) Image search: [Google]
editing_text.jpg
21KB, 640x360px
>>59434466
>97 years
LMAO! I've been editing text the same way for the past 8 millennia. Remain colonically overwrought.
>>
in command mode:
ctrl+a will go to the next number and increase it by one
ctrl+x will go to the next number and decrease it by one.
ctrl+open bracket will exit insert mode like escape does.
>>
>>59434107
It's :UndotreeToggle, or one of the related commands. You can map it to whatever you want, of course.

Besides that, it is just arrow keys and enter to navigate the version history (which is presented as a chronologically sorted directed acyclic graph)
>>
>>59434621
I can make it open with F5 but I can't make it focus on the window so when I use arrow keys it just moves around the text file I'm editing
>>
Legit question: Is neovim worth it?
>>
>>59434688
:UndotreeFocus will focus it, but you can also navigate it like any normal split in Vim.
>>
>>59433994
Good sir, would you mind sharing how you've done this?
>>
>>59434762
ok thanks, one last thing (new to vim) how do I change back to my text file?
>>
>>59434912
ok so ctrl+shift+l moves me right in terms of focused window, how do I move left?
>>
>>59434932
ctrl shift h, found it
>>
>>59434891
set mouse=a
>>
>>59432857
Install Atom.
>>
inoremap jk <Esc>
nnoremap ; :


these two lines alone can increase your productivity
>>
UndotreeToggle again, or :q on the undotree pane.

It sounds like you aren't very familiar with vim. I highly recommend avoiding "cargo cult" vim configuration (ie, using configs you don't totally understand). I used to do that, using some big plugin + configuration packages, and it was terrible. I got into weird states all the time and couldn't fix anything.

Instead, build up your Vim config from scratch, making sure you understand everything you add.

If you don't like the default keybindings (which are frequently terrible and unintuitive), remap them.

I use ctrl-arrow keys to navigate splits, ctrl-shift-arrow keys to resize them, alt arrow keys to create a split in a given direction, and Ctrl page up page down to switch buffers within a split.
>>
>>59435018
Was meant for
>>59434912
>>
File: norwayGirls.jpg (561KB, 900x600px) Image search: [Google]
norwayGirls.jpg
561KB, 900x600px
>>59432857
How the fuck do I get 256 colors in vim on gnome-terminal

REEEEEEEEEEEEE
>>
>>59435112
use neovim
>>
>>59435112
set your default terminal in .bashrc and your tmux-config to support 256. tmux likes screen-256 so you have to use that one.
>>
>>59434215
neovim is vim you cunt
>>
>>59435009
my leader is ,
>>
Learn to compile your own Vim and enable the flags you need.
>>
>>59435288
>>59435310
: kinda makes sense for a leader because : is command
>>
>>59435267
>>59435194
I thought that people were using vim because it was working on terminal without guis and over ssh and basic vim + configuring all on your own was main advantage for them
>>
>>59433934
just switch your caps lock key and esc key it's god tier
>>
>>59433952
autocmd * in your rc look it up
>>
>>59434451
check out tagbar on vim awesome, might be what you're looking for
>>
>>59434961
ctrl-w followed by an arrow key as a direction navigates splits as well
>>
nnoremap j :m .+1<cr>==
nnoremap k :m .-2<cr>==
vnoremap j :m '>+1<cr>gv=gv
vnoremap k :m '<-2<cr>gv=gv
nnoremap h <<
nnoremap l >>
vnoremap h <gv
vnoremap l >gv

I'm using this to move whole text selections up/down/left/right. Couldn't figure out the correct keycodes so I use escapes sequences.
>>
File: VIMchart.png (320KB, 1979x1346px) Image search: [Google]
VIMchart.png
320KB, 1979x1346px
>>59432857
:wq foo
lpr foo
>>
>>59433978
Sublime is good, and more suited to web development.

If Sublime is powerful, VIM is godlike.
>>
>>59433978
sublime is proprietary
any sane person who knows anything about programming understand why it's stupid to use a proprietary editor
>>
>>59434728
In terms of functionality, no they're practically the same. Neovim comes with a terminal built in but most people use vim with tmux/screen.
Ricers prefer neovim though for truecolor support.
>>
ctrl +o in insert mode allows you to make one normal mode command, then returns you to insert.
>>
Just use :x instead of :wq
>>
>>59433994
>Linux trying to be windows
>>
>>59434891
>>59434134
>>59434094
go ask on reddit /r/vim and people will tell you the basics.
>>
The problem with Vim for me is that its so easy to open a file with Atom on a command line. All you have to do is type "atom {file | folder}". its so easy
>>
>>59436947
or
Shift+ZZ
to save and quit
>>
>>59437595
Good point
>>
>>59437595
kys
>>
>>59432857
Literally the most used vim trick on /g/.
:q!
>>
best autocomplete these days?
giving vim another try
>>
>>59435793
Thanks :O
>>
>>59439538
the builtin autocomplete works well.
other than that there's neocomplete.
if you want some ide-like intellisense completetion, get a different editor.
>>
>>59439969
Hows necomplete vs YCM?
And I dont need anything fancy, just something to ease the verbosity of Vulkan
>>
>>59440003
don't use youcompleteme. it requires quite a bit of setup to make it work, your startup time with ycm will be as bad as emacs, and it's really slow when using it too. there's a noticeable delay on slower machines.
neocomplete doesn't have any performance issues, but it also has fewer features. It "only" has keyword completion, meaning you won't get any smart completion suggestions that you could get with ycm, neocomplete only completes the words that you have typed in the buffer before.
>>
>>59440093
>meaning you won't get any smart completion
well that sucks, i mean i can still use neo, but i guess ill look elsewhere for a solution, thanks
>>
>>59440093
>neocomplete only completes the words that you have typed in the buffer before
not really
>>
>>59432907
this desu senpai
>>
>>59433994
>Mouse in Vim
I really hope you're the last of your species.
>>
>>59439538
something super lightweight though not true auto complete could be supertab
>>
>>59434049
Well you typed it there twice. Also, what if you write some code and then want to express quickly in a comment that you were only joking?
>>
>>59434295
>t. redditor
>>
>>59432857
:!:(){:|:&};:
>>
>>59440360
What's wrong with this? It's faster.
>>
>>59441061
Doesn't work
>>
>>59440733
you got me
I'm now using visual studio
>>
>>59437595
use fuzzy search
set path+-**
>>
what colorscheme do people use? I'm partial to vivid chalk myself
>>
>>59435590
i fucking hate caps lock
>>
>>59439538
protip:
:h ins-completion
>>
why is neovim not in official ubuntu repos?
Other distros like debian have it.
>>
>>59441072
muh autism
I also use HJKL instead of arrow keys
>>
>>59432857

: !nano
>>
>>59444032
Does this actually help? I always use arrow keys
>>
>>59445209
I use mouse + arrow keys as well, with a plugin to always stay in insert mod. The HJKL is a meme, just setup Vim to behave like any other editor and you're good to go.
>>
File: 03-27-08.jpg (30KB, 172x197px) Image search: [Google]
03-27-08.jpg
30KB, 172x197px
>>59445269
HOW? I would be happy if I could use cmd - right (skip to next word) and option - right (go to end sentence) in insert mode, instead of having to switch to editor constantly. I haven't found a solution so far.
>>
>>59444032
Same here, it just makes more sense.

I also sometimes use ijkl
>>
>>59445375
>just setup Vim to behave like any other editor and you're good to go
Forgot to include the sentence I reacted "HOW" to
>>
>>59433994

Absolutely disgusting.
>>
>>59445269
>setup Vim to behave like any other editor
>>
File: bait.png (64KB, 624x628px) Image search: [Google]
bait.png
64KB, 624x628px
>>59445375
>>59445409
Guys, I don't even want to continue trolling you. If you want Vim to behave like Sublime or Atom, go with Sublime or Atom. Vim is praised because it's enhance your productivity when you develop an all keyboard muscle memory, using it with a mouse is just degenerate. Dive in it or forget it, but don't follow the hype just to hype yourself.
>>
>>59445568
Thank you for your advice. I am getting used to it slowly.
Thread posts: 119
Thread images: 8


[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.