I am new to vim. I have written my default settings in the vimrc file. My vimrc file has been given below. In that file I have written set ai command for auto-indentation. But it isn't working. I have to write the command every time I start working on vim.
I also have a plugin vim-indent-guides installed. I want the command IndentGuidesEnable to be run when vim starts. But I am failing here also. What I am doing wrong?
call plug#begin()
Plug 'chriskempson/base16-vim'
Plug 'scrooloose/nerdtree', {'on': 'NERDTreeToggle'}
Plug 'scrooloose/syntastic'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-surround'
Plug 'bling/vim-airline'
Plug 'majutsushi/tagbar'
Plug 'scrooloose/nerdcommenter'
Plug 'airblade/vim-gitgutter'
Plug 'valloric/youcompleteme'
Plug 'pangloss/vim-javascript'
Plug 'easymotion/vim-easymotion'
Plug 'vim-airline/vim-airline'
Plug 'godlygeek/tabular'
Plug 'honza/vim-snippets'
Plug 'ervandew/supertab'
Plug 'tpope/vim-repeat'
Plug 'mattn/emmet-vim'
Plug 'nathanaelkane/vim-indent-guides'
Plug 'shougo/unite.vim'
Plug 'terryma/vim-multiple-cursors'
call plug#end()
set number
set paste
set runtimepath^=~/.vim/bundle/ctrlp.vim
set foldmethod=indent
set foldlevel=99
set tabstop=4
set softtabstop=4
set shiftwidth=4
set textwidth=79
set expandtab
set fileformat=unix
set ai
set list listchars=tab:→\ ,eol:↲,nbsp:␣,trail:•,extends:⟩,precedes:⟨
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>
nnoremap <space> za
autocmd VimEnter * NERDTreeToggle .
autocmd VimEnter * IndentGuidesEnable
Related
While in insert mode, my vim is entering normal mode when I press the key: option + 8 or 9, this corresponds to a [ or ], respectively on my mac. To write code this is really annoying, as I need brackets a lot. How can I remove this? Thank you.
I attach below my .vimrc file.
I have changed the esc key in inoremap to "jk" and the map leader key to ";".
Update: My terminal is alacritty, and there I don't have this problem. Only in vim.
" Disable compatibility with vi which can cause unexpected issues.
set nocompatible
" Enable type file detection. Vim will be able to try to detect the type of file in use.
filetype on
" Enable plugins and load plugin for the detected file type.
filetype plugin on
" Load an indent file for the detected file type.
filetype indent on
" While searching though a file incrementally highlight matching characters as you type.
set incsearch
" Enable auto completion menu after pressing TAB.
set wildmenu
" Make wildmenu behave like similar to Bash completion.
set wildmode=list:longest
" There are certain files that we would never want to edit with Vim.
" Wildmenu will ignore files with these extensions.
set wildignore=*.docx,*.jpg,*.png,*.gif,*.pdf,*.pyc,*.exe,*.flv,*.img,*.xlsx
:set relativenumber
:set number
:set autoindent
:set tabstop=4
:set shiftwidth=4
:set smarttab
:set softtabstop=4
:set mouse=a
:colorscheme iceberg
set termguicolors
set t_Co=256
set background=dark
set term=xterm-256color
set foldmethod=indent
set foldnestmax=10
set nofoldenable
set foldlevel=2
syntax on
syntax enable
" Highlight cursor line underneath the cursor horizontally.
set cursorline
set backspace=indent,eol,start
" Highlight cursor line underneath the cursor vertically.
set cursorcolumn
set list
set showbreak=↪\
set listchars=tab:→\ ,eol:↲,nbsp:␣,trail:•,extends:⟩,precedes:⟨
call plug#begin('~/.config/nvim/plugged')
Plug 'https://github.com/tpope/vim-commentary' " For Commenting gcc & gc
Plug 'https://github.com/tc50cal/vim-terminal' " Vim Terminal
Plug 'https://github.com/ryanoasis/vim-devicons' " Developer Icons
Plug 'https://github.com/neoclide/coc.nvim' " Auto Completion
Plug 'https://github.com/preservim/nerdtree' " NerdTree
"Plug 'ap/vim-css-color'
Plug 'ryanoasis/vim-devicons'
Plug 'vim-airline/vim-airline'
Plug 'Xuyuanp/nerdtree-git-plugin'
Plug 'tiagofumo/vim-nerdtree-syntax-highlight'
Plug 'airblade/vim-gitgutter'
Plug 'ctrlpvim/ctrlp.vim' " fuzzy find files
Plug 'scrooloose/nerdcommenter'
Plug 'christoomey/vim-tmux-navigator'
Plug 'morhetz/gruvbox'
Plug 'HerringtonDarkholme/yats.vim' " TS Syntax
Plug 'https://github.com/terryma/vim-multiple-cursors' " CTRL + N for multiple cursors
Plug 'vimwiki/vimwiki'
set encoding=UTF-8
call plug#end()
let g:vimwiki_list = [{'path': '~/vimwiki/',
\ 'syntax': 'markdown', 'ext': '.md'}]
nnoremap <C-n> :NERDTree<CR>
inoremap jk <ESC>
" Set the backslash as the leader key."
let mapleader = ','
nmap <C-n> :NERDTreeToggle<CR>
vmap ++ <plug>NERDCommenterToggle
let g:NERDTreeGitStatusWithFlags = 1
tnoremap jk <C-\><c-n>
nmap <F8> :TagbarToggle<CR>
let &t_SI.="\e[5 q" "SI = INSERT mode
let &t_SR.="\e[4 q" "SR = REPLACE mode
" Have nerdtree ignore certain files and directories.
let NERDTreeIgnore=['\.git$', '\.jpg$', '\.mp4$', '\.ogg$', '\.iso$', '\.pdf$', '\.pyc$', '\.odt$', '\.png$', '\.gif$', '\.db$']
The problem was in my alacritty terminal. Fixed it by changing the alacritty.yml config to:
alt_send_esc: false
I've been using Vim for about 6 month and finally reached the level where I can't live without it.
I'm really grateful for those who wrote great tutorials or blog posts, and kindly answered easy questions which helped be alot.
Since I started using the autocompletion Plugin, Jedi, characters from the autocompletion window still remain in main window after the autocompletion window is disappeared. I thought this problem was only limited to the Jedi Plugin, but after I changed it into COC Plugin, I still experience the same problem.
I've searched quite a lot and couldn't find any thread about this problem and now I'm starting to think this problem is only occuring to me.
Solution to the problem is the best, but I'll be still grateful for any suggestions, link to a other thread.
I attached my .vimrc below.
Vim 8.2
Windows 10
" vim runtime config file
" Written by Knowblesse 2020
" Adapted from miguelgrinberg/.vimrc
"""""""""""""""""""""""""""""""""""
" Basics "
"""""""""""""""""""""""""""""""""""
" Sane text files
set fileformat=unix " uses line ending LF (not DOS-style CR LF)
set encoding=utf-8
set fileencoding=utf-8
" View
set number
set colorcolumn=100
set nowrap
set hlsearch
set relativenumber
set scrolloff=8
set scrolloff=8
set splitright
set clipboard=unnamedplus
" Tab
set tabstop=4
set shiftwidth=4
set softtabstop=4
set expandtab
" Font
if has('unix')
echo "Unix Mode"
set guifont=Bitstream\ Vera\ Sans\ Mono\ 12
else
echo "Window Mode"
set guifont=Bitstream\ Vera\ Sans\ Mono:h12
endif
"""""""""""""""""""""""""""""""""""
" Key Bindings "
"""""""""""""""""""""""""""""""""""
imap jk <Esc>
nmap <Tab> >>
nmap <S-tab> <<
vmap < <gv
vmap > >gv
map <leader>t :call NERDTreeToggle()<CR>
"remove highlighted
nmap <leader>] : nohlsearch<CR>
"delete buffer w/o closing the current window
nmap <leader>q :bp\|bd #<CR>
"faster editting
if has('unix')
nmap <leader>vv :e ~/VCF/vimrc/vimrc.vim <CR>
else
nmap <leader>vv :e C:\VCF\vimrc\vimrc.vim <CR>
endif
"""""""""""""""""""""""""""""""""""
" Color Scheme "
"""""""""""""""""""""""""""""""""""
syntax on
colorscheme monokai
filetype on
filetype plugin indent on
"""""""""""""""""""""""""""""""""""
" Plugin "
"""""""""""""""""""""""""""""""""""
"monokai theme is manually installed
"ctag is manually installed
call plug#begin()
Plug 'yegappan/taglist'
Plug 'tpope/vim-sensible'
Plug 'mg979/vim-visual-multi'
"buffer lists instead of tab
Plug 'ap/vim-buftabline'
"NERD
Plug 'preservim/nerdtree'
"Git
Plug 'airblade/vim-gitgutter'
Plug 'Xuyuanp/nerdtree-git-plugin'
Plug 'tpope/vim-fugitive'
"Coding
Plug 'davidhalter/jedi-vim'
Plug 'ervandew/supertab'
"Plug 'dense-analysis/ale'
Plug 'itchyny/lightline.vim'
"Color theme
Plug 'joshdick/onedark.vim'
"Table generataion
Plug 'dhruvasagar/vim-table-mode'
"Vertical line generation
Plug 'Yggdroot/indentLine'
" For Testing .....................
"Auto Commplete
Plug 'neoclide/coc.nvim', {'branch': 'release'}
"Arduino
Plug 'stevearc/vim-arduino'
call plug#end()
Red arrows shows remaining characters
so im trying to install some plugins for vim but some errors pop up "E492: Not an editor command: Pluginstall" i downloaded Vundle and i think i entered other thing correctly
syntax on
set nocompatible
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
set noerrorbells
set tabstop=4 softtabstop=4
set shiftwidth=4
set expandtab
set smartindent
set nu
set nowrap
set smartcase
set noswapfile
set nobackup
set undodir=~/.vim/undodir
set undofile
set incsearch
set colorcolumn=80
highlight ColorColumn ctermbg=0 guibg=lightgrey
call vundle#begin()
Plug 'gmarik/vundle'
Plug 'morhetz/gruvbox'
plug 'jremmen/vim-ripgrep'
Plug 'tpope/vim-fugitive'
Plug 'vim-utils/vim-man'
Plug 'git#github.com:kien/ctrlp.vim.git'
Plug 'git#github.com:Valloric/YouCompleteMe.git'
Plug 'mbill/undotree'
call vundle#end()
filetype plugin indent on
and source % works fine but when i type :PluginInstall the error pop up
If you use Vundle the commands are Plugin and PluginInstall.
Commands Plug and PlugInstall are for vim-plug.
After a line of code wraps onto the next line, I find that the closing brace isn't aligned properly. Here's an image to demonstrate what's going on:
Ideally the closing brace should be in line with while.
Here are my vimrc settings:
filetype plugin indent on
syntax on
set backspace=indent,eol,start
set expandtab
set tabstop=2
set shiftwidth=2
set softtabstop=2
set showtabline=2
set number
set showcmd
set cursorline
set wildmenu
set lazyredraw
set showmatch
call plug#begin('~/.vim/plugged')
Plug 'scrooloose/nerdtree'
Plug 'drewtempelmeyer/palenight.vim'
Plug 'NLKNguyen/papercolor-theme'
Plug 'rakr/vim-one'
Plug 'morhetz/gruvbox'
Plug 'tpope/vim-commentary'
Plug 'ajh17/VimCompletesMe'
Plug 'sheerun/vim-polyglot'
call plug#end()
highlight ColorColumn ctermbg=gray
set colorcolumn=81
autocmd BufNewFile,BufRead * setlocal formatoptions=croqtn textwidth=80
set t_Co=256
set term=xterm-256color
let g:gruvbox_contrast_dark='dark'
colorscheme gruvbox
set background=dark
map <C-x> :NERDTreeToggle<CR>
noremap <TAB> <C-W>w
" autoclose matching quotes, braces and parentheses
inoremap {<CR> {<CR>}<ESC>O
inoremap {;<CR> {<CR>};<ESC>O
inoremap jj <Esc>
inoremap <Esc> <Nop>
inoremap <expr> <CR> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
inoremap <C-y> <C-o>h
inoremap <C-u> <C-o>l
I currently use Iterm2, and Vim 7.4 with the Minimalist Vim Plugin Manager. While opening a file through Vim, I get the error:
Error detected while processing MYDIRECTORY/.vimrc:
line 19:
E185: Cannot find color scheme 'onedark'
Press ENTER or type command to continue
The onedark theme doesn't load, but if, in Vim, I type :colorscheme onedark, it loads perfectly.
My .vimrc is as follows:
set t_Co=256
set autoindent
set mouse=a
set number
set shiftwidth=0
set tabstop=4
"let g:airline_theme='onedark'
"Use 24-bit (true-color) mode in Vim/Neovim when outside tmux."
if (has("nvim"))
let $NVIM_TUI_ENABLE_TRUE_COLOR=1
endif
if (has("termguicolors"))
set termguicolors
endif
set background=dark
colorscheme onedark
syntax on
call plug#begin('~/.vim/plugged')
"Make sure you use single quotes
"ATOM Text Editor Default Syntax Theme"
Plug 'https://github.com/joshdick/onedark.vim.git'
"Shorthand notation; fetches https://github.com/junegunn/vim-easy-align
Plug 'junegunn/vim-easy-align'
"Any valid git URL is allowed
Plug 'https://github.com/junegunn/vim-github-dashboard.git'
"Multiple Plug commands can be written in a single line using |
"separators
Plug 'SirVer/ultisnips' | Plug 'honza/vim-snippets'
"On-demand loading
Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
Plug 'tpope/vim-fireplace', { 'for': 'clojure' }
"Using a non-master branch
Plug 'rdnetto/YCM-Generator', { 'branch': 'stable' }
"Using a tagged release; wildcard allowed (requires git 1.9.2 or
"above)
Plug 'fatih/vim-go', { 'tag': '*' }
"Plugin options
Plug 'nsf/gocode', { 'tag': 'v.20150303', 'rtp': 'vim' }
"Plugin outside /.vim/plugged with post-update hook
Plug 'junegunn/fzf', { 'dir': '/.fzf', 'do': './install --all' }
Plug 'https://github.com/exvim/ex-autocomplpop'
"Initialize plugin system
call plug#end()
What should I do?
The way vim-plug works is this:
call plug#begin('~/.vim/plugged')
creates a bunch of functions/commands and sets a bunch of options,
Plug 'https://github.com/joshdick/onedark.vim.git'
adds that resource to an internal list,
call plug#end()
actually installs all your plugins in ~/.vim/plugged if they are not there and sets up your :help 'runtimepath' to the correct value that tells Vim where to look for plugins.
So, basically, you can't expect a plugin installed by vim-plug to be available before vim-plug did its magic.
Moving colorscheme onedark below call plug#end() should solve your problem.