S
S
Sergey Burduzha2018-07-20 17:26:21
vim
Sergey Burduzha, 2018-07-20 17:26:21

How to remove the g flag in vim search?

When searching and replacing, all matches are changed
% s/some/text/
All the words some are changed to text.
But it should not be so, and only the first occurrence should change.
The g flag is used to replace all occurrences
Here is my config

set nocompatible
set backspace=indent,eol,start
set history=500
set ruler
"set incsearch
"set clipboard=unnamedplus
"set nu
set hidden
set termencoding=utf-8
set updatetime=0
set wrap 
"set showmatch 
"set hlsearch
"set ignorecase
set expandtab
set tabstop=2
map :call amv#toggle_spell()
imap { {}O
imap [ []
imap ( ()

if &t_Co > 2 || has("gui_running")
  syntax on
    set hlsearch
    endif

filetype plugin indent on    

"autocmd FileType text setlocal textwidth=78
let g:mapleader='['
                    			
"mappings
map <C-n> :NERDTreeToggle<CR>
map <Leader> <Plug>(easymotion-prefix)
:inoremap jk <Esc>
:noremap <silent> <Space> :silent noh<Bar>echo<CR>

call plug#begin('~/.vim/plugged')

"colorscheme
Plug 'dracula/vim', { 'as': 'dracula'  }
Plug 'scrooloose/nerdtree', {'on':  'NERDTreeToggle' }
Plug 'jiangmiao/auto-pairs'
Plug 'tpope/vim-fugitive'
Plug 'airblade/vim-gitgutter'
Plug 'kien/ctrlp.vim'
Plug 'easymotion/vim-easymotion'

call plug#end()

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
jcmvbkbc, 2018-07-20
@serii81

The g flag is used to replace all occurrences

To replace all occurrences in one line.
The % just says apply to all rows.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question