Thursday, January 20, 2022

Re: Disable Help

Tony,

"map <F1> <Nop>" is all that works for me, so far, during Normal/Command mode to prevent bringing up VIM HELP.
This is placed at the bottom of my .vimrc.

Attempting, "map! <F1> <Nop>"  is accepted, but does not prevent the <F1>, while in INSERT mode, from bringing up VIM HELP .
No form I tried of 'tmap' would be accepted by vim.

For what it is worth, I'm using CentOS 7.9, with KDE desktop, Konsole terminal windows, patched via the latest yum update.
VIM is version 7.4 (2013 Aug 10, compiled Dec 15 2020 16:44:08);  Included patches: 1-207, 209-629
Konsole terminals are standardized black background, zero transparency and green text.

I've included my entire .vimrc (current state) below my signature (and in-between the lines of dashes), for critique/reference/review.
I'm really proud of my status line, too.

Thank you to everyone who's been helping me on this!

R,
-Joe Wulf;  RHCSA(RHEL7), FITSP-D, CISSP, VCP3, CPO(USN/RET)
Tony Robbins:  "Management is focusing on getting someone to get a result. Leadership is producing a standard in someone that when you're gone, they will live by to produce higher level results consistently".

-----------------------------------------------------------------------------------
" .vimrc

" Standardized .vimrc file;  Written/implemented by:  Joe Wulf, 20220120@1925.
" Leading DoubleQuote--This is the right way to comment out a line in .vimrc.
" Primary Reference:  man 1 vim    -and-  :help (while in vim)

let $TMPDIR = expand('~/tmp')  " Should ease using VIM 'help', among other benefits of a local per-user-based 'tmp' storage.
                               " Supported by standard linux user-creation template which has ~/.tmp inherently there.

" Available/default colorschemes (RHEL7x/8x -- vim74+); typically found at: /usr/share/vim/vim<vernum>/colors
"colo blue
"colo darkblue
"colo default    " default
"colo delek      " ok; hard though with tons of RED
"colo desert
"colo elflord
"colo evening
"colo industry   " Only in RHEL8x
 colo koehler    " good +1 for GreenText w/ BlackBackground
"colo morning
"colo murphy
"colo pablo      " ok
"colo peachpuff
"colo ron
"colo shine
"colo slate      " good
"colo torte
"colo zellner

scriptencoding utf-8           " Do all the sets
set autoread                   " Attempts to monitor currently open file(s); watching for changes outside of VI/VIM and notifying you
set background=dark            "
set bs=eol,indent,start        " Allow backspacing over everything while in insert mode
set confirm                    " Always raise a dialog instead of failing out
set cursorline                 " Default highlight current line; opposite of [set nocursorline]; on by default
set fileencoding=utf-8         " Rounds out environment locale compliance with  'LANG=en_US.UTF-8'
set encoding=utf-8             " Rounds out environment locale compliance with  'LANG=en_US.UTF-8'
set history=10000              " Sufficiently voluminous history of VIM commands, per user
set hlsearch                   " Highlight search-term/matches
set incsearch                  " Highlight / immediately search as characters are typed
set laststatus=2               " Always display the status line
set modelines=0                " Addresses security issues; Ref:  https://www.gilesorr.com/blog/vim-tips-22-modelines.html
set mouse-=a                   " Disable automatically entering visual mode
"et mouse=a                    " Enable the mouse for scrolling (bad for pasting via mouse)
set noeb novb t_vb=            " NoErrorbells and t_VisualBell; unset; is another opportunity to achieve blessed silence
set noflash                    " Disable visual flashing for error(s)
set noignorecase               " Force ignoring cAsE when [/?] searching, off by default
set novb                       " Disable visual bell for error(s)
"et number                     " Would enable line numbering; not advisable as a default
set paste                      " Allows pasting in, without typical auto-formatting
"et scrolloff=5                " This will keep the cursor at least 5 lines away from the top or bottom of the editor window (not advisable); Nbr can be locally adjusted
"et showcmd                    " Shows partial commands in the last line of the screen, but by default, do not want this behavior
set showmatch                  " Highlight matching pairs of the following sets of character-pairs:  "[{('``')}]", even works across multiple lines
set showmode                   " Always indicate mode (Command/Insert) on the ruler/status line
set t_Co=256                   " Explicitly force the state where the terminal has 256 colors
set title                      " Change the terminal's title based on the file being edited; very useful in a terminal window with multiple tabs (i.e. KDE Konsole)
set undolevels=1000            " Provide for many mucho levels of undo, per vi-session, per file

                               " Next are the unsets
