The following is my .vimrc file in it's entirety:
For some reason, the set wrap
and set textwidth=73
(at bottom of file) are not working (I want to have files wrap at 73 columns). I can still go into a file and type past 73 columns.
Is there a conflicting command here that needs to be fixed? Or am I doing something wrong?
set nocompatible
set smartindent
set cursorline
filetype plugin indent on
set background=dark
syntax enable
set grepprg=grep\ -nH\ $*
syntax on
set mouse=a
set history=1000
set showmode
if has('cmdline_info')
set ruler " show the ruler
set rulerformat=%30(%=\:b%n%y%m%r%w\ %l,%c%V\ %P%) " a ruler on steroids
set showcmd " show partial commands in status line and
endif
set backspace=indent,eol,start " backspace for dummys
set linespace=0 " No extra spaces between rows
set nu " Line numbers on
set showmatch " show matching brackets/parenthesis
set incsearch " find as you type search
set hlsearch " highlight search terms
set winminheight=0 " windows can be 0 line high
set ignorecase " case insensitive search
set smartcase " case sensitive when uc present
set wildmenu " show list instead of just completing
set wildmode=list:longest,full
set scrolljump=5 " lines to scroll when cursor leaves screen
set scrolloff=3 " minimum lines to keep above and below cursor
set gdefault " the /g flag on :s substitutions by default
set autoindent " indent at the same level of the previous line
set shiftwidth=4 " use indents of 4 spaces
set expandtab " tabs are spaces, not tabs
set tabstop=4 " an indentation every four columns
set softtabstop=4 " let backspace delete indent
set matchpairs+=<:>
set comments=sl:/*,mb:*,elx:*/
autocmd FileType c,cpp,java,php,js,python,twig,xml,yml autocmd BufWritePre <buffer> :call setline(1,map(getline(1,"$"),'substitute(v:val,"\\s\\+$","","")'))
set foldmethod=syntax "fold based on indent
set foldnestmax=10 "deepest fold is 10 levels
set foldlevel=0 "this is just what i use
set wrap
set textwidth=73
set formatoptions+=t
EDIT: I want VIM to auto wrap at 73 lines (real time). Is that possible? I have tried adding set formatoptions+=t
to wrap text but it still isn't effective.
Options wrap
and textwidth
regard two completely different kinds of wrapping.
The textwidth
sets a line width limit, after which every new word (that means separated with spaces) will be placed in a new line.
Attached .vimrc
probably works correctly, and the textwitdh
does precisely this.
wrap
doesn't affect the edited file contents at all, just causing the line in file be displayed in several lines if it is longer than display width. If found no pleasing way to configure this to wrap at the fixed column width and I, personally, don't see such a need.
However there are two aspects of soft-wrapping that can be changed if you find soft wrapping at the end of the screen annoying.
set columns=73
(it is quite disturbing, because it changes the width of whole window)linebreak
option, see help linebreak
for details.Perhaps not the best solution, but try to assign textwidth
and formatoptions
inside an autocommand, and then format all lines of your file.
autocmd BufRead * set fo+=t tw=73|normal gggqG
This worked in my test. You can be more specific and substitute *
with *.txt
or similar.
Put this into .vimr
c, that worked for me:
autocmd FileType * set textwidth=58
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With