Page 1 of 1
My .vimrc
Posted: Tue May 27, 2014 3:08 pm
by Launfal
OK, so once I decided that Wordgrinder wasn't the tool for me (I really wanted to like it, but double-spaced screen lines and no printing capability were deal-breakers. The exporting stuff is nice, and the newer versions add more formats, but I digress.) I needed to do some stuff to my .vimrc to make it a better writing tool. (I know, I know, I should be using EMACS. One day I will, but for now, I already have an operating system installed.) Nothing fancy here, but like I said, I'm still building. I'll add some comments as to how I understand why I did what I did.
Code: Select all
" I don't want vim to act like vi. I just don't.
set nocompatible
" These four lines give me soft-wrapping to the screen length. I know all about
" the purists, but they can do what they want.
set wrap
set nolist
set linebreak
set textwidth=0
"These two lines are the built-in spell-check.
"Adding stuff to the user dictionary is as easy
"as a zg in command mode and looking for corrections is z=.
set spelllang=en_us
set spellfile=/home/launfal/.vim-spell.add
"I wished they had an option that would handle the first line like they do the last, but I take what I can get.
set display=lastline
" Just because the default is boring. Not that I notice much difference, but still.
set background=dark
colorscheme elflord
"Now comes some keybindings to get me away from using the arrows and page keys
"to navigate around. I want to get better with Vim-centric keys, since a lot of
"stuff is configured to use them, so I want to start learning the basic ones.
" These two lines scroll by screen-lines, saving a keystroke.
map j gj
map k gk
" This one is huge. I save a keystroke *every* time I need to enter a command.
map ; :
" These six lines disable the movement keys in command mode
" but leave them alone in insert mode whee I still need them.
map <up> <nop>
map <down> <nop>
map <left> <nop>
map <right> <nop>
map <PageUp> <nop>
map <PageDown> <nop>
That's it. I'm sure there's plugins and scripts and stuff I can cram in there, and as the need arises, I'll figure them out. But for now, when I need to get some writing done, Vim considerately stays out of my way.
Edited: previous version was unusable because of incorrect comment symbol/placement.
Re: My .vimrc
Posted: Tue May 27, 2014 3:17 pm
by machinebacon
+1 for this post, thanks a bunch! We have quite a handful of vimmers on board, let's see how the thread evolves :)
What's your opinion about spf13-vim?
And here something nice:
https://www.youtube.com/watch?v=aHm36-na4-4
Re: My .vimrc
Posted: Tue May 27, 2014 3:56 pm
by Launfal
^ Thanks. I'm no Vim expert by any means, but the stuff I do all the time, I'm pretty good at. I figure that to be about .00001% of what I could actually do.
As for spf13, I'd heard of it, and I like the idea, but I've never tried it. It looks like the Vim version of what EMACS does on a much smaller scale. I may download it and see what all the hooplah's about, but as with anything else, the purists have been circling the walls with their torches and pitchforks about it for years.
Cool video, but he's attained some alien-mind-meld-super-ninja skill that I can't quite relate to. I figure he's got like 12 fingers on each hand or something.
Re: My .vimrc
Posted: Tue May 27, 2014 4:33 pm
by kexolino
This is "mine", bits and pieces I've found over the internets
Code: Select all
" Enable Pathogen
execute pathogen#infect()
" LOOKS
" Load file type plugins and indentation
filetype plugin indent on
" Enable syntax highlighting
syntax enable
" Highlight current line
set cursorline
" Enable line numbers
set number
" Set terminal to 256 color
set t_Co=256
" Set GUI font
"set guifont=Terminus\ 9
" Set background
"set background=dark
let g:hybrid_use_Xresources = 1
" Set color scheme
colorscheme Tomorrow-Night
" Set tab to 4 spaces
set tabstop=4 shiftwidth=4
" Use spaces instead of tabs
set expandtab
" Backspace through everything in insert mode
set backspace=indent,eol,start
" SEARCHING
" Highligh matches
set hlsearch
" Incremental searching
set incsearch
" Searches are case insensitive
set ignorecase
" if they don't contain any capital letters
set smartcase
"Split pane settings
nnoremap <C-J> <C-W><C-J>
nnoremap <C-K> <C-W><C-K>
nnoremap <C-L> <C-W><C-L>
nnoremap <C-H> <C-W><C-H>
set splitbelow
set splitright
Other than the split pane settings, there are no rebinded keys; I'm pretty satisfied with the defaults.
One more thing to note, I use
autocomplpop for a basic automplete feature, which I find speeds things up considerably a few lines into da code, but it can be helpful no matter what you do.
Edit: almost forgot to link to
pathogen.
Re: My .vimrc
Posted: Tue May 27, 2014 6:22 pm
by ivanovnegro
Nice thread. Mine is pretty basic so I won't post it, it is anyway on Github BBQ (apps).
/Subscribed
Re: My .vimrc
Posted: Tue May 27, 2014 9:39 pm
by dkeg
good thread, why didn't we already have this? Like ivanov, mine is in github. I can post here too later when at home.
btw laundry, I fixed your post with code tags.
Re: My .vimrc
Posted: Tue May 27, 2014 10:39 pm
by pidsley
My .vimrc is also in the bbq github.
Most useful bits; line-number toggle function and bash comment/uncomment functions.
Code: Select all
function! NuTriState() " toggle through line-number modes
if(&rnu) " turn off line numbering
set nonu
set nornu
elseif(&nu) " normal numbers on, add relative numbers (hybrid mode)
set rnu
else " normal numbers off, turn them on
set nu
endif
endfunc
nnoremap <silent><F2> :call NuTriState()<cr>
" select lines in visual mode, ,ic adds # comments, ,rc removes
map ,ic :s/^/#/g<CR>:let @/ = ""<CR>
map ,rc :s/^#//g<CR>:let @/ = ""<CR>
Re: My .vimrc
Posted: Wed May 28, 2014 5:31 am
by machinebacon
^ & ^^ & ^^^ ...which means that Laundry should have a bbq-kindish github account, too :)So Laundry, if you have a github account, let us know about it. I'll add you to the bbq github group later and edit this post accordingly.
Re: My .vimrc
Posted: Thu May 29, 2014 5:31 pm
by Launfal
I don't have an account yet, but I will, next day or so.
OK, what are the frames for a code-tag? This is not the first time that I haven't used them, and I just realized that I don't know how.
I just signed up, but I don't know what to do with it. I'm betting that comes in lesson two. Launfal, just like I am here.
edited: Update on github account.
edit by bacon:
Re: My .vimrc
Posted: Thu May 29, 2014 5:38 pm
by GekkoP
You mean "
Code: Select all
" (without the quotes, of course)?
Re: My .vimrc
Posted: Thu May 29, 2014 6:12 pm
by machinebacon
Laundry, check your post above, I added a demo for you ;)
Re: My .vimrc
Posted: Fri May 30, 2014 2:20 pm
by Launfal
^ Sweet. I'll get the hang of all this eventually.
Re: My .vimrc
Posted: Fri May 30, 2014 2:28 pm
by wuxmedia
http://en.wikipedia.org/wiki/BBCode
Most of these work. if you got to the 'full editor' button on the reply box, you can play with a bunch of stuff including youtube embeds and picture uploads.
Edit: where is that page where we drew flags with bbcode?
Re: My .vimrc
Posted: Fri May 30, 2014 11:11 pm
by franksinistra
mine is definitely ... hyperbloated
Code: Select all
set nocompatible
" Vundle {{{
filetype off
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
" let Vundle manage Vundle
Bundle 'gmarik/vundle'
" Vundles
"
Bundle 'tpope/vim-fugitive'
Bundle 'tpope/vim-endwise'
Bundle 'tpope/vim-surround'
Bundle 'tpope/vim-scriptease'
Bundle 'tpope/vim-ragtag'
Bundle 'tpope/vim-markdown'
Bundle 'tpope/vim-unimpaired'
Bundle 'scrooloose/nerdtree'
Bundle 'jistr/vim-nerdtree-tabs'
Bundle 'vim-ruby/vim-ruby'
Bundle 'kchmck/vim-coffee-script'
Bundle 'kien/ctrlp.vim'
Bundle 'itchyny/lightline.vim'
Bundle 'vim-scripts/YankRing.vim'
Bundle 'tomtom/tlib_vim'
Bundle 'tomtom/tcomment_vim'
Bundle 'tomtom/tselectbuffer_vim'
Bundle 'tsaleh/vim-matchit'
Bundle 'lilydjwg/colorizer'
Bundle 'shemerey/vim-project'
Bundle 'Twinside/vim-codeoverview'
" General settings {{{
syntax on
filetype off
filetype plugin indent on
set title
set mouse=a
set shortmess=at
set nrformats+=alpha
set modeline
set modelines=5
set number
set ruler
set cursorline
set backspace=2
set background=dark
set hidden
set confirm
set equalalways
set lazyredraw
set noshowmode
let mapleader=","
let maplocalleader=","
let g:nerdtree_tabs_open_on_console_startup=0
" }}}
" General Keybinds {{{
let mapleader = ","
map <F2> <Esc>:TSelectBuffer<CR>
map <F4> <Esc>:TlistToggle<CR>
nmap <silent> <leader>md :!mkdir -p %:p:h<CR>
" }}}
" Styling {{{
colorscheme year_of_the_horse
" }}}
" Status line {{{
set laststatus=2
let g:lightline = {
\ 'colorscheme': 'erosion',
\ 'component': {
\ 'readonly': '%{&readonly?"\
" toggle wrapping
nmap <silent> <F12> :let &wrap = !&wrap<CR>
" }}}
" RagTag {{{
imap <M-O> <Esc>o
imap <C-J> <Down>
let g:ragtag_global_maps = 1
imap <C-Space> <C-X><Space>
imap <C-CR> <C-X><CR>
" }}}
" Ctrlp plugin options {{{
let g:ctrlp_map = '<c-p>'
let g:ctrlp_cmd = 'CtrlP'
let g:ctrlp_working_path_mode = 'ra'
set wildignore+=*/tmp/*,*.so,*.swp,*.zip " MacOSX/Linux
set wildignore+=*\\tmp\\*,*.swp,*.zip,*.exe " Windows
let g:ctrlp_custom_ignore = '\v[\/]\.(git|hg|svn)$'
let g:ctrlp_user_command = 'find %s -type f'
" }}}
Re: My .vimrc
Posted: Sat May 31, 2014 3:22 pm
by GekkoP
Not a vi/vim user here, although I know the basics. But thanks for this topic, really interesting stuff. I will try to use only vim for a week and see if it suits me.
Re: My .vimrc
Posted: Thu Mar 10, 2016 11:13 am
by aaah
Just some bits from my .vimrc
Code: Select all
"-------------------------------------------
"Display the numbered registers, press a key and paste it to the buffer, so use :Reg or make a keybinding to it
" I made Ctrl+x r to call it
function! Reg()
reg
echo "Register: "
let char = nr2char(getchar())
if char != "\<Esc>"
execute "normal! \"".char."p"
endif
redraw
endfunction
command! -nargs=0 Reg call Reg()
" Control-x r = show paste register and choose number
noremap <C-x>r :call Reg()<CR>
"--------------------------------------------
"highlight line when over 80 characters
highlight OverLength ctermbg=red ctermfg=white guibg=#592929
match OverLength /\%81v.\+/
"--------------------------------------------
"So that the File, Open dialog defaults to the current file's directory.
set browsedir=buffer
"-------------------------------------------
function! DmenuOpen(cmd)
let fname = Chomp(system("ls | dmenu -i -l 20 -p " . a:cmd))
if empty(fname)
return
endif
execute a:cmd . " " . fname
endfunction
" use \ddt to open file in a new tab
" use \dde to open file in current buffer
map <leader>ddt :call DmenuOpen("tabe")<cr>
map <leader>dde :call DmenuOpen("e")<cr>
"--------------------------------------------
"Set relative number on starup but can toggle it with a keybinding
set relativenumber
"--Some of my keybindings --------------
"Toggle relative line numbering on and off
nnoremap <silent><leader>n :set relativenumber!<cr>
"toggle line numbering by pressing ctrl and l (twice)
:nmap <C-l><C-l> :set invnumber<CR>
" When in insert mode, you can move the cursor by using CTRL+h, CRTL+j, CTRL+k or CTRL+l
imap <C-h> <C-o>h
imap <C-j> <C-o>j
imap <C-k> <C-o>k
imap <C-l> <C-o>l
" Create Blank Newlines and stay in Normal mode
nnoremap <silent> zj o<Esc>
nnoremap <silent> zk O<Esc>
" surround current word with brackets by typeing \b
:nnoremap <leader>b viw<esc>a)<esc>hbi(<esc>lel
Re: My .vimrc
Posted: Thu Mar 10, 2016 11:58 am
by wuxmedia
Slightly tempted by a custom vim.
Main problem is I mostly use vim on the servers - which are all vanilla.
Re: My .vimrc
Posted: Mon Jul 03, 2017 9:51 pm
by elixir
Simple line that will highlight all characters after a specific column width in red. This has been very useful for me with coding by keeping all lines within 80 characters in width.
Re: My .vimrc
Posted: Tue Jul 04, 2017 1:52 am
by pidsley
Timely necrobump. I just added this to my .vimrc today. Highlight trailing white space unless you are still typing on the line.
Code: Select all
highlight ExtraWhitespace ctermbg=red guibg=red
match ExtraWhitespace /\s\+$/
autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@!$/
autocmd InsertLeave * match ExtraWhitespace /\s\+$/
Re: My .vimrc
Posted: Tue Jul 04, 2017 8:34 pm
by wuxmedia
^ oh that's good one, I recently added a bit to have the trailing whitespace bit, but just pops up every so often.
thanks!
I actually filled it up with junk, which stopped some useful things working. So I debloated.