set nocompatible               " Gets rid of the crap that Vim does to be vi compatible, thus vim is substantially improved
"et nocursorline               " Does the opposite of (set cursorline) which highlights the current line with and edge-to-edge underline; off by default
set noerrorbells               " No damned audible 'bell' to bother with;    Ref:  https://vim.fandom.com/wiki/Disable_beeping
set nomodeline                 " Addresses security issues; Ref:  https://alioth-lists-archive.debian.net/pipermail/pkg-vim-maintainers/2007-June/004020.html
"et nopaste                    " Toggled off, allows formatting of pasted content; opposite of 'set paste'
set novisualbell               " No damned visual 'bell' to be bothered by;  Ref:  https://vim.fandom.com/wiki/Disable_beeping

syntax reset                   " Puts syntax color highlighting back to sane defaults
set syntax=on                  " Set syntax color highlighting on by default or use:  ':syntax off' to disable
syntax on                      " Further ensures syntax highlighting is on/enabled

" Reference:  https://vim.fandom.com/wiki/Have_Vim_check_automatically_if_the_file_has_changed_externally; specifically see:  'Alternative Solutions'!
" -- Will reload target file content when entering the buffer or gaining focus; trigger autoread reload when changing buffers or coming back to vim
au FocusGained,BufEnter * :silent! !
" -- Will save when exiting the buffer or losing focus; not enabled by default; must still TEST, use with caution.
" au FocusLost,WinLeave * :silent! w

if has('autocmd') && has('gui_running')
   " Disables beeping and visual bells even in Vim GUI.
   " If-check prevents error when /usr/bin/vim isn't compiled with autoCMD; typically it is by default.
   autoCMD GUIEnter * set noerrorbells novisualbell t_vb=
endif

" Set this StatusLine look/feel 'after' the colorscheme is merged in (up above).
" Reference:  http://vimdoc.sourceforge.net/htmldoc/options.html#'statusline'
" This statusline example is 'OK' on Green Text w/ Black Background
" hi StatusLine     term=bold,reverse  cterm=bold ctermfg=black ctermbg=cyan gui=bold guifg=blue guibg=white"
" This statusline example is 'Great' on GreenText w/ BlackBackground
hi StatusLine     term=bold,reverse  cterm=bold ctermfg=white ctermbg=blue gui=bold guifg=blue guibg=white"

" Must still document this line structure!!!
" Construct a highly useful standard status line to be displayed [example ruler/status line view; 'set' command which achieves it].
" Modern version--viable in a terminal only 80 columns wide; generally most useful in terminal 90+ columns wide (based on length of filename being edited).
" [RO] [+] -(x)- Buf[1]                                          Fmt[unix[conf]] (C:001|L:001/329)  A[035] H[23] (  0%|b:00001)-
"
set statusline=%<%r\ %m\ -(%f)-%w\ Buf[%n]%=\ Fmt[%{&ff}%y]\ (C:%03c\|L:%03l/%03L)\ A[\%03.3b]\ H[%02.2B]\ (%3p%%\|b:%05o)-

" This will center the next forward (/) found search result into the center of the shell window.
" Reference:  https://vi.stackexchange.com/questions/13641/how-can-i-center-the-window-on-each-search-result
function! CenteredFindNext(forward)
    " save the current value for later restore
    let s:so_curr=&scrolloff
    set scrolloff=999
    try
        if a:forward
            silent normal! n
        else
            silent normal! N
        endif
    finally
        " restore no matter what
        let &scrolloff=s:so_curr
    endtry
endfunction
nnoremap <silent>n :call CenteredFindNext(1)<CR>
nnoremap <silent>N :call CenteredFindNext(0)<CR>

" Unmap <F1> from being the ESC out to VI help.  ":help" clearly will always continue to work.
" Reference:  https://vim.fandom.com/wiki/Disable_F1_built-in_help_key
cmap <F1> <Nop>
imap <F1> <Nop>
lmap <F1> <Nop>
map <F1> <Nop>
map! <F1> <nop>
nmap <F1> <Nop>
omap <F1> <Nop>
smap <F1> <Nop>
vmap <F1> <Nop>
xmap <F1> <Nop>
"
"map! <F1> <nop>   " Doesn't work
"tmap <F1> <Nop>   " Doesn't work
"imap! <F1> <nop>  " BAD
"nmap! <F1> <nop>  " BAD
"iu <F1>           " BAD
"unm <F1>          " BAD
"imap <F1> :echo<CR>
"nmap <F1> :echo<CR>
"inoremap <F1> <esc>
"inoremap <F1> <Nop>

