From 307d2ef4d4d0174f749388fdd6396d8bc64d0f52 Mon Sep 17 00:00:00 2001 From: Max Christian Pohle Date: Wed, 11 Oct 2017 20:10:49 +0200 Subject: Minor improvements, mostly from reading :help --- doc/shortcuts.txt | 13 +++++++++++-- vimrc-full | 57 +++++++++++++++++++++++++++++++++++++------------------ 2 files changed, 50 insertions(+), 20 deletions(-) diff --git a/doc/shortcuts.txt b/doc/shortcuts.txt index a5c33ae..fdd28c8 100644 --- a/doc/shortcuts.txt +++ b/doc/shortcuts.txt @@ -23,8 +23,9 @@ ciw = select inner word caw = select 'a word' " where c can be replaced by v for visual mode - - +:%s/foo/bar/g = replace all foo with bar +:g/foo/s/bar//g = on lines with foo replace bar with nothing +:g!/foo/s/bar//g = on lines not containing foo replace bar with nothing [visual mode] # with selected lines gq = formats text so that it fits in whatever :set textwidth was set @@ -144,6 +145,14 @@ viB:sort = sort inner block by name [fancy utf-8 symbols] ௵ +[debugging] +:profile! start /tmp/profile.log +:profile func * +:profile file * +" At this point do slow actions +:profdel * +:e /tmp/profile.log + [vim modeline] filetype can have multiple values, like python.django The last line can be a mode line, which holds settings like tab width: diff --git a/vimrc-full b/vimrc-full index f99a5c1..4e73d20 100644 --- a/vimrc-full +++ b/vimrc-full @@ -52,7 +52,7 @@ if has("multi_byte") set listchars+=extends:» | " symbols used when using :set list (which displays non-printable chars) set listchars+=precedes:« | " symbols used when using :set list (which displays non-printable chars) - set listchars+=tab:▏\ | " + set listchars+=tab:▏\ | " set listchars+=trail:· | " symbols used when using :set list (which displays non-printable chars) " set listchars+=eol:↲ | " symbols used when using :set list (which displays non-printable chars) " set listchars+=space:· | " symbols used when using :set list (which displays non-printable chars) @@ -232,6 +232,15 @@ set equalalways | " do not evenly size windows when opening new or set nocursorline | " turn visual cursor line off (improves performance) "======================================================================================================================= +" Vim8 has a terminal command... +if has('terminal') + " use default ESC key to leave insert mode in the internal terminal emulator + tnoremap N + " make terminal windows hidden by default (copied from :help terminal) + autocmd BufWinEnter * if &buftype == 'terminal' | setlocal bufhidden=hide | endif +endif + + " NEOVIM_incompatible: " if has('nvim') " Neovim? @@ -318,7 +327,7 @@ if has("autocmd") autocmd FileType vim setlocal keywordprg=:help |. autocmd FileType c,cpp setlocal equalprg=clang-format autocmd FileType c,cpp setlocal breakat-=- - autocmd WinNew * if &previewwindow | setlocal nonumber signcolumn=no filetype=c nobuflisted | endif + autocmd BufWinEnter * if &previewwindow | setlocal nonumber signcolumn=no filetype=c nobuflisted | endif " autocmd FileType c,cpp setlocal iskeyword-=_ @@ -415,8 +424,8 @@ if has("autocmd") \ :execute ':!nvr --servername /tmp/nvimsocket --remote % +'.line('.'):stopinsert:set readonly menu &Verify.&Textwidth\ and\ white\ space - \ :execute ':match SpellBad /\%>'.&textwidth.'v./' - \ :2match SpellBad /\s\+$/ + \ :execute ':match Error /\%>'.&textwidth.'v./' + \ :2match Error /\s\+$/ menu &Verify.Highlight\ current\ file\ name \ :execute ':match SpellBad /'.escape(expand('%:t'), '.').'/' @@ -590,9 +599,9 @@ let g:lightline_buffer_git_icon = ' ' let g:lightline_buffer_ellipsis_icon = '..' let g:lightline_buffer_expand_left_icon = '◀ ' let g:lightline_buffer_expand_right_icon = ' ▶' -let g:lightline_buffer_active_buffer_left_icon = '' -let g:lightline_buffer_active_buffer_right_icon = '' -let g:lightline_buffer_separator_icon = ' ' +" let g:lightline_buffer_active_buffer_left_icon = ' ' +" let g:lightline_buffer_active_buffer_right_icon = '' +" let g:lightline_buffer_separator_icon = 'XX' " lightline-buffer function settings let g:lightline_buffer_show_bufnr = 0 @@ -606,7 +615,12 @@ let g:lightline_buffer_minfextlen = 3 let g:lightline_buffer_reservelen = 20 " \ ['warnings', 'errors', 'syntastic'] +" \ 'left': [ [ 'bufferinfo' ], [ 'bufferbefore', 'buffercurrent', 'bufferafter' ], ], let g:lightline = { + \ 'tabline': { + \ 'left': [ [ 'bufferinfo' ], [ 'bufferbefore', 'buffercurrent', 'bufferafter' ], ], + \ 'right': [ [], [ 'close' ] ], + \ }, \ 'colorscheme': 'Tomorrow_Night_Bright', \ 'separator': { 'left': "\ue0b0", 'right': "\ue0b2" }, \ 'subseparator': { 'left': "\ue0b1", 'right': "\ue0b3" }, @@ -620,13 +634,10 @@ let g:lightline = { \ [ 'spell', 'fileencoding', 'fileformat', 'filetype' ] \ ], \ }, - \ 'tabline': { - \ 'left': [ [ 'bufferinfo' ], [ 'bufferbefore', 'buffercurrent', 'bufferafter' ], ], - \ 'right': [ [], [ 'close' ] ], - \ }, \ 'component': { \ 'tagbar': '%{substitute(tagbar#currenttag("%s", "", "fs"), "\(.*\)", "", "")}', - \ 'ycmparent': '%{substitute(execute("YcmComplete GetParent"), "\(.*\)", "", "")}' + \ 'ycmparent': '%{substitute(execute("YcmComplete GetParent"), "\(.*\)", "", "")}', + \ 'filename': '%t' \ }, \ 'component_expand': { \ 'buffercurrent': 'lightline#buffer#buffercurrent2', @@ -661,7 +672,7 @@ autocmd! ColorScheme * call ExtendLightlineColorTheme() let g:ycm_server_python_interpreter = 'python3' let g:ycm_python_binary_path = '/usr/bin/python3' " the python interpreter of choice (for code checking) let g:ycm_add_preview_to_completeopt = 1 " reuse existing preview window - let g:ycm_autoclose_preview_window_after_insertion = 0 + let g:ycm_autoclose_preview_window_after_insertion = 1 let g:ycm_collect_identifiers_from_tags_files = 0 " Let YCM read tags from Ctags file let g:ycm_seed_identifiers_with_syntax = 1 " Completion for programming language's keyword let g:ycm_complete_in_comments = 1 " Completion in comments @@ -738,10 +749,13 @@ autocmd! ColorScheme * call ExtendLightlineColorTheme() "======================================================================================================================= " Plug 'rhysd/vim-clang-format' | unnecessary, because we can just :pyf /usr/share/clang/clang-format.py Plug 'kana/vim-operator-user' " dependency, which allows overriding the = operator for indentation + +" TODO: check if this is unrequired, when set equalprog is set to that py file autocmd FileType c,cpp,objc map = :pyf /usr/share/clang/clang-format.py + " let g:clang_format#detect_style_file = 1 " autocmd FileType c,cpp,objc map = (operator-clang-format) - + " Plug 'tpope/vim-characterize' | " normal mode: make ga show character names of Unicode chars (ga shows hex and dec values) " Plug 'rkitover/vimpager' " found this command instead (use as PAGER): @@ -797,14 +811,14 @@ function! ExtendColorTheme() highlight! link Folded LineNr highlight! Cursor guibg=#729fcf ctermbg=yellow highlight! link VertSplit LineNr - highlight! SpellBad ctermbg=none + " highlight! SpellBad ctermbg=none highlight! SpecialKey ctermfg=19 highlight! WhiteSpace ctermfg=19 highlight! link TabLine LineNr highlight! TabLineSel ctermbg=blue ctermfg=black highlight! link TabLineFill LineNr - highlight! Search ctermbg=12 ctermfg=0 + highlight! Search ctermbg=LightYellow ctermfg=black " generic, which should exist but don't highlight! Bold cterm=bold gui=bold @@ -814,6 +828,13 @@ function! ExtendColorTheme() " make tab stop (see listchars) less disturbing... highlight! link SpecialKey NonText + + + " Show trailing whitepace and spaces before a tab as part of the syntax highlighting + autocmd Syntax * syn match Error /\s\+$\| \+\ze\t/ containedin=ALL + " automatically enter list mode when going in insert mode (makes above syntax command temporarily ineffective) + autocmd InsertEnter * set list + autocmd InsertLeave * set nolist endfunction autocmd! ColorScheme * call ExtendColorTheme() @@ -830,7 +851,7 @@ else colorscheme base16-phd endif -set background=light +" set background=dark " ====================================================================================================================== " TESTING: @@ -844,4 +865,4 @@ set scrolloff=0 | " keeps cursor centered autocmd VimEnter,WinEnter * exec ':set scrolljump='.winheight(0)/2 " display highlight group under the cursor -map h :echo map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")') +map h :echo map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")') -- cgit v1.2.3