Last active
November 8, 2022 15:56
-
-
Save ghost355/de3ec24795cf80fdc8a675e352e0f332 to your computer and use it in GitHub Desktop.
Vim testing .vimrc file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Настройка Vim | |
1. Базовая настройка | |
a. Настройка поведения | |
b. Настройка внешнего вида | |
c. | |
2. Настройка клавиш | |
a. Настройка Lead key | |
b. Настройка команд | |
c. Настройки для плагинов | |
3. Настройка плагинов | |
a. Менеджер Плагинов | |
b. Загрузка плагинов | |
c. Список нужных плагинов | |
============================================================= | |
“Плагины | |
if empty(glob('~/.vim/autoload/plug.vim')) "Если vim-plug не стоит | |
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs "Создать директорию | |
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim | |
"И скачать его оттуда | |
"А после прогнать команду PlugInstall, о которой мы сейчас поговорим | |
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC | |
endif | |
“ Разное | |
set nocompatible | |
set autoread | |
au FocusGained,BufEnter * checktime | |
set autowrite | |
filetype plugin on | |
set backspace = indent, eol, start | |
set formatoptions+=j | |
set history=1000 | |
set undolevels=1000 | |
set nomodeline | |
set noswapfile | |
set nobackup | |
set nowritebackup | |
set spell | |
“ Отступы | |
set autoindent | |
set expandtab | |
set filetype indend on | |
set shiftround | |
set shiftwidth=4 | |
set tabstop=4 | |
set softtabstop=4 | |
set smarttab | |
“ Поиск | |
set hlsearch | |
set ignorecase | |
set incsearch | |
set smartcase | |
set showmatch | |
set gdefault “ опция g-весь документ включена при замене по умолчанию | |
" For regular expressions turn magic on | |
set magic | |
set regexpengine=0 | |
“ Производительность | |
set complete-=i | |
set lazyreadraw | |
set ttyfast | |
“ Рендеринг текста | |
set display+=lastline | |
set encoding=utf-8 | |
set ffs=unix,dos,mac | |
set linebreak | |
set scrolloff=5 | |
set sidescrolloff=5 | |
syntax enable | |
set tw=100 | |
set wrap | |
set virtualedit+=block " allow the cursor to go anywhere in visual block mode | |
" Не сбрасывать скопированное после вставки: | |
xnoremap p pgvy | |
xnoremap P Pgvy | |
" Скобки и др парные символы | |
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 | |
“ Свертка | |
set foldmethod=indent | |
set foldnestmax=3 | |
set nofoldenable | |
“ Интерфейс | |
set laststatus=2 | |
" Format the status line | |
set statusline=\ %{HasPaste()}%F%m%r%h\ %w\ \ CWD:\ %r%{getcwd()}%h\ \ \ Line:\ %l\ \ Column:\ %c | |
set ruler | |
set wildmenu | |
set wildignore+= *.so,*.swp,*.zip,*.gz,*.xz,*.pyc,*.db,*.sqlite,*.jpg,*.png | |
set wildchar=<Tab> | |
set tabpagemax=10 | |
“set colorscheme themename | |
set number relativenumber | |
set noerrorbells | |
set visualbell | |
set mouse=a | |
set title | |
set background=dark | |
set cmdheight=1 | |
set hidden | |
" Add a bit extra margin to the left | |
set foldcolumn=2 | |
" Показывать колонну на 100 символе строк (по счёту) | |
"set colorcolumn=100 | |
" Подсвечивать строку на которой находится курсор | |
set cursorline | |
" Прекратить подсвечивать её при переходе в режим INSERT | |
autocmd InsertEnter,InsertLeave * set cursorline! | |
set guioptions= "Отключаем панели прокрутки в GUI | |
set showtabline=0 "Отключаем панель табов (окошки FTW) | |
"... для изменения курсора в разных режимах используйте это: | |
set ttimeoutlen=10 "Понижаем задержку ввода escape последовательностей | |
let &t_SI.="\e[5 q" "SI = режим вставки | |
let &t_SR.="\e[3 q" "SR = режим замены | |
let &t_EI.="\e[1 q" "EI = нормальный режим | |
"Где 1 - это мигающий прямоугольник | |
"2 - обычный прямоугольник | |
"3 - мигающее подчёркивание | |
"4 - просто подчёркивание | |
"5 - мигающая вертикальная черта | |
"6 - просто вертикальная черта | |
“ Решение проблемы русской раскладки | |
let g:xkbswitchenabled = 1 | |
" 256 цветов (Использовать RGB) | |
set t_Co=256 | |
" Тот же параметр, но вне графического сервера (Xorg, Wayland) | |
if !has('gui_running') | |
set t_Co=256 | |
endif | |
" Ignore compiled files | |
set wildignore=*.o,*~,*.pyc | |
if has("win16") || has("win32") | |
set wildignore+=.git\*,.hg\*,.svn\* | |
else | |
set wildignore+=*/.git/*,*/.hg/*,*/.svn/*,*/.DS_Store | |
endif | |
" Disable scrollbars (real hackers don't use scrollbars for navigation!) | |
set guioptions-=r | |
set guioptions-=R | |
set guioptions-=l | |
set guioptions-=L | |
2. | |
“ Кнопки | |
" Убираю Shift+s, а то бесит :) | |
noremap S <Nop> | |
let mapleader = " " | |
nnoremap ; : | |
vnoremap ; : | |
map 0 ^ | |
" Перемещение по окнам | |
nnoremap <C-h> <C-w>h | |
nnoremap <C-j> <C-w>j | |
nnoremap <C-k> <C-w>k | |
nnoremap <C-l> <C-w>l | |
" Создать вертикальный сплит окно и перейти в него | |
noremap <leader>v <C-w>v | |
" Clear match highlighting | |
noremap <leader><CR> :noh<cr>:call clearmatches()<cr> | |
" Quick buffer switching | |
nnoremap <leader><TAB> <C-^> | |
" Visual line nav, not real line nav | |
" If you wrap lines, vim by default won't let you move down one line to the | |
" wrapped portion. This fixes that. | |
noremap j gj | |
noremap k gk | |
" Fast saving | |
nmap <leader>w :w!<cr> | |
" :W sudo saves the file | |
" (useful for handling the permission-denied error) | |
command! W execute 'w !sudo tee % > /dev/null' <bar> edit! | |
" Visual mode pressing * or # searches for the current selection | |
" Super useful! From an idea by Michael Naumann | |
vnoremap <silent> * :<C-u>call VisualSelection('', '')<CR>/<C-R>=@/<CR><CR> | |
vnoremap <silent> # :<C-u>call VisualSelection('', '')<CR>?<C-R>=@/<CR><CR> | |
" Toggle paste mode on and off | |
map <leader>pp :setlocal paste!<cr> | |
" 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= | |
" 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> | |
" Close the current buffer | |
map <leader>bd :Bclose<cr>:tabclose<cr>gT | |
" Close all the buffers | |
map <leader>ba :bufdo bd<cr> | |
map <leader>l :bnext<cr> | |
map <leader>h :bprevious<cr> | |
" Useful mappings for managing tabs | |
map <leader>tn :tabnew<cr> | |
map <leader>to :tabonly<cr> | |
map <leader>tc :tabclose<cr> | |
map <leader>tm :tabmove | |
map <leader>t<leader> :tabnext<cr> | |
" Let 'tl' toggle between this and the last accessed tab | |
let g:lasttab = 1 | |
nmap <leader>tl :exe "tabn ".g:lasttab<CR> | |
au TabLeave * let g:lasttab = tabpagenr() | |
" Opens a new tab with the current buffer's path | |
" Super useful when editing files in the same directory | |
map <leader>te :tabedit <C-r>=escape(expand("%:p:h"), " ")<cr>/ | |
" Switch CWD to the directory of the open buffer | |
map <leader>cd :cd %:p:h<cr>:pwd<cr> | |
" Specify the behavior when switching between buffers | |
try | |
set switchbuf=useopen,usetab,newtab | |
set stal=2 | |
catch | |
endtry | |
" Return to last edit position when opening files (You want this!) | |
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif | |
" => Helper functions | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" Returns true if paste mode is enabled | |
function! HasPaste() | |
if &paste | |
return 'PASTE MODE ' | |
endif | |
return '' | |
endfunction | |
" Don't close window, when deleting a 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 | |
3. | |
call plug#begin('~/.vim/bundle') | |
Plug 'lyokha/vim-xkbswitch' | |
call plug#end() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment