This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 10 years ago.
I took my vimrc from a friend and it has some changes to the split bar. How do I restore it to the default split bar?
my .vim folder: here
and .vimrc:
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Maintainer: amix the lucky stiff
" http://amix.dk - amix#amix.dk
"
" Version: 3.6 - 25/08/10 14:40:30
"
" Blog_post:
" http://amix.dk/blog/post/19486#The-ultimate-vim-configuration-vimrc
" Syntax_highlighted:
" http://amix.dk/vim/vimrc.html
" Raw_version:
" http://amix.dk/vim/vimrc.txt
"
" How_to_Install_on_Unix:
" $ mkdir ~/.vim_runtime
" $ svn co svn://orangoo.com/vim ~/.vim_runtime
" $ cat ~/.vim_runtime/install.sh
" $ sh ~/.vim_runtime/install.sh <system>
" <sytem> can be `mac`, `linux` or `windows`
"
" How_to_Upgrade:
" $ svn update ~/.vim_runtime
"
" Sections:
" -> General
" -> VIM user interface
" -> Colors and Fonts
" -> Files and backups
" -> Text, tab and indent related
" -> Visual mode related
" -> Command mode related
" -> Moving around, tabs and buffers
" -> Statusline
" -> Parenthesis/bracket expanding
" -> General Abbrevs
" -> Editing mappings
"
" -> Cope
" -> Minibuffer plugin
" -> Omni complete functions
" -> Python section
" -> JavaScript section
"
"
" Plugins_Included:
" > minibufexpl.vim - http://www.vim.org/scripts/script.php?script_id=159
" Makes it easy to get an overview of buffers:
" info -> :e ~/.vim_runtime/plugin/minibufexpl.vim
"
" > bufexplorer - http://www.vim.org/scripts/script.php?script_id=42
" Makes it easy to switch between buffers:
" info -> :help bufExplorer
"
" > yankring.vim - http://www.vim.org/scripts/script.php?script_id=1234
" Emacs's killring, useful when using the clipboard:
" info -> :help yankring
"
" > surround.vim - http://www.vim.org/scripts/script.php?script_id=1697
" Makes it easy to work with surrounding text:
" info -> :help surround
"
" > snipMate.vim - http://www.vim.org/scripts/script.php?script_id=2540
" Snippets for many languages (similar to TextMate's):
" info -> :help snipMate
"
" > mru.vim - http://www.vim.org/scripts/script.php?script_id=521
" Plugin to manage Most Recently Used (MRU) files:
" info -> :e ~/.vim_runtime/plugin/mru.vim
"
" > Command-T - http://www.vim.org/scripts/script.php?script_id=3025
" Command-T plug-in provides an extremely fast, intuitive mechanism for opening filesa:
" info -> :help CommandT
" screencast and web-help -> http://amix.dk/blog/post/19501
"
"
" Revisions:
" > 3.6: Added lots of stuff (colors, Command-T, Vim 7.3 persistent undo etc.)
" > 3.5: Paste mode is now shown in status line if you are in paste mode
" > 3.4: Added mru.vim
" > 3.3: Added syntax highlighting for Mako mako.vim
" > 3.2: Turned on python_highlight_all for better syntax
" highlighting for Python
" > 3.1: Added revisions ;) and bufexplorer.vim
"
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => General
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Sets how many lines of history VIM has to remember
set history=700
" Enable filetype plugin
filetype plugin on
filetype indent on
set nocp
" Set to auto read when a file is changed from the outside
set autoread
" With a map leader it's possible to do extra key combinations
" like <leader>w saves the current file
let mapleader = ","
let g:mapleader = ","
" Fast saving
nmap <leader>w :w!<cr>
" Fast editing of the .vimrc
map <leader>e :e! ~/.vim_runtime/vimrc<cr>
" When vimrc is edited, reload it
autocmd! bufwritepost vimrc source ~/.vim_runtime/vimrc
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => VIM user interface
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Set 7 lines to the curors - when moving vertical..
set so=7
set wildmenu "Turn on WiLd menu
set ruler "Always show current position
set cmdheight=2 "The commandbar height
set hid "Change buffer - without saving
" Set backspace config
set backspace=eol,start,indent
set whichwrap+=<,>,h,l
set ignorecase "Ignore case when searching
set smartcase
set hlsearch "Highlight search things
set incsearch "Make search act like search in modern browsers
set nolazyredraw "Don't redraw while executing macros
set magic "Set magic on, for regular expressions
set showmatch "Show matching bracets when text indicator is over them
set mat=2 "How many tenths of a second to blink
" No sound on errors
set noerrorbells
set novisualbell
set t_vb=
set tm=500
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Colors and Fonts
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
syntax enable "Enable syntax hl
colorscheme 256-jungle
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Files, backups and undo
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Turn backup off, since most stuff is in SVN, git anyway...
set nobackup
set nowb
set noswapfile
"Persistent undo
try
if MySys() == "windows"
set undodir=C:\Windows\Temp
else
set undodir=~/.vim_runtime/undodir
endif
set undofile
catch
endtry
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Text, tab and indent related
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set expandtab
set shiftwidth=2
set tabstop=2
set smarttab
set lbr
set tw=500
set ai "Auto indent
set si "Smart indet
set wrap "Wrap lines
""""""""""""""""""""""""""""""
" => Visual mode related
""""""""""""""""""""""""""""""
" Really useful!
" In visual mode when you press * or # to search for the current selection
vnoremap <silent> * :call VisualSearch('f')<CR>
vnoremap <silent> # :call VisualSearch('b')<CR>
" When you press gv you vimgrep after the selected text
vnoremap <silent> gv :call VisualSearch('gv')<CR>
map <leader>g :vimgrep // **/*.<left><left><left><left><left><left><left>
function! CmdLine(str)
exe "menu Foo.Bar :" . a:str
emenu Foo.Bar
unmenu Foo
endfunction
" From an idea by Michael Naumann
function! VisualSearch(direction) range
let l:saved_reg = #"
execute "normal! vgvy"
let l:pattern = escape(#", '\\/.*$^~[]')
let l:pattern = substitute(l:pattern, "\n$", "", "")
if a:direction == 'b'
execute "normal ?" . l:pattern . "^M"
elseif a:direction == 'gv'
call CmdLine("vimgrep " . '/'. l:pattern . '/' . ' **/*.')
elseif a:direction == 'f'
execute "normal /" . l:pattern . "^M"
endif
let #/ = l:pattern
let #" = l:saved_reg
endfunction
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Command mode related
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Smart mappings on the command line
cno $h e ~/
cno $d e ~/Desktop/
cno $j e ./
cno $c e <C-\>eCurrentFileDir("e")<cr>
" $q is super useful when browsing on the command line
cno $q <C-\>eDeleteTillSlash()<cr>
" Bash like keys for the command line
cnoremap <C-A> <Home>
cnoremap <C-E> <End>
cnoremap <C-K> <C-U>
cnoremap <C-P> <Up>
cnoremap <C-N> <Down>
" Useful on some European keyboards
map ½ $
imap ½ $
vmap ½ $
cmap ½ $
func! Cwd()
let cwd = getcwd()
return "e " . cwd
endfunc
func! DeleteTillSlash()
let g:cmd = getcmdline()
if MySys() == "linux" || MySys() == "mac"
let g:cmd_edited = substitute(g:cmd, "\\(.*\[/\]\\).*", "\\1", "")
else
let g:cmd_edited = substitute(g:cmd, "\\(.*\[\\\\]\\).*", "\\1", "")
endif
if g:cmd == g:cmd_edited
if MySys() == "linux" || MySys() == "mac"
let g:cmd_edited = substitute(g:cmd, "\\(.*\[/\]\\).*/", "\\1", "")
else
let g:cmd_edited = substitute(g:cmd, "\\(.*\[\\\\\]\\).*\[\\\\\]", "\\1", "")
endif
endif
return g:cmd_edited
endfunc
func! CurrentFileDir(cmd)
return a:cmd . " " . expand("%:p:h") . "/"
endfunc
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Moving around, tabs and buffers
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Map space to / (search) and c-space to ? (backgwards search)
map <space> /
map <c-space> ?
map <silent> <leader><cr> :noh<cr>
" Smart way to move btw. windows
map <C-j> <C-W>j
map <C-k> <C-W>k
map <C-h> <C-W>h
map <C-l> <C-W>l
" Close the current buffer
map <leader>bd :Bclose<cr>
" Close all the buffers
map <leader>ba :1,300 bd!<cr>
" Use the arrows to something usefull
map <right> :bn<cr>
map <left> :bp<cr>
" Tab configuration
map <leader>tn :tabnew<cr>
map <leader>te :tabedit
map <leader>tc :tabclose<cr>
map <leader>tm :tabmove
" When pressing <leader>cd switch to the directory of the open buffer
map <leader>cd :cd %:p:h<cr>
command! Bclose call <SID>BufcloseCloseIt()
function! <SID>BufcloseCloseIt()
let l:currentBufNum = bufnr("%")
let l:alternateBufNum = bufnr("#")
if buflisted(l:alternateBufNum)
buffer #
else
bnext
endif
if bufnr("%") == l:currentBufNum
new
endif
if buflisted(l:currentBufNum)
execute("bdelete! ".l:currentBufNum)
endif
endfunction
" Specify the behavior when switching between buffers
try
set switchbuf=usetab
set stal=2
catch
endtry
""""""""""""""""""""""""""""""
" => Statusline
""""""""""""""""""""""""""""""
" Always hide the statusline
set laststatus=2
" Format the statusline
set statusline=\ %{HasPaste()}%F%m%r%h\ %w\ \ CWD:\ %r%{CurDir()}%h\ \ \ Line:\ %l/%L:%c
function! CurDir()
let curdir = substitute(getcwd(), '/Users/amir/', "~/", "g")
return curdir
endfunction
function! HasPaste()
if &paste
return 'PASTE MODE '
else
return ''
endif
endfunction
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Parenthesis/bracket expanding
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
vnoremap $1 <esc>`>a)<esc>`<i(<esc>
vnoremap $2 <esc>`>a]<esc>`<i[<esc>
vnoremap $3 <esc>`>a}<esc>`<i{<esc>
vnoremap $$ <esc>`>a"<esc>`<i"<esc>
vnoremap $q <esc>`>a'<esc>`<i'<esc>
vnoremap $e <esc>`>a"<esc>`<i"<esc>
" Map auto complete of (, ", ', [
inoremap $1 ()<esc>i
inoremap $2 []<esc>i
inoremap $3 {}<esc>i
inoremap $4 {<esc>o}<esc>O
inoremap $q ''<esc>i
inoremap $e ""<esc>i
inoremap $t <><esc>i
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => General Abbrevs
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
iab xdate <c-r>=strftime("%d/%m/%y %H:%M:%S")<cr>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Editing mappings
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"Remap VIM 0
map 0 ^
"Move a line of text using ALT+[jk] or Comamnd+[jk] on mac
nmap <M-j> mz:m+<cr>`z
nmap <M-k> mz:m-2<cr>`z
vmap <M-j> :m'>+<cr>`<my`>mzgv`yo`z
vmap <M-k> :m'<-2<cr>`>my`<mzgv`yo`z
"Delete trailing white space, useful for Python ;)
func! DeleteTrailingWS()
exe "normal mz"
%s/\s\+$//ge
exe "normal `z"
endfunc
autocmd BufWrite *.py :call DeleteTrailingWS()
set guitablabel=%t
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Cope
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Do :help cope if you are unsure what cope is. It's super useful!
map <leader>cc :botright cope<cr>
map <leader>n :cn<cr>
map <leader>p :cp<cr>
""""""""""""""""""""""""""""""
" => bufExplorer plugin
""""""""""""""""""""""""""""""
let g:bufExplorerDefaultHelp=0
let g:bufExplorerShowRelativePath=1
map <leader>o :BufExplorer<cr>
""""""""""""""""""""""""""""""
" => Minibuffer plugin
""""""""""""""""""""""""""""""
let g:miniBufExplModSelTarget = 1
let g:miniBufExplorerMoreThanOne = 2
let g:miniBufExplModSelTarget = 0
let g:miniBufExplUseSingleClick = 1
let g:miniBufExplMapWindowNavVim = 1
let g:miniBufExplVSplit = 25
let g:miniBufExplSplitBelow=1
let g:bufExplorerSortBy = "name"
autocmd BufRead,BufNew :call UMiniBufExplorer
map <leader>u :TMiniBufExplorer<cr>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Omni complete functions
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
autocmd FileType css set omnifunc=csscomplete#CompleteCSS
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Spell checking
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"Pressing ,ss will toggle and untoggle spell checking
map <leader>ss :setlocal spell!<cr>
"Shortcuts using <leader>
map <leader>sn ]s
map <leader>sp [s
map <leader>sa zg
map <leader>s? z=
""""""""""""""""""""""""""""""
" => Python section
""""""""""""""""""""""""""""""
let python_highlight_all = 1
au FileType python syn keyword pythonDecorator True None False self
au BufNewFile,BufRead *.jinja set syntax=htmljinja
au BufNewFile,BufRead *.mako set ft=mako
au FileType python inoremap <buffer> $r return
au FileType python inoremap <buffer> $i import
au FileType python inoremap <buffer> $p print
au FileType python inoremap <buffer> $f #--- PH ----------------------------------------------<esc>FP2xi
au FileType python map <buffer> <leader>1 /class
au FileType python map <buffer> <leader>2 /def
au FileType python map <buffer> <leader>C ?class
au FileType python map <buffer> <leader>D ?def
""""""""""""""""""""""""""""""
" => JavaScript section
"""""""""""""""""""""""""""""""
au FileType javascript call JavaScriptFold()
au FileType javascript setl fen
au FileType javascript setl nocindent
au FileType javascript imap <c-t> AJS.log();<esc>hi
au FileType javascript imap <c-a> alert();<esc>hi
au FileType javascript inoremap <buffer> $r return
au FileType javascript inoremap <buffer> $f //--- PH ----------------------------------------------<esc>FP2xi
function! JavaScriptFold()
setl foldmethod=syntax
setl foldlevelstart=1
syn region foldBraces start=/{/ end=/}/ transparent fold keepend extend
function! FoldText()
return substitute(getline(v:foldstart), '{.*', '{...}', '')
endfunction
setl foldtext=FoldText()
endfunction
""""""""""""""""""""""""""""""
" => MRU plugin
""""""""""""""""""""""""""""""
let MRU_Max_Entries = 400
map <leader>f :MRU<CR>
""""""""""""""""""""""""""""""
" => Command-T
""""""""""""""""""""""""""""""
let g:CommandTMaxHeight = 15
set wildignore+=*.o,*.obj,.git,*.pyc
noremap <leader>j :CommandT<cr>
noremap <leader>y :CommandTFlush<cr>
""""""""""""""""""""""""""""""
" => Vim grep
""""""""""""""""""""""""""""""
let Grep_Skip_Dirs = 'RCS CVS SCCS .svn generated'
set grepprg=/bin/grep\ -nH
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => MISC
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Remove the Windows ^M - when the encodings gets messed up
noremap <Leader>m mmHmt:%s/<C-V><cr>//ge<cr>'tzt'm
"Quickly open a buffer for scripbble
map <leader>q :e ~/buffer<cr>
au BufRead,BufNewFile ~/buffer iab <buffer> xh1 ===========================================
map <leader>pp :setlocal paste!<cr>
map <leader>bb :cd ..<cr>
"setting taglist to be opened at startup
let Tlist_Auto_Open = 1
"mapping keys for auto changing the colorscheme
map <silent><F3> :NEXTCOLOR<cr>
map <silent><F2> :PREVCOLOR<cr>
"to get function parameters shown from autocomplpop
let g:AutoComplPop_CompleteoptPreview = 1
"mapping key to save all the open buffers
map <silent><F4> :wa<cr>
the split bar shows like in the image. While I want it to be movable. What needs to be changed?
Thanks in advance.
You can move the horizontal split bar by pressing control-w follow by 10+ to increase the size of the active window by 10 lines in the vertical directions. (or - to decrease), e.g. move the ruler up or down.
The resize the vertical split bar, you can do something similar: control-w 10> or <. To move the split bar to the left or right.
I don't think this is related to the .vimrc that you give.
Related
I am setting up neovim, with CoC.
It seems to work well, but with one big problem: My diagnostic windows are very large
I am not sure why this is. I would expect this to be only a few lines. Ideally, it should show up somewhere not directly over the code, but I'm not sure how to configure this.
This is my neovim config:
call plug#begin('~/.config/nvim/autoload')
Plug 'easymotion/vim-easymotion' " Get to where you want to go fast
Plug 'nanotech/jellybeans.vim' " Pretty theme
Plug 'scrooloose/nerdtree'
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'junegunn/fzf.vim' " Fuzzy search
Plug 'jiangmiao/auto-pairs', { 'tag': 'v2.0.0' } " auto-pairs of parens
Plug 'Olical/conjure', {'tag': 'v4.15.0'} " Interactive Clojure Eval
Plug 'guns/vim-sexp' " paredi for vim
Plug 'tpope/vim-sexp-mappings-for-regular-people'
Plug 'clojure-vim/clojure.vim'
Plug 'neoclide/coc.nvim', {'branch': 'release'} " Language servers for vim!
Plug 'w0rp/ale' " linter -- TODO: maybe lsp obviates the need for this?
call plug#end()
" vim:foldmethod=marker:foldlevel=0
" Stopa's vimrc -- my magic sauce for getting things done!
" -----------------------------------------------------------------------------
" Vim settings {{{1
" Important {{{2
set nocompatible " Enable Vim features
syntax on " Turn on syntax highlighting
let mapleader = "," " Set <leader> character
let maplocalleader = "," " Set <localleader> character
colorscheme jellybeans " Favorite so far
set encoding=utf-8 " Use utf-8 when reading files
set fileencoding=utf-8 " Files are written using utf-8
set lazyredraw " Don't redraw on macros -- boosts performance
set ttyfast " Faster redraws and smoother vim
set modelines=1 " Read the modeline at the top
" Ignore these files in Vim's file explorer {{{2
set wildignore+="/tmp/*,*.so,*.swp,*.zip
" Make clipboard the default register {{{2
set clipboard=unnamed
" Highlight column 81 {{{2
set colorcolumn=81
highlight ColorColumn ctermbg=234
" General {{{2
set autoread " Reload files when outside changes made
set backspace=indent,eol,start " Allow backspace in insert mode
set foldnestmax=2 " Sets max fold level.
set gcr=a:blinkon0 " Disable cursor blink
set hidden " Buffers can exist in background
set history=1000 " keep 100 lines of command line history
set laststatus=2 " lightline needs this to display status when opening first buffer
set noshowmode " using Lightline to show status bar instead
set noswapfile " Disable swap files. I don't use them
set number " Line numbers!
set ruler " show the cursor position all the time
set scrolloff=8 " Start scrolling 8 lines away from bottom
set shortmess+=I " Remove Vim startup message for empty file
set showcmd " Show incomplete commands at bottom
set showmode " Show current mode down the bottom
set splitbelow " Default horizontal split below
set splitright " Default vertical split right
set visualbell " Disable sounds
" Wrap {{{2
set wrap
set linebreak " Wrap lines at convienent points
set textwidth=0
set wrapmargin=0
" Searching {{{2
set hlsearch " highlight searching
set incsearch " do incremental searching
set ignorecase " searches are case insensitive
set smartcase " unless you search with a capital letter
" Tabs and Spaces {{{2
set expandtab
set tabstop=4
set softtabstop=4
set shiftwidth=4
" Auto adjust window sizes when they become current {{{2
set winwidth=84
set winheight=5
set winminheight=5
set winheight=999
" }}} End section
" Key mappings {{{1
" Highlight initials in notes {{{2
:match Todo /JA:/
" Easy Navigating {{{2
:inoremap jk <Esc>
:nnoremap j gj
:nnoremap k gk
" Easy window cycling {{{2
:nnoremap <C-h> <C-w>h
:nnoremap <C-j> <C-w>j
:nnoremap <C-k> <C-w>k
:nnoremap <C-l> <C-w>l
" Easy save/quit {{{2
:noremap <leader>w :w<CR>
:nnoremap <leader>q :q!<CR>
:nnoremap <leader>zz :qa!<CR>
" Reload vimrc file {{{2
:nnoremap <silent><leader>sv :so $MYVIMRC<CR>
" Edit useful files {{{2
:nnoremap <silent><leader>ev :e $MYVIMRC<CR>
:nnoremap <silent><leader>et :e $MYTMUXCONF<CR>
:nnoremap <silent><leader>ez :e $MYZSH<CR>
:nnoremap <silent><leader>ep :e $MYPROFILE<CR>
:nnoremap <silent><leader>ed :e $MYTODOS<CR>
" Clear search {{{2
:nnoremap <silent><leader>/ :nohlsearch<CR>
" Easy command Mode {{{2
:nnoremap ; :
" Easy begin/end line navigation {{{2
:nnoremap H 0w
:nnoremap L $
" Easy clipboard copy {{{2
:vnoremap <silent><leader>c :w !pbcopy<CR><CR>
" Easy clipboard paste {{{2
:nnoremap <silent><leader>v :r !pbpaste<CR><CR>
" Easy grep under cursor {{{2
:nmap <silent><leader>r viw"ry:Ag! <C-R>r<CR><CR>
" Easy code folding {{{2
:nnoremap <Space> za
" Focus fold {{{2
:nnoremap <leader>f zMzA
" Toggle lint errors/warnings
:nnoremap <leader>A :ALEToggle<CR><CR>
" Quick newline {{{2
:nnoremap <CR> o<Esc>
" Toggle NERDTree {{{2
:nnoremap <leader>nt :NERDTree<CR>
"
" Toggle show formatting {{{2
:nnoremap <leader>l :set list!<CR>
" Window manipulation {{{2
:nnoremap <leader>\ :vsp<CR>
:nnoremap <leader>m :vertical resize 80<CR>
" Fugitive shortcuts {{{2
:nnoremap <leader>gb :Gblame<CR>
" Tab switching {{{2
:nnoremap <leader>1 1gt
:nnoremap <leader>2 2gt
:nnoremap <leader>3 3gt
:nnoremap <leader>4 4gt
:nnoremap <leader>5 5gt
:nnoremap <leader>6 6gt
:nnoremap <leader>7 7gt
:nnoremap <leader>8 8gt
:nnoremap <leader>9 9gt
:nnoremap <leader>0 :tablast<CR>
:nnoremap <leader>x :tabclose<CR>
:nnoremap <leader>t :0tabnew<CR>
" Easy fzf {{{2
nmap ; :Buffers<CR>
nmap <leader>p :Files<CR>
" Toggle paste mode {{{2
:nnoremap <leader>P :set invpaste!<CR>
" Ctags navigation {{{2
:nnoremap <leader>g <C-]>
:nnoremap <leader>b <C-t>
" Easy Ack/Ag {{{2
:nnoremap <leader>a :Ag
" Easy commenting {{{2
:nnoremap // :TComment<CR>
:vnoremap // :TComment<CR>
" Prevent overwriting default register (system clipboard) when inconvenient {{{2
:vnoremap x "_x
:vnoremap c "_c
:vnoremap p "_dP
" Don't use arrow keys in normal mode :) {{{2
:nnoremap <Left> <NOP>
:nnoremap <Right> <NOP>
:nnoremap <Up> <NOP>
:nnoremap <Down> <NOP>
" In insert or command mode, move normally by using Ctrl {{{2
inoremap <C-h> <Left>
inoremap <C-j> <Down>
inoremap <C-k> <Up>
inoremap <C-l> <Right>
cnoremap <C-h> <Left>
cnoremap <C-j> <Down>
cnoremap <C-k> <Up>
cnoremap <C-l> <Right>
" Enables filetype detection and loads indent files {{{2
" Note: It's important this called after vim/bundle is added to vim's
" runtime path so that ftdetect will be loaded
" Thanks: http://stackoverflow.com/a/19314347
filetype plugin indent on
" Set path for fzf
set rtp+=/usr/local/opt/fzf
" Use Omni-Completion
set omnifunc=syntaxcomplete#Complete
" Plugins {{{1
" Ag {{{2
if executable('ag')
" Use ag over grep
set grepprg=ag\ --nogroup\ --nocolor
" use ag over ack
let g:ackprg = 'ag --vimgrep'
endif
" Lightline {{{2
" General settings
let g:lightline = {
\ 'colorscheme': 'jellybeans',
\ 'mode_map': { 'c': 'NORMAL' },
\ 'active': {
\ 'left': [ [ 'mode', 'paste' ], [ 'fugitive', 'filename' ] ]
\ },
\ 'component_function': {
\ 'fugitive': 'MyFugitive'
\ },
\ 'separator': { 'left': "", 'right': '' },
\ 'subseparator': { 'left': '|', 'right': '|' }
\ }
" NERDTree {{{2
" Files and directories I don't want to see
" Note the use of vim-style regex
let NERDTreeIgnore = [
\ '\.\(pyc\|swp\|db\|coverage\|DS_Store\)$',
\ '\.\(git\|hg\|svn\|egg-info\)$[[dir]]',
\ '\(coverage\|pytests\)\.xml$',
\ ]
" I do want to see dotfiles (like .gitignore)
let NERDTreeShowHidden=1
" Pretty NERDTree
let NERDTreeMinimalUI = 1
let NERDTreeDirArrows = 1
" vim-javascript {{{2
" Enable syntax highlighting for flow
let g:javascript_plugin_flow = 1
" ale {{{2
" Configure error and warning formatting
let g:ale_sign_error = '✘'
let g:ale_sign_warning = '⚠'
highlight ALEErrorSign ctermbg=NONE ctermfg=red
highlight ALEWarningSign ctermbg=NONE ctermfg=yellow
let g:ale_lint_on_enter = 0 " Don't lint files on open
let g:ale_sign_column_always = 1 " Keep column open by default
" Linters
let g:ale_linters = {
\ 'javascript': ['eslint'],
\}
let g:ale_linters_explicit = 1
" Fixers
let g:ale_fixers = {
\ 'javascript': ['eslint']
\ }
" vim-jsx-pretty {{{2
" Colorful style
let g:vim_jsx_pretty_colorful_config = 1
" vim-prettier {{{2
" Run prettier async
let g:prettier#exec_cmd_async = 1
" Custom functions {{{1
" Strip whitespace and save cursor position {{{2
function! <SID>StripTrailingWhitespaces()
" Preparation: save last search, and cursor position.
let _s=#/
let l = line(".")
let c = col(".")
" Do the business:
%s/\s\+$//e
" Clean up: restore previous search history, and cursor position
let #/=_s
call cursor(l, c)
endfunction
" Displays current git branch in powerline {{{2
function! MyFugitive()
if &ft !~? 'vimfiler\|gundo' && exists("*fugitive#head")
let _ = fugitive#head()
return strlen(_) ? "\u00A7 "._ : ''
endif
return ''
endfunction
" }}}
" Autocommands {{{1
augroup configgroup
" Clear previous autocmds
autocmd!
" White Space Settings for different file types {{{2
autocmd FileType python setlocal ts=4 sts=4 sw=4 et
autocmd FileType javascript,jsx,tsx setlocal ts=2 sts=2 sw=2 et
autocmd FileType css setlocal ts=2 sts=2 sw=2 et
autocmd FileType ruby setlocal ts=2 sts=2 sw=2 et
autocmd FileType html,htmljinja setlocal ts=2 sts=2 sw=2 et
" Clean up trailing white spaces {{{2
autocmd BufWritePre * :call <SID>StripTrailingWhitespaces()
" Python folding {{{2
au FileType python setlocal foldmethod=indent
au FileType python setlocal foldlevel=0
" Javascript folding {{{2
au FileType javascript,jsx,tsx setlocal foldmethod=syntax
au FileType javascript,jsx,tsx setlocal foldlevel=1
" Rainbow-ify parens/brackets for selected file types {{{2
au FileType javascriptreact,jsx call rainbow#load()
" Enable vim-jinja highlighting for .jinja files {{{2
autocmd BufNewFile,BufRead *.jinja set filetype=htmljinja
" Trigger autoread whenever I switch buffer or when focusing vim again {{{2
" Thanks: http://stackoverflow.com/questions/2490227/how-does-vims-autoread-work/20418591#20418591
au FocusGained,BufEnter * :silent! !
" Save whenever switching between windows and buffers {{{2
au FocusLost,BufLeave,WinLeave * :silent! w
" Close the Omni-Completion tip window when a selection is made {{{2
" These lines close it on movement in insert mode or when leaving insert mode
" Thanks:
" http://stackoverflow.com/questions/3105307/how-do-you-automatically-remove-the-preview-window-after-autocompletion-in-vim
autocmd CursorMovedI * if pumvisible() == 0|pclose|endif
autocmd InsertLeave * if pumvisible() == 0|pclose|endif
" }}} End section
augroup END
" COC {{{1
" Having longer updatetime (default is 4000 ms = 4 s) leads to noticeable
" delays and poor user experience.
set updatetime=300
" Use tab for trigger completion with characters ahead and navigate.
" NOTE: Use command ':verbose imap <tab>' to make sure tab is not mapped by
" other plugin before putting this into your config.
inoremap <silent><expr> <TAB>
\ pumvisible() ? "\<C-n>" :
\ <SID>check_back_space() ? "\<TAB>" :
\ coc#refresh()
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
function! s:check_back_space() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunction
" Use <c-space> to trigger completion.
if has('nvim')
inoremap <silent><expr> <c-space> coc#refresh()
else
inoremap <silent><expr> <c-#> coc#refresh()
endif
" Make <CR> auto-select the first completion item and notify coc.nvim to
" format on enter, <cr> could be remapped by other vim plugin
inoremap <silent><expr> <cr> pumvisible() ? coc#_select_confirm()
\: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
" Remap keys for gotos
nmap <silent> gd <Plug>(coc-definition)
nmap <leader>u <Plug>(coc-references)
nmap <leader>rn <Plug>(coc-rename)
command! -nargs=0 Format :call CocAction('format')
" Diagnostics
inoremap <silent><expr> <c-space> coc#refresh()
nmap <silent> [l <Plug>(coc-diagnostic-prev)
nmap <silent> ]l <Plug>(coc-diagnostic-next)
nmap <silent> [k :CocPrev<cr>
nmap <silent> ]k :CocNext<cr>
" Highlight symbol under cursor on CursorHold
autocmd CursorHold * silent call CocActionAsync('highlight')
vmap <leader>f <Plug>(coc-format-selected)
nmap <leader>f <Plug>(coc-format-selected)
" Fix autofix problem of current line
nmap <leader>aq <Plug>(coc-fix-current)
" Show documentation
nnoremap <silent> K :call <SID>show_documentation()<CR>
function! s:show_documentation()
if &filetype == 'vim'
execute 'h '.expand('<cword>')
else
call CocAction('doHover')
endif
endfunction
autocmd BufReadCmd,FileReadCmd,SourceCmd jar:file://* call s:LoadClojureContent(expand("<amatch>"))
function! s:LoadClojureContent(uri)
setfiletype clojure
let content = CocRequest('clojure-lsp', 'clojure/dependencyContents', {'uri': a:uri})
call setline(1, split(content, "\n"))
setl nomodified
setl readonly
endfunction
" }}} End Section
" Source private vimrc {{{1
if filereadable(expand("~/.vim/vimrc.private.after"))
source ~/.vim/vimrc.private.after
endif
Help would be much appreciated. Mainky:
Why is the diagnostic window full-screen?
Is there a way I could configure this to be smaller, or to show up somewhere else? (perhaps below the main pane)
Problem was
" Auto adjust window sizes when they become current {{{2
set winwidth=84
set winheight=5
set winminheight=5
set winheight=999
" }}} End section
Removing this did the trick
I prefer to make my code folds manually. However, I've noticed that the folds move after I
Make the fold using zf
Make some deletes/inserts after/below the code fold
The folds "move" in the sense that if 51 lines were folded, after movement only 50 lines are now folded. This makes it so that part of the code that was folded is no longer in the fold and now just looks like a randomly placed piece of code. I often have to delete the moved fold and do a refold.
Any ideas on how to fix this? Please let me know if this didn't make any sense or if you can't replicate this behavior.
set nocompatible " required
filetype off " required
" ================================================================="
" ================================================================="
" ==================== Begin my added plugins ====================="
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'
Plugin 'vim-syntastic/syntastic'
Plugin 'luochen1990/rainbow'
Plugin 'godlygeek/tabular'
Plugin 'garbas/vim-snipmate'
Plugin 'MarcWeber/vim-addon-mw-utils'
Plugin 'tomtom/tlib_vim'
Plugin 'honza/vim-snippets'
Plugin 'aperezdc/vim-template'
Plugin 'tpope/tpope-vim-abolish'
Plugin 'Raimondi/delimitMate'
Plugin 'tpope/vim-repeat'
call vundle#end()
filetype plugin indent on
" ================================================================="
" ================================================================="
" ===================== End my added plugins ======================"
if v:lang =~ "utf8$" || v:lang =~ "UTF-8$"
set fileencodings=ucs-bom,utf-8,latin1
endif
set bs=indent,eol,start " allow backspacing over everything in insert mode
set ai " always set autoindenting on
set viminfo='20,\"50 " read/write a .viminfo file, don't store more than 50 lines of registers
set history=50 " keep 50 lines of command line history
set ruler " show the cursor position all the time
" Only do this part when compiled with support for autocommands
if has("autocmd")
augroup fedora
autocmd!
" In text files, always limit the width of text to 78 characters
" autocmd BufRead *.txt set tw=78
" When editing a file, always jump to the last cursor position
autocmd BufReadPost *
\ if line("'\"") > 0 && line ("'\"") <= line("$") |
\ exe "normal! g'\"" |
\ endif
" don't write swapfile on most commonly used directories for NFS mounts or USB sticks
autocmd BufNewFile,BufReadPre /media/*,/run/media/*,/mnt/* set directory=~/tmp,/var/tmp,/tmp
" start with spec file template
autocmd BufNewFile *.spec 0r /usr/share/vim/vimfiles/template.spec
" auto-source the vimrc upon writing to the file
autocmd bufwritepost vimrc source %
augroup END
endif
if has("cscope") && filereadable("/usr/bin/cscope")
set csprg=/usr/bin/cscope
set csto=0
set cst
set nocsverb
" add any database in current directory
if filereadable("cscope.out")
cs add $PWD/cscope.out
" else add database pointed to by environment
elseif $CSCOPE_DB != ""
cs add $CSCOPE_DB
endif
set csverb
endif
syntax enable
" ================================================================="
" ================================================================="
" ============== Begin additions for Syntastic plugin ============="
let &shellpipe = '2>&1| tee'
let &shellredir = '>%s 2>&1'
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 1
let g:syntastic_enable_signs=1
let g:syntastic_check_on_wq = 0
"let g:syntastic_auto_loc_list = 2
"let g:syntastic_check_on_open = 1
"let g:syntastic_check_on_wq = 0
"let g:syntastic_enable_balloons = 0
"let g:syntastic_error_symbol = '✗'
"let g:syntastic_ignore_files = ['\.min\.js$', '\.min\.css$']
"let g:syntastic_loc_list_height = 5
"let g:syntastic_warning_symbol = '✗'
"let g:syntastic_style_error_symbol = '∆'
"let g:syntastic_style_warning_symbol = '∆'
" shortcut command for toggling syntastic mode (useful for when I'm just writing test code)
fun! s:toggle_syntastic()
call SyntasticToggleMode()
endfun
command! STM :call s:toggle_syntastic()
" ================================================================="
" ================================================================="
" =========== Begin additions for Rainbow_parens plugin ==========="
" set to zero and use :RainbowToggle to switch between modes
let g:rainbow_active = 1
" ================================================================="
" ================================================================="
" =========== Begin additions for Tabular plugin ==========="
vnoremap ;t :Tabularize /
" ================================================================="
" ================================================================="
" =========== Begin additions for SnipMate plugin ==========="
let g:snippet_version = 1
" ================================================================="
" ================================================================="
" ============== Begin additions for Templates plugin ============="
" see :h template.txt
" let g:templates_user_variables = [
" \ ['FULLPATH', 'GetFullPath'],
" \ ]
"
" function! GetFullPath()
" return expand('%:p')
" endfunction
" ================================================================="
" ================================================================="
" ================== Begin my 'set' vimrc things =================="
" Show (partial) command in status line
set showcmd
" Do case insensitive matching, smart case matching, don't wrap back to the top after searching
set ignorecase
set smartcase
set nowrapscan
set incsearch
" Automatically save before commands like :make
set autowrite
" Hide buffers when they are abandoned
set hidden
" set tab length, indentation length, auto indent
set tabstop=4
set shiftwidth=4
set autoindent
" disable swap file generation
set noswapfile
" change the orientation of the windows when using :split and :vs
set splitbelow
set splitright
" save state of original code folds, don't open code folds when doing searches
autocmd BufWinLeave *.* mkview
autocmd BufWinEnter *.* silent loadview
set foldopen-=search
set viewoptions=folds,cursor
" auto comments for /* (javadoc style comments)
set comments=sl:/*,mb:\ *,elx:\ */
" lets the tags file to be in a separate directory from the source code
" basically does the following:
" goes up one directory at a time until it finds a file called '.tags'
set tags=.tags;/
" set manual fold method, min number of lines to make a fold = 1
set fdm=manual
set fml=1
" fold method based on file syntax
" fold level = 2 for .java = 1 for .c
" min fold level = 0 for folding single lines
"set fdm=syntax
"set fml=0
"if &filetype == 'java'
" set fdn=2
"elseif &filetype == 'c'
" set fdn=1
"endif
" searches down into subfolders
" provides tab-completion for all file-related tasks
set path+=**
" display all matching files when you tab-complete
set wildmenu
" tweaks for file browsing
let g:netrw_browse_split=4 " open in prior window
let g:netrw_altv=1 " open splits to the right
let g:netrw_liststyle=3 " tree view
" set matching parenthesis/brace/bracket to be underlined
hi MatchParen cterm=underline ctermbg=none ctermfg=none
" make the vim tab bar look prettier
hi TabLineFill ctermfg=Black ctermbg=Black
hi TabLine ctermfg=Blue ctermbg=Black
hi TabLineSel ctermfg=Black ctermbg=Yellow
hi Title ctermfg=Black ctermbg=Yellow
" set variable 'g:os' according to development environment
if !exists('g:os')
if has('win32') || has('win16')
let g:os = 'Windows'
else
let g:os = substitute(system('uname'), '\n', '', '')
endif
endif
" a godsend that disables that stupidly annoying beep/bell once and for all
if g:os =~ 'CYGWIN'
set belloff=all
endif
" prevent ubuntu from outputting garbage characters
if g:os =~ 'Linux'
set t_RV=
endif
" make the clipboard the default register
if has('unnamedplus')
set clipboard=unnamed,unnamedplus
else
set clipboard=unnamed
endif
" ================================================================="
" ================================================================="
" =============== Begin my 'nnoremaps' vimrc things ==============="
" typing '' now also centers the screen
nnoremap '' ''zz
" map the jump-to-mark command 'm so that the
" command centers the screen upon jumping
nnoremap 'm 'mzz
"" press % to visually highlight in-between brace/bracket/parentheses
noremap % v%
" press CTRL-j/CTRL-k to go down/up half a page, respectively
noremap <C-j> <C-D>
noremap <C-k> <C-U>
" capital K enters a linefeed while maintaining normal mode
nnoremap K i<CR><ESC>
" use CTRL-h and CTRL-L to switch between Vim tabs
nnoremap <C-h> gT
inoremap <C-h> <ESC>gT
nnoremap <C-l> gt
inoremap <C-l> <ESC>gt
" use , to repeat the last find command --> use shift, to go the other way
nnoremap , ;
vnoremap , ;
nnoremap < ,
" remap the normal paste to align the pasted block with the surrounded text
nnoremap p ]p
nnoremap P ]P
" remap yb to not move the cursor backwards (repositioning the cursor was annoying)
nnoremap yb ybw
" remap CTRL-n to move to the next line that has a compile error"
nnoremap <C-n> :cn<CR>
" remap CTRL-p to move to the previous line that has a compile error"
" NOTE: can also map this to CTRL-N
nnoremap <C-p> :cp<CR>
" mappings for easily deleting the surrounding brackets/parentheses
" ==========================================================================================================
nnoremap <silent> <Plug>Map_df( dt(me%x`ex:silent! call repeat#set("\<plug>Map_df(", v:count)<cr>
nmap df( <Plug>Map_df(
nnoremap <silent> <Plug>Map_d( me%x`ex:silent! call repeat#set("\<Plug>Map_d(", v:count)<CR>
nmap d( <Plug>Map_d(`e
nnoremap <silent> <Plug>Map_df[ dt[me%x`ex:silent! call repeat#set("\<Plug>Map_df[", v:count)<CR>
nmap df[ <Plug>Map_df[`e
nnoremap <silent> <Plug>Map_d[ me%x`ex:silent! call repeat#set("\<Plug>Map_d[", v:count)<CR>
nmap d[ <Plug>Map_df[`e
" ==========================================================================================================
" mappings for easily changing the surrounding brackets/parentheses
" ==========================================================================================================
nnoremap <silent> <Plug>Map_cf( dt(me%x`exi:silent! call repeat#set("\<Plug>Map_cf(", v:count)<CR>
nmap cf( <Plug>Map_cf(`e
nnoremap <silent> <Plug>Map_c( %me%r(`er)%:silent! call repeat#set("\<Plug>Map_c(", v:count)<CR>
nmap c( <Plug>Map_c(`e
nnoremap <silent> <Plug>Map_cf[ dt[me%x`exi:silent! call repeat#set("\<Plug>Map_cf[", v:count)<CR>
nmap cf[ <Plug>Map_cf[`e
nnoremap <silent> <Plug>Map_c[ %me%r[`er]%:silent! call repeat#set("\<Plug>Map_c[", v:count)<CR>
nmap c[ <Plug>Map_c[`e
" ==========================================================================================================
" mappings for easily replacing the surrounding brackets/parentheses
" ==========================================================================================================
nnoremap <silent> <Plug>Map_r( %me%r(`er)%:silent! call repeat#set("\<Plug>Map_r(", v:count)<CR>
nmap r( <Plug>Map_r(`e
nnoremap <silent> <Plug>Map_r[ %me%r[`er]%:silent! call repeat#set("\<Plug>Map_r[", v:count)<CR>
nmap r[ <Plug>Map_r[`e
" ==========================================================================================================
" remap U to ~ for easier uppercasing/lowercasing
nnoremap U ~
" pressing Control-w then Control-c in split windows accidentally closes the window. I dislike this
nnoremap <C-w><C-c> <ESC>
" using 'x' will now put the 'cut' letter(s) in the black hole register "_
nnoremap x "_x
nnoremap X "_X
" using '' to will now put you at the (last cursor position) instead of the (last row your cursor was in)
nnoremap '' ``zz
" map Y to act the same as D & C
nnoremap Y y$
" ================================================================="
" ================================================================="
" =============== Begin my 'inoremaps' vimrc things ==============="
" autocomplete for matching brace (activated upon pressing enter)
if g:os =~ 'CYGWIN'
inoremap {<CR> {<TAB><CR>}<Esc><Esc>O
elseif g:os =~ 'Linux'
inoremap {<CR> {<CR>}<ESC>O
endif
" DUMBEST HACK EVER (but I'm so happy it works)
" normally pressing CTRL-c undoes your auto-indent on a blank line
" solutions to this is to make a new line that is auto-indented for you
" and then type some random character, delete it, then press CTRL-c
" so, that's exactly what this hack does
inoremap <C-c> l<BS><ESC>
" remap the paste function in insert mode to Control-p
inoremap <C-p> <C-R>*
" remap the autocomplete feature in vim to only look in the current file
inoremap <C-n> <C-x><C-n>
" remap the autocomplete feature for files to Control-m in insert mode
inoremap <C-k> <C-x><C-f>
" ================================================================="
" ================================================================="
" =============== Begin my 'vnoremaps' vimrc things ==============="
" easier uppercasing/lowercasing
vnoremap U ~
" so that your default register won't be overwritten when you paste over stuff in visual mode
xnoremap p "_dP
" ================================================================="
" ================================================================="
" ============== Begin some 'function' vimrc things ==============="
" now you can close the file, get back in, and still maintain the original undo tree
if has('persistent_undo')
set undolevels=5000
call system('mkdir ~/.vim/undo')
set undodir=~/.vim/undo
set undofile
endif
"=================================================================="
" toggle commented lines for #-style comments
function! ToggleComment_Py()
if matchstr(getline(line(".")),'^\s*\#.*$') == ''
:execute "s:^:# :"
else
:execute "s:^\s*# ::"
endif
endfunction
vnoremap ;# :call ToggleComment_Py()<CR>
nnoremap ;# :call ToggleComment_Py()<CR>
" toggle commented lines for "-style comments
function! ToggleComment_Vimrc()
if matchstr(getline(line(".")),'^\s*\".*$') == ''
:execute 's:^:" :'
else
:execute 's:^\s*" ::'
endif
endfunction
vnoremap ;" :call ToggleComment_Vimrc()<CR>
nnoremap ;" :call ToggleComment_Vimrc()<CR>
"=================================================================="
" reformat multiline if-statements into single line if-statements
fun! s:reformat(line1, line2)
" Remember line locs and numbers (bookkeeping)
execute 'normal!' 'me'
let l:before = line('$')
" Join the selected lines && put a newline before every 'else'
execute 'normal!' . (a:line2 - a:line1 + 1) . 'J'
execute 's/else/\relse/g'
" Recalculate the range && run Tabular
let l:line2 = a:line2 - (l:before - line('$'))
execute 'normal!' "V'e="
execute 'normal!' 'f(i '
execute a:line1 . ',' . l:line2 . 'Tabularize /{/'
endfun
command! -range Reformat :call s:reformat(<line1>, <line2>)
"=================================================================="
" unformat single line if-statements into multiline if-statements
fun! s:unformat(line1, line2)
" mark line one && keep track of lines selected
execute 'normal!' 'me'
let l:numDiff = a:line2 - a:line1 + 1
" delete extraneous white space
execute 'normal!' 'f dt(i '
let c = 0
while c < numDiff - 1
execute 'normal!' 'f)f dt{i '
execute 'normal!' 'j0w'
let c += 1
endwhile
execute 'normal!' 'f dt{i '
" Formatting to make the statements span multiple lines
execute 'normal!' "'e"
execute 'normal!' . (a:line2 - a:line1 + 1) . 'J'
execute 's/{ /{\r/g'
execute 'normal!' "'e"
let c = 0
while c < l:numDiff
execute 'normal!' 'j'
execute 's/}/\r}/g'
let c += 1
endwhile
execute 'normal!' "V'e="
endfun
command! -range Unformat :call s:unformat(<line1>, <line2>)
"=================================================================="
" a smarter delete operation (does not copy whitespace into registers)
" NOTE: this doesn't prevent copying whitespace using 'yy' or 'Vy'
" my assumption is that you wanted to copy the whitespace instead of deleting it
function! Smart_Delete_dd()
let temp = getreg('"', 1)
execute 'normal!' 'dd'
if matchstr(#", '\_s*') == #" " if just whitespace
call setreg('"', temp)
call setreg('*', temp)
call setreg('+', temp)
call setreg('0', temp)
endif
endfunction
nnoremap <silent> dd :call Smart_Delete_dd()<CR>
function! Smart_Delete_Vd() range
let temp = getreg('"', 1)
execute 'normal!' . (a:lastline - a:firstline + 1) . 'dd'
if matchstr(#", '\_s*') == #" " if just whitespace
call setreg('"', temp)
call setreg('*', temp)
call setreg('+', temp)
call setreg('0', temp)
endif
endfunction
vnoremap <silent> d :call Smart_Delete_Vd()<CR>
"=================================================================="
" insert the full path of the current file
fun! s:fullpath()
:put =expand('%:p')
endfun
command! FullPath :call s:fullpath()
" ================================================================="
" ================================================================="
" ================= Begin my custom ';' commands =================="
" use ;zf to fold all functions (in C and C++ and Java)
function! FoldFunctions()
:silent! execute "%g/^bool/normal! vf{%zf"
:silent! execute "%g/^boolean/normal! vf{%zf"
:silent! execute "%g/^int/normal! vf{%zf"
:silent! execute "%g/^double/normal! vf{%zf"
:silent! execute "%g/^void/normal! vf{%zf"
:silent! execute "%g/\tbool/normal! vf{%zf"
:silent! execute "%g/\tboolean/normal! vf{%zf"
:silent! execute "%g/\tint/normal! vf{%zf"
:silent! execute "%g/\tdouble/normal! vf{%zf"
:silent! execute "%g/\tvoid/normal! vf{%zf"
:silent! execute "%g/\tpublic/normal! vf{%zf"
:silent! execute "%g/\tprivate/normal! vf{%zf"
endfunc
nnoremap ;zf zE :call FoldFunctions()<CR><ESC>
" use ;n to toggle between number mode and relative number mode
function! NumberToggle()
if(&relativenumber == 1)
set nornu
set nonu
else
set rnu
set nu
endif
endfunc
nnoremap ;n :call NumberToggle()<CR>
set rnu
set nu
" use ;p to retain original indentation when pasting from another application
nnoremap ;p :set invpaste paste?<CR>
set showmode
" use ;w to remove trailing whitespace press ';w' (semicolon then 'w')
function! TrimWhitespace()
let l:save_cursor = getpos('.')
%s/\s\+$//e
call setpos('.', l:save_cursor)
endfunction
nnoremap ;w :call TrimWhitespace()<CR>
" use ;h to toggle highlighted search
nnoremap ;h :set hlsearch! hlsearch?<CR>
" use ;l to reload the file
nnoremap ;l :e<CR>
" use ;t and type a file name to open it in a VIM tab (:tabnew)
nnoremap ;t :tabnew
" use ;m to run the Makefile in the current directory (:make)
nnoremap ;m :make<CR>
" use ;s to source the vimrc file
nnoremap ;s :source $VIM/vimrc<CR>
" use ;f to format the file according to C++/Java style
nnoremap ;f :set expandtab! expandtab?<CR>gg=G''<ESC>
" use ;d to put deleted stuff in the black hole register "_
nnoremap ;d "_dd
vnoremap ;d "_d
" use ;j to jump from a function call to that function's definition
" use T to pop from the tag stack and go to that location
" use in conjuction with ctags
nnoremap ;j <C-]>zz
nnoremap T <C-t>zz
" use ;y to copy the current text file into the clipboard
nnoremap ;y myggvG$"*y'y
" use ;v to paste from the clipboard
nnoremap ;v "*p
" use ;zf to easily fold code that lies in between the braces
" v%zf<CR>
" use ;r in visual mode to replace the visually selected word
nnoremap ;r ye:%s/<C-F>pa//g<ESC>F/i
vnoremap ;r y:%s/<C-F>pa//g<ESC>F/i
" ================================================================="
" ================================================================="
" ================== Some nice things to remember ================="
" restore color scheme --> this is not actually mapped to something
" set filetype=____ (e.g. :set filetype=cpp)
" zipping files
" zip -r file_name.zip *
" specific things for filetypes --> actually don't do this --> see ~/.vim/after/ftplugin/
" au FileType python
" Don't wake up system with blinking cursor:
" http://www.linuxpowertop.org/known.php
let &guicursor = &guicursor . ",a:blinkon0"
I installed MacVim 7.4-73_1 on MacOs X Yosemite using Homebrew. When in a ruby file hovering over certain words will cause a tooltip to fade in. It seems to slow Vim down causing a short lag while the tooltip loads, they also tend to get in the way. So, my goal is to hide these tooltips all together. I understand this may be caused by a plugin I am using but I can't seem to pin it down.
I have attached a gif below showing another strange behavior. The tooltips only show up if I begin editing a file from the vim explorer.
Below is a list of the vim plugins I am using and my .vimrc
All my plugins
ack.vim
mustache
nerdcommenter
sass-convert.vim
snipmate-mocha
snipmate-snippets
tabular
tlib_vim
vim-addon-mw-utils
vim-coffee-script
vim-css-color
vim-fugitive
vim-less
vim-rails
vim-rspec
vim-snipmate
My Vimrc File
" Use Pathogen
call pathogen#runtime_append_all_bundles()
call pathogen#helptags()
" ================
" Ruby stuff
" ================
syntax on " Enable syntax highlighting
filetype plugin indent on " Enable filetype-specific indenting and plugins
augroup myfiletypes
" Clear old autocmds in group
autocmd!
" autoindent with two spaces, always expand tabs
autocmd FileType ruby,eruby,yaml set ai sw=2 sts=2 et
augroup END
"================
let mapleader = ","
" START html.tidy
:vmap <Leader>ti :!tidy -q -i --show-errors 0<CR>
" START TAB.vim
nmap <Leader>a{ :Tabularize /{<CR>
vmap <Leader>a= :Tabularize /=<CR>
nmap <Leader>a= :Tabularize /=<CR>
nmap <Leader>a. :Tabularize /=><CR>
vmap <Leader>a. :Tabularize /=><CR>
nmap <Leader>a: :Tabularize /:\zs<CR>
vmap <Leader>a: :Tabularize /:\zs<CR>
"inoremap <silent> = =<Esc>:call <SID>ealign()<CR>a
function! s:ealign()
let p = '^.*=[^>]*$'
if exists(':Tabularize') && getline('.') =~# '^.*=' && (getline(line('.')-1) =~# p || getline(line('.')+1) =~# p)
let column = strlen(substitute(getline('.')[0:col('.')],'[^=]','','g'))
let position = strlen(matchstr(getline('.')[0:col('.')],'.*=\s*\zs.*'))
Tabularize/=/l1
normal! 0
call search(repeat('[^=]*=',column).'\s\{-\}'.repeat('.',position),'ce',line('.'))
endif
endfunction
"inoremap <silent> => =><Esc>:call <SID>ralign()<CR>a
function! s:ralign()
let p = '^.*=>*$'
if exists(':Tabularize') && getline('.') =~# '^.*=>' && (getline(line('.')-1) =~# p || getline(line('.')+1) =~# p)
let column = strlen(substitute(getline('.')[0:col('.')],'[^=>]','','g'))
let position = strlen(matchstr(getline('.')[0:col('.')],'.*=>\s*\zs.*'))
Tabularize/=/l1
normal! 0
call search(repeat('[^=>]*=>',column).'\s\{-\}'.repeat('.',position),'ce',line('.'))
endif
endfunction
inoremap <silent> <Bar> <Bar><Esc>:call <SID>palign()<CR>a
function! s:palign()
let p = '^\s*|\s.*\s|\s*$'
if exists(':Tabularize') && getline('.') =~# '^\s*|' && (getline(line('.')-1) =~# p || getline(line('.')+1) =~# p)
let column = strlen(substitute(getline('.')[0:col('.')],'[^|]','','g'))
let position = strlen(matchstr(getline('.')[0:col('.')],'.*|\s*\zs.*'))
Tabularize/|/l1
normal! 0
call search(repeat('[^|]*|',column).'\s\{-\}'.repeat('.',position),'ce',line('.'))
endif
endfunction
" END TAB.vim
noremap <Up> <nop>
noremap <Down> <nop>
noremap <Left> <nop>
noremap <Right> <nop>
" START rspec.vim
"map <Leader>t :call RunCurrentSpecFile()<CR>
"map <Leader>s :call RunNearestSpec()<CR>
"map <Leader>l :call RunLastSpec()<CR>
map <Leader>ra :call RunAllSpecs()<CR>
" END rspec.vim
set nocompatible
set backspace=indent,eol,start " allow backspacing over everything in insert mode
set history=500 " keep 500 lines of command line history
set ruler " show the cursor position all the time
set showcmd " display incomplete commands
set autoindent " indent next line
set showmatch " Attempts to show matching (), {}, or []
set nowrap
"set nobackup
"set noswapfile
set backupdir=~/.tmp
set directory=~/.tmp " Don't clutter my dirs up with swp and tmp files
set autoread
set wmh=0 " This sets the minimum window height to 0, so you can stack many more files before things get crowded. Vim will only display the filename.
set viminfo+=!
" Edit another file in the same directory as the current file
" uses expression to extract path from current file's path
map <Leader>e :Explore
map <Leader>ep :e <C-R>=expand("%:p:h") . '/'<CR>
map <Leader>s :Sexplore
map <Leader>v :Vexplore
map <Leader>nt :tabe <C-R>=expand("%:p:h") . '/'<CR>
" Easy window navigation
map <C-h> <C-w>h
map <C-j> <C-w>j
map <C-k> <C-w>k
map <C-l> <C-w>l
vmap <leader>h :!/Users/ross/.rvm/bin/vim_html2haml<cr>
function! PasteAsCoffee()
:read !pbpaste | js2coffee
endfunction
:command! PasteAsCoffee :call PasteAsCoffee()
:map <leader>pc :PasteAsCoffee<CR>
set tabstop=2 " Set tabs to 2 spaces
set autowriteall " Auto save on close
set spell
set list
set listchars=tab:>.,trail:.,extends:#,nbsp:. " Highlight problematic whitespace
set et " expand tab
set sw=2 " shift width < >
set smarttab " deltes of adds a tab
set tw=80 " auto break lines at 80 columns
set incsearch " don't show search matches as you type
set ignorecase smartcase " when searching ignore case when the pattern contains lowercase letters only.
set laststatus=2 " show status line. never=0 only when split=1 always=2
set number " show line numbers
set gdefault " assume the /g flag on :s substitutions to replace all matches in a line
set autoindent " always set autoindenting on
set pastetoggle=<F2> " Don't auto indent pasted text after F2
let g:netrw_preview = 1
let g:fuzzy_ignore = ".DS_Store;*.png;*.PNG;*.JPG;*.jpg;*.GIF;*.gif;vendor/**;coverage/**;tmp/**;rdoc/**"
set nofoldenable " Say no to code folding...
set statusline+=%<%f\ %h%m%r%{fugitive#statusline()}%=%-14.(%l,%c%V%)\ %P
" I don't remember what this does
autocmd BufEnter * silent! lcd %:p:h
" remove search highlight with ,/
nmap <silent> ,/ :nohlsearch<CR>
" Switch syntax highlighting on, when the terminal has colors
" Also switch on highlighting the last used search pattern.
if &t_Co > 2 || has("gui_running")
syntax on
set hlsearch
endif
" Only do this part when compiled with support for autocommands.
if has("autocmd")
" Enable file type detection.
" Use the default filetype settings, so that mail gets 'tw' set to 72,
" 'cindent' is on in C files, etc.
" Also load indent files, to automatically do language-dependent indenting.
filetype plugin indent on
endif " has("autocmd")
colors codeschool
You can read about that feature in :help balloon-eval.
That option is disabled by default so one of your plugins probably enabled it. This command should show you which one is the culprit:
:verbose set ballooneval?
You can disable that feature with :set noballooneval.
I'm having an issue with some vim commands that replace words, specifically after movement commands like e, w and b.
Specifically, there is always a delay for cw, but not for ci" for example to change text within quotes.
Secondly, if I move three words forward, and type cw to change the third word without waiting a bit, it moves another word forward and cw's that one.
I've cut out a lot out of my Vimrc, and I can't really tell what might be causing the issue. Many times I end up doing a viw then c to change the word quickly, which doesn't make sense to me. Any insight into the issue would be fantastic.
Also, this is not system dependent, It's consistent across three different computers, nor is it syntax/filetype specific.
autocmd!
set nocompatible
filetype off
set rtp+=$HOME/.local/lib/python2.7/site-packages/powerline/bindings/vim
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
Bundle 'gmarik/vundle'
Bundle 'nanotech/jellybeans.vim'
Bundle 'bling/vim-airline'
Bundle 'kchmck/vim-coffee-script'
Bundle 'bitc/vim-bad-whitespace'
Bundle 'scrooloose/nerdtree'
Bundle 'Lokaltog/vim-easymotion'
Bundle 'mileszs/ack.vim'
Bundle 'othree/html5.vim'
Bundle 'juvenn/mustache.vim'
Bundle 'yaymukund/vim-rabl'
Bundle 'int3/vim-extradite'
Bundle 'tpope/vim-fugitive'
Bundle 'tpope/vim-haml'
Bundle 'tpope/vim-repeat'
Bundle 'tpope/vim-endwise'
Bundle 'tpope/vim-rails'
Bundle 'tpope/vim-eunuch'
Bundle 'tpope/vim-surround'
Bundle 'tpope/vim-markdown'
Bundle 'kein/ctrlp.vim'
Bundle 'wincent/Command-T'
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" BASIC EDITING CONFIGURATION
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set nocompatible
" allow unsaved background buffers and remember marks/undo for them
set hidden
" remember more commands and search history
set nu
set history=10000
set expandtab
set tabstop=4
set shiftwidth=4
set softtabstop=4
set autoindent
set laststatus=2
set showmatch
set incsearch
set hlsearch
set t_Co=256
" make searches case-sensitive only if they contain upper-case characters
set ignorecase smartcase
" highlight current line
set cursorline
set cmdheight=1
set switchbuf=useopen
set showtabline=2
set winwidth=79
" This makes RVM work inside Vim. I have no idea why.
set shell=bash
" Prevent Vim from clobbering the scrollback buffer. See
" http://www.shallowsky.com/linux/noaltscreen.html
set t_ti= t_te=
" keep more context when scrolling off the end of a buffer
set scrolloff=3
" Store temporary files in a central spot
set backup
set backupdir=~/.vim-tmp,~/.tmp,~/tmp,/var/tmp,/tmp
set directory=~/.vim-tmp,~/.tmp,~/tmp,/var/tmp,/tmp
" allow backspacing over everything in insert mode
set backspace=indent,eol,start
" display incomplete commands
set showcmd
" Enable highlighting for syntax
syntax on
" Enable file type detection.
" Use the default filetype settings, so that mail gets 'tw' set to 72,
" 'cindent' is on in C files, etc.
" Also load indent files, to automatically do language-dependent indenting.
filetype plugin indent on
" use emacs-style tab completion when selecting files, etc
set wildmode=longest,list
" make tab completion for files/buffers act like bash
set wildmenu
let mapleader=","
" Fix slow O inserts
:set timeout timeoutlen=1000 ttimeoutlen=100
" Normally, Vim messes with iskeyword when you open a shell file. This can
" leak out, polluting other file types even after a 'set ft=' change. This
" variable prevents the iskeyword change so it can't hurt anyone.
let g:sh_noisk=1
" Modelines (comments that set vim options on a per-file basis)
set modeline
set modelines=3
" Turn folding off for real, hopefully
set foldmethod=manual
set nofoldenable
let g:airline_left_sep = ''
let g:airline_left_alt_sep = ''
let g:airline_right_sep = ''
let g:airline_right_alt_sep = ''
let g:airline_fugitive_prefix = ' '
let g:airline_readonly_symbol = ''
let g:airline_linecolumn_prefix = ''
let g:airline_theme='badwolf'
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" CUSTOM AUTOCMDS
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
augroup vimrcEx
" Clear all autocmds in the group
autocmd!
autocmd FileType text setlocal textwidth=78
" Jump to last cursor position unless it's invalid or in an event handler
autocmd BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal g`\"" |
\ endif
"for ruby, autoindent with two spaces, always expand tabs
autocmd FileType ruby,haml,eruby,yaml,html,javascript,sass,cucumber set ai sw=2 sts=2 et
autocmd FileType python set sw=4 sts=4 et
autocmd! BufRead,BufNewFile *.sass setfiletype sass
autocmd BufRead *.mkd set ai formatoptions=tcroqn2 comments=n:>
autocmd BufRead *.markdown set ai formatoptions=tcroqn2 comments=n:>
" Indent p tags
" autocmd FileType html,eruby if g:html_indent_tags !~ '\\|p\>' | let g:html_indent_tags .= '\|p\|li\|dt\|dd' | endif
" Don't syntax highlight markdown because it's often wrong
autocmd! FileType mkd setlocal syn=off
" Leave the return key alone when in command line windows, since it's used
" to run commands there.
autocmd! CmdwinEnter * :unmap <cr>
autocmd! CmdwinLeave * :call MapCR()
augroup END
" Create the dirs required for a save if they don't exist.
function s:MkNonExDir(file, buf)
if empty(getbufvar(a:buf, '&buftype')) && a:file!~#'\v^\w+\:\/'
let dir=fnamemodify(a:file, ':h')
if !isdirectory(dir)
call mkdir(dir, 'p')
endif
endif
endfunction
augroup BWCCreateDir
autocmd!
autocmd BufWritePre * :call s:MkNonExDir(expand('<afile>'), +expand('<abuf>'))
augroup END
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" STATUS LINE
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
:set statusline=%<%f\ (%{&ft})\ %-4(%m%)%=%-19(%3l,%02c%03V%)
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" MISC KEY MAPS
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
map <leader>y "*y
" Move around splits with <c-hjkl>
nnoremap <c-j> <c-w>j
nnoremap <c-k> <c-w>k
nnoremap <c-h> <c-w>h
nnoremap <c-l> <c-w>l
" Insert a hash rocket with <c-l>
imap <c-l> <space>=><space>
" Can't be bothered to understand ESC vs <c-c> in insert mode
imap <c-c> <esc>
nnoremap <leader><leader> <c-^>
" Close all other windows, open a vertical split, and open this file's test
" alternate in it.
nnoremap <leader>s :call FocusOnFile()<cr>
function! FocusOnFile()
tabnew %
normal! v
normal! l
call OpenTestAlternate()
normal! h
endfunction
" Reload in chrome
map <leader>l :w\|:silent !reload-chrome<cr>
" Align selected lines
vnoremap <leader>ib :!align<cr>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" MULTIPURPOSE TAB KEY
" Indent if we're at the beginning of a line. Else, do completion.
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
function! InsertTabWrapper()
let col = col('.') - 1
if !col || getline('.')[col - 1] !~ '\k'
return "\<tab>"
else
return "\<c-p>"
endif
endfunction
inoremap <tab> <c-r>=InsertTabWrapper()<cr>
inoremap <s-tab> <c-n>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" OPEN FILES IN DIRECTORY OF CURRENT FILE
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
cnoremap %% <C-R>=expand('%:h').'/'<cr>
map <leader>e :edit %%
map <leader>v :view %%
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" RENAME CURRENT FILE
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
function! RenameFile()
let old_name = expand('%')
let new_name = input('New file name: ', expand('%'), 'file')
if new_name != '' && new_name != old_name
exec ':saveas ' . new_name
exec ':silent !rm ' . old_name
redraw!
endif
endfunction
map <leader>n :call RenameFile()<cr>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" PROMOTE VARIABLE TO RSPEC LET
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
function! PromoteToLet()
:normal! dd
" :exec '?^\s*it\>'
:normal! P
:.s/\(\w\+\) = \(.*\)$/let(:\1) { \2 }/
:normal ==
endfunction
:command! PromoteToLet :call PromoteToLet()
:map <leader>p :PromoteToLet<cr>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" EXTRACT VARIABLE (SKETCHY)
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
function! ExtractVariable()
let name = input("Variable name: ")
if name == ''
return
endif
" Enter visual mode (not sure why this is needed since we're already in
" visual mode anyway)
normal! gv
" Replace selected text with the variable name
exec "normal c" . name
" Define the variable on the line above
exec "normal! O" . name . " = "
" Paste the original selected text to be the variable value
normal! $p
endfunction
vnoremap <leader>rv :call ExtractVariable()<cr>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" INLINE VARIABLE (SKETCHY)
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
function! InlineVariable()
" Copy the variable under the cursor into the 'a' register
:let l:tmp_a = #a
:normal "ayiw
" Delete variable and equals sign
:normal 2daW
" Delete the expression into the 'b' register
:let l:tmp_b = #b
:normal "bd$
" Delete the remnants of the line
:normal dd
" Go to the end of the previous line so we can start our search for the
" usage of the variable to replace. Doing '0' instead of 'k$' doesn't
" work; I'm not sure why.
normal k$
" Find the next occurence of the variable
exec '/\<' . #a . '\>'
" Replace that occurence with the text we yanked
exec ':.s/\<' . #a . '\>/' . #b
:let #a = l:tmp_a
:let #b = l:tmp_b
endfunction
nnoremap <leader>ri :call InlineVariable()<cr>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" MAPS TO JUMP TO SPECIFIC COMMAND-T TARGETS AND FILES
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
map <leader>gr :topleft :split config/routes.rb<cr>
function! ShowRoutes()
" Requires 'scratch' plugin
:topleft 100 :split __Routes__
" Make sure Vim doesn't write __Routes__ as a file
:set buftype=nofile
" Delete everything
:normal 1GdG
" Put routes output in buffer
:0r! zeus rake -s routes
" Size window to number of lines (1 plus rake output length)
:exec ":normal " . line("$") . "_ "
" Move cursor to bottom
:normal 1GG
" Delete empty trailing line
:normal dd
endfunction
map <leader>gR :call ShowRoutes()<cr>
map <leader>gv :CommandTFlush<cr>\|:CommandT app/views<cr>
map <leader>gc :CommandTFlush<cr>\|:CommandT app/controllers<cr>
map <leader>gm :CommandTFlush<cr>\|:CommandT app/models<cr>
map <leader>gh :CommandTFlush<cr>\|:CommandT app/helpers<cr>
map <leader>gl :CommandTFlush<cr>\|:CommandT lib<cr>
map <leader>gp :CommandTFlush<cr>\|:CommandT public<cr>
map <leader>gs :CommandTFlush<cr>\|:CommandT public/stylesheets<cr>
map <leader>gf :CommandTFlush<cr>\|:CommandT features<cr>
map <leader>gg :topleft 100 :split Gemfile<cr>
map <leader>gt :CommandTFlush<cr>\|:CommandTTag<cr>
map <leader>f :CommandTFlush<cr>\|:CommandT<cr>
map <leader>F :CommandTFlush<cr>\|:CommandT %%<cr>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" SWITCH BETWEEN TEST AND PRODUCTION CODE
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
function! OpenTestAlternate()
let new_file = AlternateForCurrentFile()
exec ':e ' . new_file
endfunction
function! AlternateForCurrentFile()
let current_file = expand("%")
let new_file = current_file
let in_spec = match(current_file, '^spec/') != -1
let going_to_spec = !in_spec
let in_app = match(current_file, '\<controllers\>') != -1 || match(current_file, '\<models\>') != -1 || match(current_file, '\<views\>') != -1 || match(current_file, '\<helpers\>') != -1
if going_to_spec
if in_app
let new_file = substitute(new_file, '^app/', '', '')
end
let new_file = substitute(new_file, '\.e\?rb$', '_spec.rb', '')
let new_file = 'spec/' . new_file
else
let new_file = substitute(new_file, '_spec\.rb$', '.rb', '')
let new_file = substitute(new_file, '^spec/', '', '')
if in_app
let new_file = 'app/' . new_file
end
endif
return new_file
endfunction
nnoremap <leader>. :call OpenTestAlternate()<cr>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" RUNNING TESTS
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
function! MapCR()
nnoremap <cr> :call RunTestFile()<cr>
endfunction
call MapCR()
nnoremap <leader>T :call RunNearestTest()<cr>
nnoremap <leader>a :call RunTests('')<cr>
nnoremap <leader>c :w\|:!script/features<cr>
nnoremap <leader>w :w\|:!script/features --profile wip<cr>
function! RunTestFile(...)
if a:0
let command_suffix = a:1
else
let command_suffix = ""
endif
" Run the tests for the previously-marked file.
let in_test_file = match(expand("%"), '\(.feature\|_spec.rb\)$') != -1
if in_test_file
call SetTestFile()
elseif !exists("t:grb_test_file")
return
end
call RunTests(t:grb_test_file . command_suffix)
endfunction
function! RunNearestTest()
let spec_line_number = line('.')
call RunTestFile(":" . spec_line_number)
endfunction
function! SetTestFile()
" Set the spec file that tests will be run for.
let t:grb_test_file=#%
endfunction
function! RunTests(filename)
" Write the file and run tests for the given filename
if expand("%") != ""
:w
end
if match(a:filename, '\.feature$') != -1
exec ":!script/features " . a:filename
else
" First choice: project-specific test script
if filereadable("script/test")
exec ":!script/test " . a:filename
" Fall back to the .test-commands pipe if available, assuming someone
" is reading the other side and running the commands
elseif filewritable(".test-commands")
let cmd = 'rspec --color --format progress --require "~/lib/vim_rspec_formatter" --format VimFormatter --out tmp/quickfix'
exec ":!echo " . cmd . " " . a:filename . " > .test-commands"
" Write an empty string to block until the command completes
sleep 100m " milliseconds
:!echo > .test-commands
redraw!
" Fall back to a blocking test run with Bundler
elseif filereadable("Gemfile")
exec ":!bundle exec rspec --color " . a:filename
" Fall back to a normal blocking test run
else
exec ":!rspec --color " . a:filename
end
end
endfunction
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" CtrlP Configuration
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:ctrlp_custom_ignore = '\v[\/]\.(git|hg|svn)$'
let g:ctrlp_user_command = 'find %s -type f'
let g:ctrlp_use_caching = 0
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Md5 COMMAND
" Show the MD5 of the current buffer
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
command! -range Md5 :echo system('echo '.shellescape(join(getline(<line1>, <line2>), '\n')) . '| md5')
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" OpenChangedFiles COMMAND
" Open a split for each dirty file in git
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
function! OpenChangedFiles()
only " Close all windows, unless they're modified
let status = system('git status -s | grep "^ \?\(M\|A\|UU\)" | sed "s/^.\{3\}//"')
let filenames = split(status, "\n")
exec "edit " . filenames[0]
for filename in filenames[1:]
exec "sp " . filename
endfor
endfunction
command! OpenChangedFiles :call OpenChangedFiles()
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" InsertTime COMMAND
" Insert the current time
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
command! InsertTime :normal a<c-r>=strftime('%F %H:%M:%S.0 %z')<cr>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" FindConditionals COMMAND
" Start a search for conditional branches, both implicit and explicit
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
command! FindConditionals :normal /\<if\>\|\<unless\>\|\<and\>\|\<or\>\|||\|&&<cr>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Diff tab management: open the current git diff in a tab
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
command! GdiffInTab tabedit %|vsplit|Gdiff
nnoremap <leader>d :GdiffInTab<cr>
nnoremap <leader>D :tabclose<cr>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" RemoveFancyCharacters COMMAND
" Remove smart quotes, etc.
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
function! RemoveFancyCharacters()
let typo = {}
let typo["“"] = '"'
let typo["”"] = '"'
let typo["‘"] = "'"
let typo["’"] = "'"
let typo["–"] = '--'
let typo["—"] = '---'
let typo["…"] = '...'
:exe ":%s/".join(keys(typo), '\|').'/\=typo[submatch(0)]/ge'
endfunction
command! RemoveFancyCharacters :call RemoveFancyCharacters()
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Selecta Mappings
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Run a given vim command on the results of fuzzy selecting from a given shell
" command. See usage below.
function! SelectaCommand(choice_command, selecta_args, vim_command)
try
silent let selection = system(a:choice_command . " | selecta " . a:selecta_args)
catch /Vim:Interrupt/
" Swallow the ^C so that the redraw below happens; otherwise there will be
" leftovers from selecta on the screen
redraw!
return
endtry
redraw!
exec a:vim_command . " " . selection
endfunction
" Find all files in all non-dot directories starting in the working directory.
" Fuzzy select one of those. Open the selected file with :e.
nnoremap <leader>f :call SelectaCommand("find * -type f", "", ":e")<cr>
function! SelectaIdentifier()
" Yank the word under the cursor into the z register
normal "zyiw
" Fuzzy match files in the current directory, starting with the word under
" the cursor
call SelectaCommand("find * -type f", "-s " . #z, ":e")
endfunction
nnoremap <c-g> :call SelectaIdentifier()<cr>
colorscheme jellybeans
highlight clear SignColumn
autocmd BufNewFile,BufRead *.mobile.erb let b:eruby_subtype='html'
autocmd BufNewFile,BufRead *.mobile.erb set filetype=eruby
autocmd BufNewFile,BufRead .pryrc set filetype=ruby
map <silent> <C-N> :silent noh<CR>
map <silent> <C-T> :NERDTree <CR>
map <silent> gb :Gblame<CR>
map <silent> gc :Gcommit<CR>
map <silent> gC :Gcommit -a<CR>
map <silent> gl :gitv<CR>
map <silent> gs :Gstatus<CR>
map <silent> ws :EraseBadWhitespace<CR>
"No arrow keys. :(
inoremap <Up> <NOP>
inoremap <Down> <NOP>
inoremap <Left> <NOP>
inoremap <Right> <NOP>
noremap <Up> <NOP>
noremap <Down> <NOP>
noremap <Left> <NOP>
noremap <Right> <NOP>
I added a comment, and then noticed that the very bottom of your vimrc file shows that I was right. The culprit is
:map <silent> ws :EraseBadWhitespace<CR>
According to :help map-modes, the :map command applies in Normal, Visual, Select, and Operator-pending modes. After you type c, vim enters Operator-pending mode, and then it waits to see if you just want w or if you plan to add an s. See also
:help 'timeout'
I know this has already been discussed, but the proposed solution is not working for me.
I have this in my .vimrc:
autocmd! BufWritePost .vimrc nested source $MYVIMRC
Since I read that the correct way to source .vimrc inside an autocmd is using autocmd-nested.
Still, everytime I save it I lose colors in powerline
Edit:
here is my .vimrc
filetype off
set rtp+=~/.vim/vundle.git/
call vundle#rc()
set rtp+=~/.vim/bundle/powerline/powerline/bindings/vim
"set statusline+=%#warningmsg#
"set statusline+=%{SyntasticStatuslineFlag()}
"set statusline+=%*
let g:syntastic_enable_signs=1
let g:syntastic_auto_loc_list=1
let g:ctrlp_working_path_mode = 'ra'
" Bundles
"
" original repos on github
"Bundle 'vim-scripts/taglist.vim'
Bundle 'majutsushi/tagbar'
"Bundle 'joonty/vim-phpqa.git'
"Bundle 'joonty/vim-phpunitqf'
Bundle 'joonty/vdebug'
" Php
Bundle 'sumpygump/php-documentor-vim'
Bundle 'sophacles/vim-processing'
Bundle 'nelstrom/vim-visual-star-search'
Bundle 'Lokaltog/powerline'
Bundle 'spolu/dwm.vim'
Bundle 'tpope/vim-unimpaired'
Bundle 'airblade/vim-gitgutter'
Bundle 'kien/ctrlp.vim'
Bundle 'wikitopian/hardmode'
Bundle 'tpope/vim-fugitive'
Bundle 'sbl/scvim'
Bundle 'vim-scripts/bufexplorer'
Bundle 'aaronbieber/quicktask'
Bundle 'vim-scripts/The-NERD-Commenter'
Bundle 'tpope/vim-fugitive'
Bundle 'tpope/vim-surround'
Bundle 'vim-scripts/HTML-AutoCloseTag'
Bundle 'scrooloose/nerdtree'
"Bundle 'scrooloose/syntastic'
Bundle 'vim-scripts/css_color.vim'
" Color schemes
Bundle 'tomasr/molokai'
Bundle 'altercation/vim-colors-solarized'
Bundle 'vim-scripts/OOP-javascript-indentation'
let g:gitgutter_enabled = 0
set nocompatible "Don't be compatible with vi
" Enable filetype plugin
filetype indent on
filetype plugin on
" Set to auto read when a file is changed from the outside
set autoread
set t_Co=16
set background=dark
set number "Show line numbering
set numberwidth=1 "Use 1 col + 1 space for numbers
" With a map leader it's possible to do extra key combinations
let mapleader = ","
let g:mapleader = ","
" Toggle NERDTree
map <leader>n :NERDTreeToggle<CR>
set backupdir=~/.vim/backup " where to put backup files
set directory=~/.vim/temp " where to put swap files
" Fast saving
nmap <leader>w :w!<cr>
" Fast editing of the .vimrc
map <leader>e :e $MYVIMRC<cr>
" When .vimrc is edited, reload it
augroup MyAutoCmd
autocmd!
augroup END
autocmd MyAutoCmd BufWritePost $MYVIMRC nested source $MYVIMRC
"au! BufWritePost .vimrc nested source %
set title
" Remap esc key
inoremap jk <esc>
" work more logically with wrapped lines
noremap j gj
noremap k gk
set smartcase " search case sensitive if caps on
set showcmd " Display what command is waiting for an operator
autocmd BufNewFile,BufRead /*apache* setfiletype apache
autocmd BufNewFile,BufRead /*lighttpd*.conf setfiletype lighty
autocmd BufNewFile,BufRead {.,_}vimrc set foldmethod=marker
" PhpDocumentor
au BufRead,BufNewFile *.php inoremap <buffer> <leader>p :call PhpDoc()<CR>
au BufRead,BufNewFile *.php nnoremap <buffer> <leader>p :call PhpDoc()<CR>
au BufRead,BufNewFile *.php vnoremap <buffer> <leader>p :call PhpDocRange()<CR>
" Nicer highlighting of completion popup
highlight Pmenu guibg=brown gui=bold
set scrolloff=7 "Set 7 lines to the cursors when moving vertical
set wildmenu "Autocomplete features in the status bar
set ruler "Always show current position
set cmdheight=2 "The commandbar height
set hidden "Change buffer without saving
" Backspae config
set backspace=eol,start,indent
set whichwrap+=<,>,h,l
set ignorecase "Search is case insensitive
set hlsearch "Highlight matches to the search
set incsearch "Show best match so far
set magic "Set magic on for regular expressions
set showmatch "Show matching bracets when text indicator is over them
set mat=2 "How many tenths of a second to blink
" No sound on errors
set noerrorbells
set novisualbell
set t_vb=
" Colors and fonts {{{1
set term=screen-256color
syntax enable "Enable syntax hl
syntax on "Enable syntax hl
"colorscheme molokai
"let g:solarized_termcolors=256
colorscheme solarized
set guifont=Envy\ Code\ R\ for\ Powerline
set encoding=utf-8
filetype plugin on
"set guifont=Inconsolata\ for\ Powerline\
let g:Powerline_symbols="fancy"
" Text, tab and indent related {{{1
set expandtab "Transform tabs into spaces
set shiftwidth=4 "sw 4 spaces (used on auto indent)
set shiftwidth=4 "sw 4 spaces (used on auto indent)
set tabstop=4 "4 spaces as a tab for bs/del
set smarttab
set wrap linebreak tw=80 wm=0 "Wrap lines
set ai "Auto indent
set si "Smart indent
" }}}1
" Moving around, tabs and buffers {{{1
" Move to previous and next buffer
:nmap <C-n> :bnext<CR>
:nmap <C-p> :bprev<CR>
" Map space to / (search) and c-space to ? (backwards search)
map <space> /
map <c-space> ?
map <silent> <leader><cr> :noh<cr>
" Smart way to move between windows
map <C-j> <C-W>j
map <C-k> <C-W>k
map <C-h> <C-W>h
map <C-l> <C-W>l
" Mappings to access buffers (don't use "\p" because a
" delay before pressing "p" would accidentally paste).
" ,l : list buffers
" ,b ,f ,g : go back/forward/last-used
" ,1 ,2 ,3 : go to buffer 1/2/3 etc
nnoremap <Leader>l :ls<CR>
nnoremap <Leader>b :bp<CR>
nnoremap <Leader>f :bn<CR>
nnoremap <Leader>g :e#<CR>
nnoremap <Leader>1 :1b<CR>
nnoremap <Leader>2 :2b<CR>
nnoremap <Leader>3 :3b<CR>
nnoremap <Leader>4 :4b<CR>
nnoremap <Leader>5 :5b<CR>
nnoremap <Leader>6 :6b<CR>
nnoremap <Leader>7 :7b<CR>
nnoremap <Leader>8 :8b<CR>
nnoremap <Leader>9 :9b<CR>
nnoremap <Leader>0 :10b<CR>
" Close the current buffer. Bclose defined below.
" dovrebbe già esistere in bufkill.vim
" map <leader>bd :Bclose<cr>
" Use the arrows to do something useful
map <right> :bn<cr>
map <left> :bp<cr>
" MiniBufExplorer settings
let g:miniBufExplModSelTarget = 1
let g:miniBufExplorerMoreThanOne = 2
let g:miniBufExplModSelTarget = 0
let g:miniBufExplUseSingleClick = 1
let g:miniBufExplMapWindowNavVim = 1
" Change directory to the file I'm editing
"autocmd BufEnter * lcd %:p:h
" When pressing <leader>cd switch to the directory of the open buffer
map <leader>cd :cd %:p:h<cr>
" Function to close buffer?
command! Bclose call <SID>BufcloseCloseIt()
function! <SID>BufcloseCloseIt()
let l:currentBufNum = bufnr("%")
let l:alternateBufNum = bufnr("#")
if buflisted(l:alternateBufNum)
buffer #
else
bnext
endif
if bufnr("%") == l:currentBufNum
new
endif
if buflisted(l:currentBufNum)
execute("bdelete! ".l:currentBufNum)
endif
endfunction
" Specify the behavior when switching between buffers
try
set switchbuf=usetab
set stal=2
catch
endtry
nnoremap <C-e> 3<C-e>
nnoremap <C-y> 3<C-y>
" Always hide the statusline
set laststatus=2
" Format the statusline
set statusline=\ %F%m%r%h\ %w\ \ [%Y]\ \ CWD:\ %r%{CurDir()}%h\ \ \ Line:\ %l/%L:%c
"set statusline=%F%m%w\ Line:\ %l\/%L[%p%%]\ Col:\ %c\ Buf:\ #%n\ [%Y]\ [\%03.3b]\[\%02.2B]
function! CurDir()
let curdir = substitute(getcwd(), '/Users/amir/', "~/", "g")
return curdir
endfunction
" tab labels show the filename without path(tail)
set guitablabel=%N/\ %t\ %M
""" Windows
if exists(":tab") " Try to move to other windows if changing buf
set switchbuf=useopen,usetab
else " Try other windows & tabs if available
set switchbuf=useopen
endif
"""" Messages, Info, Status
set shortmess+=a " Use [+] [RO] [w] for modified, read-only, modified
set report=0 " Notify me whenever any lines have changed
set confirm " Y-N-C prompt if closing with unsaved changes
" we don't want to edit these type of files
set wildignore=*.o,*.obj,*.bak,*.exe,*.pyc,*.swp
"""" Coding
set history=1000 " 1000 Lines of history
set showfulltag " Show more information while completing tags
" taglist plugin settings
"nnoremap <silent> <F8> :TlistToggle<CR>
let Tlist_Exit_OnlyWindow = 1 "exit if taglist is last window open
let Tlist_Show_One_File = 1 "only show tags for current buffer
let Tlist_Enable_Fold_Column = 0 "no fold column (only showing one file)
" OmniCppComplete
let OmniCpp_NamespaceSearch = 1
let OmniCpp_GlobalScopeSearch = 1
let OmniCpp_ShowAccess = 1
let OmniCpp_ShowPrototypeInAbbr = 1 " show function parameters
let OmniCpp_MayCompleteDot = 1 " autocomplete after .
let OmniCpp_MayCompleteArrow = 1 " autocomplete after ->
let OmniCpp_MayCompleteScope = 1 " autocomplete after ::
let OmniCpp_DefaultNamespaces = ["std", "_GLIBCXX_STD"]
" automatically open and close the popup menu / preview window
au CursorMovedI,InsertLeave * if pumvisible() == 0|silent! pclose|endif
set completeopt=menuone,menu,longest,preview
let g:sparkupNextMapping = '<c-x>'
" SuperTab settings
let g:SuperTabDefaultCompletionType = '<c-x><c-o>'
""""" Folding
set foldmethod=syntax " By default, use syntax to determine folds
set foldlevelstart=99 " All folds open by default
" Function to highlight character beyond column 79
" activate it with ,h
nnoremap <leader>h :call ToggleOverLengthHighlight()<CR>
let g:overlength_enabled = 0
" set the highlight color
highlight OverLength ctermbg=red guibg=red
function! ToggleOverLengthHighlight()
if g:overlength_enabled == 0
match OverLength /\%79v.*/
let g:overlength_enabled = 1
echo 'OverLength highlighting turned on'
else
match
let g:overlength_enabled = 0
echo 'OverLength highlighting turned off'
endif
endfunction
" in visual mode press Ctrl r to start substituting text
vnoremap <C-r> "hy:%s/<C-r>h//gc<left><left><left>
" PHP Code Sniffer binary (default = "phpcs")
let g:phpqa_codesniffer_cmd='vendor/bin/phpcs'
" PHP Mess Detector binary (default = "phpmd")
let g:phpqa_messdetector_cmd='vendor/bin/phpmd'
set relativenumber
" important
" moving around, searching and patterns
" tags
" displaying text
" syntax, highlighting and spelling
" multiple windows
" multiple tab pages
" terminal
" using the mouse
" printing
" messages and info
" selecting text
" editing text
" tabs and indenting
" folding
" diff mode
" mapping
" toggle the tag list
nmap <Leader>tl :TlistToggle<CR>
" reading and writing files
" the swap file
" command line editing
" executing external commands
" running make and jumping to errors
" language specific
" multi-byte characters
" various
" TagList options
" set the names of flags
let tlist_php_settings = 'php;c:class;f:function;d:constant;p:property'
" close all folds except for current file
let Tlist_File_Fold_Auto_Close = 1
" make tlist pane active when opened
let Tlist_GainFocus_On_ToggleOpen = 1
" width of window
let Tlist_WinWidth = 60
" close tlist when a selection is made
let Tlist_Close_On_Select = 1
" show the prototype
let Tlist_Display_Prototype = 1
" show tags only for current buffer
let Tlist_Show_One_File = 1
" Taglist variables
" Display function name in status bar:
let g:ctags_statusline=1
" Automatically start script
let generate_tags=1
" Displays taglist results in a vertical windows:
let Tlist_Use_Horiz_Window=0
" Shorter commands to toggle Taglist display
nnoremap TT :TlistToggle<CR>
map <F4> :TlistToggle<CR>
" Various Taglist display config:
let Tlist_Use_Right_Windows = 1
let Tlist_Compact_Format = 1
let Tlist_Exit_OnlyWindow = 1
let Tlist_GainFocus_On_ToggleOpen = 1
let Tlist_File_Fold_Auto_Close = 1
" Ctags options
nmap <Leader>tf :call CtagsFind(expand('<cword>'))<CR>
com! -nargs=+ Tf :call CtagsFind("<args>")
" split window and search for tag
nmap <Leader>ts :exe('stj '.expand('<cword>'))<CR>
set tags=tags;/
" open new tab and search for tag
"
fun! CtagsFind(keyword)
tabe
exe "tj ".a:keyword
endfunction
" TagBar
nmap <F8> :TagbarToggle<CR>
" CtrlP
let g:ctrlp_map = ',t'
nnoremap <silent> ,t :CtrlP<CR>
Your autocmd will be appended to your vim events.
You need handle reload with using augroup.
augroup MyAutoCmd
autocmd!
autocmd MyAutoCmd BufWritePost $MYVIMRC nested source $MYVIMRC
augroup END