autocmd WinEnter * if &diff | set nocursorline | endif
" or
au OptionSet diff let &cul=!v:option_new
" or
augroup CursorLine
au!
au FilterWritePost * if &diff | let &cul=0 |endif
au BufEnter * if !&diff | let &cul=1 |endif
augroup end
" go back to insert mode when entering the terminal window
autocmd BufEnter * if &buftype == 'terminal' | :startinsert | endif
function! NeovimTermOpen()
:split
:terminal
:startinsert
endfunction
cabbrev ter call NeovimTermOpen()
or and use: for f in GetFiletypes() | echo f | endfor
function! GetFiletypes()
" Get a list of all the runtime directories by taking the value of that
" option and splitting it using a comma as the separator.
let rtps = split(&runtimepath, ",")
" This will be the list of filetypes that the function returns
let filetypes = []
" Loop through each individual item in the list of runtime paths
for rtp in rtps
let syntax_dir = rtp . "/syntax"
" Check to see if there is a syntax directory in this runtimepath.
if (isdirectory(syntax_dir))
" Loop through each vimscript file in the syntax directory
for syntax_file in split(glob(syntax_dir . "/*.vim"), "\n")
" Add this file to the filetypes list with its everything
" except its name removed.
call add(filetypes, fnamemodify(syntax_file, ":t:r"))
endfor
endif
endfor
" This removes any duplicates and returns the resulting list.
" NOTE: This might not be the best way to do this, suggestions are welcome.
return uniq(sort(filetypes))
endfunction
- [Vim documentation: pattern](http://vimdoc.sourceforge.net/htmldoc/pattern.html#/%5Cr) : - `\n` matches an end of line (newline) - `\r` matches a carriage return (more precisely it’s treated as the input `CR`))
" support unicode
function! AppendFullCode() range
for lnum in range(a:firstline, a:lastline)
let char = getline(lnum)[0]
let code = char2nr(char)
let hex = code > 0xffff ? printf("Hex %06x", code) : printf("Hex %04x", code)
let oct = printf("Octal %o", code)
call setline( lnum, printf("%s: %d, %s, %s", char, code, hex, oct) )
endfor
endfunction
" usage
:%call AppendFullCode()
" full version
function! AppendFullAscii() range
for lnum in range(a:firstline, a:lastline)
let char = getline(lnum)[0]
let code = char2nr(char)
" get code
let dec = code
let hex = code > 0xffff ? printf("%08x", code) : printf("%04x", code)
let oct = printf("%o", code)
" UTF-8 coding
let utf8_bytes = []
let n = code
while n > 0
call insert(utf8_bytes, n % 0x100)
let n = n / 0x100
endwhile
" get final string
let result = printf("%s : DEC %d | HEX %s | OCT %o | UTF-8 %s",
\ char, dec, hex, oct, join(map(utf8_bytes, 'printf("%02x", v:val)'), ''))
call setline(lnum, result)
endfor
endfunction
" usage
:%call AppendAscii()
" using `:ascii` command and redirect
function! AppendAscii() range
let save = @a
for lnum in range(a:firstline, a:lastline)
let char = getline(lnum)[0]
" go to first column
execute lnum . 'normal! 0'
" capture ascii result
redir @a
silent! ascii
redir END
" format output
let output = substitute(@a, '\n', '', 'g')
" remove <x>
let output = substitute(output, '^<.*>\s*', '', '')
let output = substitute(output, ',\s*Hex\s*', ', Hex ', '')
let output = substitute(output, ',\s*Octal\s*', ', Octal ', '')
" join string
call setline(lnum, printf("%s: %s", char, output))
endfor
let @a = save
endfunction
" usage
:%call AppendAscii()
# last line
$ vim + /path/to/file
# specific line
$ vim +123 /path/to/file
" or https://til.hashrocket.com/posts/joyovn3pau-go-to-file-with-line-number
$ vim /path/to/file:123
set iskeyword-=_
nnoremap <leader>e :set iskeyword-=_<cr>diw:set iskeyword+=_<cr>i
run vim commands in terminal
[!NOTE|label:manual:]
$ man vim
...
OPTIONS
+{command}
-c {command}
{command} will be executed after the first file has been read. {command} is interpreted
as an Ex command. If the {command} contains spaces it must be enclosed in double quotes
(this depends on the shell that is used). Example: Vim "+set si" main.c
Note: You can use up to 10 "+" or "-c" commands.
--cmd {command}
Like using "-c", but the command is executed just before processing any vimrc file. You
can use up to 10 of these commands, independently from "-c" commands.
" DrChip's additional man.vim stuff
syn match manSectionHeading "^\s\+[0-9]\+\.[0-9.]*\s\+[A-Z].*$" contains=manSectionNumber
syn match manSectionNumber "^\s\+[0-9]\+\.[0-9]*" contained
syn region manDQString start='[^a-zA-Z"]"[^", )]'lc=1 end='"' contains=manSQString
syn region manSQString start="[ \t]'[^', )]"lc=1 end="'"
syn region manSQString start="^'[^', )]"lc=1 end="'"
syn region manBQString start="[^a-zA-Z`]`[^`, )]"lc=1 end="[`']"
syn region manBQSQString start="``[^),']" end="''"
syn match manBulletZone transparent "^\s\+o\s" contains=manBullet
syn case match
syn keyword manBullet contained o
syn match manBullet contained "\[+*]"
syn match manSubSectionStart "^\*" skipwhite nextgroup=manSubSection
syn match manSubSection ".*$" contained
hi link manSectionNumber Number
hi link manDQString String
hi link manSQString String
hi link manBQString String
hi link manBQSQString String
hi link manBullet Special
hi manSubSectionStart term=NONE cterm=NONE gui=NONE ctermfg=black ctermbg=black guifg=navyblue guibg=navyblue
hi manSubSection term=underline cterm=underline gui=underline ctermfg=green guifg=green
:redir @a | silent digraph | redir END | new +setl\ buftype=nofile\ bufhidden=wipe | put! a
: or
:redir @a | silent digraph | redir END | new +setl\ buftype=nofile\ bufhidden=wipe | put! a | on
if has('statusline')
set laststatus=2
set statusline=%#User2#%m%r%*\ %F\ %y,%{&fileformat}
" set statusline+=\ %{FugitiveStatusline()} " set statusline+=\ %{fugitive#statusline()}
set statusline+=%=\ %-{strftime(\"%H:%M\ %d/%m/%Y\")}\ %b[A],0x%B\ %c%V,%l/%L\ %1*--%n%%--%*\ %p%%\ |
endif