[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
Vim and other editors
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 39
Thread images: 4
File: Vimlogo.svg.png (90 KB, 1022x1024) Image search: [Google]
Vimlogo.svg.png
90 KB, 1022x1024
Completely and utter newfag on vim here.
It feels like I'm missing out on a lot of things by not having a good vimrc.
I only have:
set expandtab

set smarttab

set shiftwidth=4
set tabstop=4

set autoindent

syntax enable

What would you recommend? You could just post yours and say why you have a certain thing enabled.
I'd love for it to have autocompletion on language dictionaries and my own written functions from the file.
Aside from that, it's a very neat editor after going through vimtutor.
>>
File: bear_suit_lain_vector_by_saioul.png (179 KB, 1024x946) Image search: [Google]
bear_suit_lain_vector_by_saioul.png
179 KB, 1024x946
Shameless self bump.
>>
>>55394765
The most important part:

syntax on (not "enable")
filetype plugin indent on


For now, don't worry about manually setting up autoindent and stuff like that. It's okay to have defaults but you'll probably end up with settings specific to each language. Some of that will be set up by the language plugin, and other parts can go in your
after/indent/lang.vim
scripts.

The next thing is to set up a plugin that manages your other plugins, so you don't have to fuck around with installing things by hand. I like Vundle. I'll let you google that. I'll make a couple more posts about the plugins I use and what they do.
>>
>>55394765
dude, just use emacs lmao
>>
>>55395418
Neat. I'll be on the lookout then.
>>
>>55394765
set hlsearch
set incsearch

I find these useful, the first highlights all instances of what you're searching for, the second activates incremental searching, so you start getting results as soon as you type
>>
>>55394765

"disablle compatibility with Vi
set nocompatible

"Make tabs work as expected (and be proper tabs!)
set tabstop=4 "width of a tab in spaces
set softtabstop=0 "when this is non-zero, the tab key inserts a combination of spaces and tabs
set shiftwidth=4 "the width of the < and > commands
set noexpandtab "don't convert tabs to spaces

"Enable some fancy indenting
set autoindent
set smartindent

"Enable line numbers
set number

"Line wrap
set wrap "enable line wrap
set linebreak "don't break lines in the middle of a word

"Let the open brace key automatically insert a closing brace after hitting enter
inoremap {<CR> {<CR>}<Esc>ko

"In normal mode, oo inserts a newline below, and OO inserts a newline above
nmap oo o<Esc>k
nmap OO O<Esc>j

if has("gui_running")
"in gVim, disable the menu bar, toolbar and scrollbars
set guioptions-=m "menu bar
set guioptions-=T "toolbar
set guioptions -=r "right scroll bar
set guioptions-=L "left scroll bar
endif

"let the F4 key toggle between the .h and .cpp file
map <F4> :e %:p:s,.h$,.X123X,:s,.cpp$,.h,:s,.X123X$,.cpp,<CR>

"Don't automatically comment new lines
autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o
>>
Plugin 'jiangmiao/auto-pairs'


When you type a left parenthesis, this automatically inserts a right parenthesis after the cursor. Same thing for square brackets, curly braces, and quotes. Then you can "type over" the closing character, so you don't really have to change your typing habits. Some people don't like it. I'm pretty fond of it. Give it a shot.

Plugin 'tpope/vim-surround'


Extends Vim's text object manipulation with various ways of addressing matching pairs (so it goes hand in hand with the above plugin). For example, if the cursor is between two square brackets and you need to change them to curly braces, you can type cs]} and it'll do that in one edit. Also works on angle brackets, quotes, even HTML tags.
>>
Who /GNUemacs/ here?
>>
Plugin 'Shougo/neocomplete.vim'


Better autocompletion, including complete-as-you-type. It's a minor pain in the ass to set up, mostly because you have to do it for each language, but once it's working it's pretty great.

Plugin 'reedes/vim-thematic'


If you find yourself changing certain settings at the same time, like switching to a certain color scheme and changing the font (in the GUI version) then this lets you automate some of that. Not actually useful, just convenient.

Plugin 'godlygeek/csapprox'


Makes GUI color schemes work in the terminal. (If you're on Windows, this is useless, but whatever.)

Plugin 'itchyny/lightline.vim'


There are like 15 different plugins for changing the look of the tab bar and status bar. This is one of them. I like it because it actually works and doesn't have any crazy dependencies.
>>
>>55395868
>because you have to do it for each language
Do I need a dictionary for each language then? Also, what about user defined functions?
>>
>>55395457
Emacs getting a new graphical browser in emacs 25 is going to be pretty cool.
>>
>>55396245
didn't know that

hopefully it's more useful than listing the phases of the moon
>>
>>55395708
>>55395868
If you're going to add that many plugins, you're better off using Emacs.
>>
>>55394765
https://dotfiles.github.io
>>
set ruler
set scrolloff=4

set wildmenu
set wildmode=longest,list
>>
Plugin 'scrooloose/nerdtree'
Plugin 'vimwiki/vimwiki'


Both of these are classics.

Also:

"remap escape and capslock in vim

au VimEnter * !xmodmap -e 'clear Lock' -e 'keycode 0x42 = Escape'
au VimLeave * !xmodmap -e 'clear Lock' -e 'keycode 0x42 = Caps_Lock'


This remaps escape as capslock inside of vim.

If you do decide to use vimWiki (and a lot of people have vim only for this reason), this is helpful.

" Run multiple wikis "
let g:vimwiki_list = [
\{'path': '~/Documents/VimWiki/main'},
\{'path': '~/Documents/VimWiki/work'},
\{'path': '~/Documents/VimWiki/creative'},
\{'path': '~/Documents/VimWiki/household'},
\{'path': '~/Documents/VimWiki/organization'},
\{'path': '~/Documents/VimWiki/technical'},
\]

au BufRead,BufNewFile *.wiki set filetype=vimwiki


This lets you run multiple predefined wikis and switch them using <Leader>ws
>>
>>55394765
just use atom with vim bindings
>>
>>55398219
Atom isn't even on my non-free repos. I could build it, but I don't want botnet.
>>
>i don't like VIM because my .vimrc is wrong!!!
no

you're using vim wrong

you start off with the most minimal install you can, then piecemeal identify features you wish vim had, then add them.

you dont start off with a starter pack of changes that someone else drops in your lap, because then you dont understand why they're helpful and why you should use them
>>
:e $HOME/.vimrc

http://pastebin.com/PaT6h03K
>>
>>55394765
>>55395528

set backup
set backupdir=~/.backup
set relativenumber
set ruler

map <C-j> <C-w>j
map <C-k> <C-w>k
map <C-h> <C-w>h
map <C-l> <C-w>l

map! ,, <Esc>
>>
>>55396245

> adding even more bloat shit to emacs
>>
>>55394765

build your vim rc while reading through this

http://stevelosh.com/blog/2010/09/coming-home-to-vim/
>>
>>55394765
I always map jk for esc
>>
>>55401992
Bloat is very subjective and an opinion.
>>
>>55396245
let me know when they get a new text editor lmao
>>
>>55402328
What the fuck is your shitposting supposed to mean?
>>
>>55402022
Only if you're shilling Emacs. If, on the other hand, you don't use Emacs as your designated shitting editor, it is very easy to specifically define.
>>
>>55401436
What does the clump of four lines do? I found that in my vimrc the other day because I snatched it from somewhere a while ago but I still don't know what this does.
>>
>>55402619
>>55401436
I'm retarded. I'm referring to the second clump of four lines.
>>
>>55402608
Okay, kid.
>>
Some plugins you might want
vundle (plugin manager)
tabular (alignment)
fugitive (git)
ultisnips (snippets)
syntastic (syntax errors)
youcompleteme (autocomplete)
>>
File: 1466499452179.jpg (74 KB, 1008x617) Image search: [Google]
1466499452179.jpg
74 KB, 1008x617
>>55395457
Emacs is the systemd of text editors. It tries to do everything, even things that are not needed and ends up bloated.
>>
/g/ definitely does not have the attention span for emacs... which is fine, because emacs can get next level. emacs is great if you can program in ELISP and want to use emacs to run your entire personal life and stem career, but most people will never get there

you guys can have fun writing hello world and editing zshrc in nano/vim/sublime text (so productive)
>>
>>55403063
At least make the bait funny, it's just asinine.
>>
File: bsadqvA.jpg (72 KB, 960x648) Image search: [Google]
bsadqvA.jpg
72 KB, 960x648
>>55403084
>he can't program worth shit
>he googled what is the best text editor
>he thought it was vim

how do you comment a block of code in Vim, again? Don't you have to change the mode three times? Isn't it minimum six steps?
>>
>>55403166
>how do you comment a block of code in Vim, again
You bind a key or a user command to it in your vimrc, just like any other action you find yourself doing often.
And no, you don't even have to change modes once, you could do the whole thing in one regex.
If you really wanted to record a macro for it, you could.
>>
>>55402608
For example, bloat is like compiling a spell checker into your text editor when *NIX already has spell checkers like aspell and hunspell, or compiling fucking grep into your text editor.

Oh wait.
Thread replies: 39
Thread images: 4

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

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.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.