"
" NUGGETS/LessonsLearned of vim goodies:
" -  /[^\x00-\x7f]   " This will do a NEGATIVE search; good for finding non-ascii characters.
" -  :%s/\\n/\r/g    " This will convert all null's (\n) in a given text file, to real CR's
" -  set nowrap      " This will stop vi from wrapping lines of text in the window (leaveing some longer lines visually 'chopped off'; sometimes helpful).
"
" Additional helpful VI references:
" -  https://unix.stackexchange.com/questions/199203/why-does-vim-indent-pasted-code-incorrectly
" -  https://vim.fandom.com/wiki/Disable_automatic_comment_insertion
" -  https://vim.fandom.com/wiki/Pasting_code_with_syntax_coloring_in_emails
"

-----------------------------------------------------------------------------------


On Thu, Jan 20, 2022 at 4:30 PM Tony Mechelynck <antoine.mechelynck@gmail.com> wrote:
On Thu, Jan 20, 2022 at 4:26 PM Joseph Wulf <joseph.c.wulf@gmail.com> wrote:
>
> Gary,
>
> Little closer......The results for "i' were:
> i  <F1>          <Nop>         Last set from ~/.vimrc
> In my previous email, I showed that (I thought) I'd addressed ALL the modes (c, i, l, n, o, s, v, x).

Normally, using

        map <F1> <Nop>
        map! <F1> <Nop>

ought to work for all usual modes: with exclamation mark for Insert
and Command-line modes, without it for Normal, Visual (i.e. s+x) and
Operator-pending. If you use the terminal window you may have to add a
tmap. Language mappings are used when keymaps are active (i.e.
'iminsert' is equal to 1, toggled by Ctrl-^), any key with no langmap
defined defaults to whatever it does in "standard" Insert mode. See
:help :map-commands

Best regards,
Tony.
>
> R,
> -Joe Wulf;  RHCSA(RHEL7), FITSP-D, CISSP, VCP3, CPO(USN/RET)
> Tony Robbins:  "Management is focusing on getting someone to get a result. Leadership is producing a standard in someone that when you're gone, they will live by to produce higher level results consistently".
>
>
>
>
> On Wed, Jan 19, 2022 at 7:38 PM Gary Johnson <garyjohn@spocom.com> wrote:
>>
>> On 2022-01-19, Joseph Wulf wrote:
>> > Gary,
>> >
>> > Thank you.
>> >
>> > That's interesting.
>> > In doing  ":verbose map <f1>", I get the following output:
>> > x  <F1>          <Nop>               Last set from ~/.vimrc
>> > s  <F1>          <Nop>               Last set from ~/.vimrc
>> > o  <F1>          <Nop>               Last set from ~/.vimrc
>> > n  <F1>          <Nop>               Last set from ~/.vimrc
>> >
>> > While in my .vimrc, I have:
>> > cmap <F1> <nop>
>> > imap <F1> <nop>
>> > lmap <F1> <nop>
>> > nmap <F1> <nop>
>> > omap <F1> <nop>
>> > smap <F1> <nop>
>> > vmap <F1> <nop>
>> > xmap <F1> <nop>
>> >
>> > At the moment, in command-mode, <F1> is properly NOT working, while in INSERT
>> > mode, <F1> still does bring up the help.
>> > I can see I'm getting closer, as I'm half-way there.
>>
>> Joe,
>>
>> Thanks for showing all that.  Interesting that your insert-mode
>> mapping doesn't work.  I was thinking that
>>
>>     verbose map <f1>
>>
>> would show all maps of <f1>, but it doesn't.  It doesn't show
>> insert-mode maps.  Obvious on reflection, but I don't always
>> reflect.  To see those, execute
>>
>>     :verbose imap <f1>
>>
>> HTH,
>> Gary
>>
>> --
>> --
>> You received this message from the "vim_use" maillist.
>> Do not top-post! Type your reply below the text you are replying to.
>> For more information, visit http://www.vim.org/maillist.php
>>
>> ---
>> You received this message because you are subscribed to the Google Groups "vim_use" group.
>> To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
>> To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/20220120003914.GA14109%40phoenix.
>
> --
> --
> You received this message from the "vim_use" maillist.
> Do not top-post! Type your reply below the text you are replying to.
> For more information, visit http://www.vim.org/maillist.php
>
> ---
> You received this message because you are subscribed to the Google Groups "vim_use" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/CAJ8cad-aZORqWSjdqiZMexQwUQ%2BsSyQ%2BzLazhpzO2GQVxE1XTw%40mail.gmail.com.

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/CAJkCKXutxVKcinNVcSkyTL9AKP47ZnfXrSwXuO5amF1tJU32Hw%40mail.gmail.com.

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/CAJ8cad_e68%2BpOKjzvQdQtCK8jsZav5DXQMgT03Apeoz5OdUoXQ%40mail.gmail.com.

No comments:

Post a Comment